Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add node version to spaces e2e image #3536

Merged
merged 5 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions e2e/test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const { ElasticsearchTestHelpers } = require('elasticsearch-store');
const { customAlphabet } = require('nanoid');
const path = require('path');
const defaultNodeVersion = require('../../packages/scripts/src/helpers/config.ts');

const {
TEST_INDEX_PREFIX,
Expand Down Expand Up @@ -35,7 +36,8 @@ const {
HOST_IP = '127.0.0.1',
GENERATE_ONLY,
TEST_OPENSEARCH = false,
TEST_PLATFORM = 'native'
TEST_PLATFORM = 'native',
NODE_VERSION = defaultNodeVersion
} = process.env;

const TEST_HOST = TEST_OPENSEARCH ? OPENSEARCH_HOST : ELASTICSEARCH_HOST;
Expand Down Expand Up @@ -82,5 +84,6 @@ module.exports = {
newId,
TEST_HOST,
TEST_PLATFORM,
TERASLICE_PORT
TERASLICE_PORT,
NODE_VERSION
};
14 changes: 13 additions & 1 deletion e2e/test/docker-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

const { Compose } = require('@terascope/docker-compose-js');
const ms = require('ms');
const { DEFAULT_WORKERS } = require('./config');
const semver = require('semver');
const { DEFAULT_WORKERS, NODE_VERSION } = require('./config');
const signale = require('./signale');

const compose = new Compose('docker-compose.yml');
Expand Down Expand Up @@ -36,6 +37,17 @@ async function dockerUp() {
'force-recreate': ''
});
signale.success('Docker environment is good to go', getElapsed(startTime));

let e2eNodeVersion = await compose.runCmd('exec', undefined, 'teraslice-master', 'node', '--version');
signale.info('Teraslice node version: ', e2eNodeVersion);
const parsedVersion = semver.parse(e2eNodeVersion);
if (parsedVersion?.version) {
e2eNodeVersion = parsedVersion.version;
}
if (e2eNodeVersion !== NODE_VERSION) {
signale.error(`Expected node version(${NODE_VERSION}) does not match teraslice node version(${e2eNodeVersion})`);
process.exit(1);
}
}

function getElapsed(time) {
Expand Down
3 changes: 2 additions & 1 deletion packages/scripts/src/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ if (testElasticsearch) {

export const SEARCH_TEST_HOST = testHost;

export const defaultNodeVersion = '18.18.2';
// This overrides the value in the Dockerfile
export const NODE_VERSION = process.env.NODE_VERSION || '18.18.2';
export const NODE_VERSION = process.env.NODE_VERSION || defaultNodeVersion;

export const {
TEST_PLATFORM = 'native',
Expand Down
2 changes: 0 additions & 2 deletions packages/scripts/src/helpers/k8s-env/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ async function buildAndTagTerasliceImage(options:k8sEnvOptions) {
}

try {
signale.pending(`Tagging image ${runImage} as ${e2eImage}`);
await dockerTag(runImage, e2eImage);
signale.success(`Image ${runImage} re-tagged as ${e2eImage}`);
} catch (err) {
throw new Error(`Failed to tag docker image ${runImage} as ${e2eImage}: ${err}`);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/src/helpers/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export function getServicesForSuite(suite: string): Service[] {
}

export function getDevDockerImage(nodeVersion?: string): string {
if (DEV_DOCKER_IMAGE) return DEV_DOCKER_IMAGE; // an override so shouldn't change
if (DEV_DOCKER_IMAGE) return `${DEV_DOCKER_IMAGE}-nodev${nodeVersion}`;

const rootInfo = getRootInfo();
const [registry] = rootInfo.terascope.docker.registries;
Expand Down
3 changes: 2 additions & 1 deletion packages/scripts/src/helpers/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,12 @@ export async function dockerStop(name: string): Promise<void> {
}

export async function dockerTag(from: string, to: string): Promise<void> {
logger.debug(`dockerTag: ${from} -> ${to}`);
signale.pending(`Tagging image ${from} as ${to}`);
await exec({
cmd: 'docker',
args: ['tag', from, to],
});
signale.success(`Image ${from} re-tagged as ${to}`);
}

export async function getContainerInfo(name: string): Promise<any> {
Expand Down
3 changes: 2 additions & 1 deletion packages/scripts/src/helpers/test-runner/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export function getEnv(options: TestOptions, suite?: string): ExecEnv {
NODE_ENV: 'test',
FORCE_COLOR: config.FORCE_COLOR,
TEST_NAMESPACE: config.TEST_NAMESPACE,
TZ: 'utc'
TZ: 'utc',
NODE_VERSION: options.nodeVersion
};

if (config.DOCKER_NETWORK_NAME) {
Expand Down
Loading