From b37ec8006c1f47b30869d65bcccdd191849fb5c0 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Wed, 11 Dec 2024 17:24:51 +0000 Subject: [PATCH 01/13] WIP --- packages/compass-e2e-tests/smoke-test.ts | 133 +++++++++++++++++++ packages/compass-e2e-tests/tsconfig.json | 5 +- packages/hadron-build/commands/download.d.ts | 0 packages/hadron-build/commands/info.d.ts | 0 4 files changed, 134 insertions(+), 4 deletions(-) create mode 100755 packages/compass-e2e-tests/smoke-test.ts create mode 100644 packages/hadron-build/commands/download.d.ts create mode 100644 packages/hadron-build/commands/info.d.ts diff --git a/packages/compass-e2e-tests/smoke-test.ts b/packages/compass-e2e-tests/smoke-test.ts new file mode 100755 index 00000000000..66a1233d336 --- /dev/null +++ b/packages/compass-e2e-tests/smoke-test.ts @@ -0,0 +1,133 @@ +#!/usr/bin/env npx ts-node +import yargs from 'yargs'; +import type { Argv } from 'yargs'; +import { hideBin } from 'yargs/helpers'; + +const argv = yargs(hideBin(process.argv)) + .middleware((argv) => { + if (process.env.EVERGREEN_BUCKET_NAME) { + argv.bucketName = process.env.EVERGREEN_BUCKET_NAME; + } + if (process.env.EVERGREEN_BUCKET_KEY_PREFIX) { + argv.bucketKeyPrefix = process.env.EVERGREEN_BUCKET_KEY_PREFIX; + } + + argv.isWindows = process.env.IS_WINDOWS === 'true'; + argv.isOSX = process.env.IS_OSX === 'true'; + argv.isRHEL = process.env.IS_RHEL === 'true'; + argv.isUbuntu = process.env.IS_UBUNTU === 'true'; + }) + .scriptName('smoke-tests') + .detectLocale(false) + .version(false) + .strict() + .option('skip-download', { + type: 'boolean', + description: "Don't download all assets before starting", + }) + .check((argv) => { + if (!argv.skipDownload) { + if (!(argv.bucketName && argv.bucketKeyPrefix)) { + throw new Error( + 'Either supply EVERGREEN_BUCKET_NAME and EVERGREEN_BUCKET_KEY_PREFIX or specify --skip-download' + ); + } + } + + if (!(argv.isWindows || argv.isOSX || argv.isUbuntu || argv.isRHEL)) { + throw new Error( + 'Set at least one of IS_WINDOWS, IS_OSX, IS_UBUNTU, IS_RHEL' + ); + } + + return true; + }); + +type BuilderCallbackParsedArgs Argv> = + ReturnType['parseSync']>; + +type SmokeTestsContext = BuilderCallbackParsedArgs; + +async function run() { + const parsedArgs = argv.parse(); + + if ('then' in parsedArgs && typeof parsedArgs.then === 'function') { + throw new Error('Async args parser is not allowed'); + } + + const context = parsedArgs as SmokeTestsContext; + + console.log(context); + + if (!context.skipDownload) { + // download + } + + // +} + +run() + .then(function () { + console.log('done'); + }) + .catch(function (err) { + console.error(err.stack); + process.exit(1); + }); + +// for later (once we can test upgrading TO this version), which channel are we on? dev, beta or staging + +// params needed for downloading all the assets +// EVERGREEN_BUCKET_NAME: mciuploads +// EVERGREEN_BUCKET_KEY_PREFIX: ${project}/${revision}_${revision_order_id} +// npm run --workspace mongodb-compass download + +// use build-info to get the info about the files +// npm run --workspace mongodb-compass build-info + +// from print-compass-env.sh +/* +IS_WINDOWS +IS_OSX +IS_UBUNTU +IS_RHEL +*/ + +/* +// expansions are from apply-compass-target-expansion func +// or npm run --workspace mongodb-compass build-info -- --format=yaml --flatten --out expansions.raw.yml +// env vars have to be set from that output somehow +WINDOWS_EXE_NAME: ${windows_setup_filename} +WINDOWS_MSI_NAME: ${windows_msi_filename} +WINDOWS_ZIP_NAME: ${windows_zip_filename} +WINDOWS_NUPKG_NAME: ${windows_nupkg_full_filename} + +OSX_DMG_NAME: ${osx_dmg_filename} +OSX_ZIP_NAME: ${osx_zip_filename} + +RHEL_RPM_NAME: ${linux_rpm_filename} +RHEL_TAR_NAME: ${rhel_tar_filename} + +LINUX_DEB_NAME: ${linux_deb_filename} +LINUX_TAR_NAME: ${linux_tar_filename} +*/ + +/* +- &get-artifact-params +aws_key: ${aws_key} +aws_secret: ${aws_secret} +bucket: mciuploads +content_type: application/octet-stream + + +// see get-all-artifacts + +EVERGREEN_BUCKET_NAME: mciuploads +EVERGREEN_BUCKET_KEY_PREFIX: ${project}/${revision}_${revision_order_id} + +npm run --workspace mongodb-compass download + +// takes dir and version + +can also be used with generateVersionsForAssets to figure out the download links for beta/stable if we have the version +*/ diff --git a/packages/compass-e2e-tests/tsconfig.json b/packages/compass-e2e-tests/tsconfig.json index d8494d7522d..8534724e776 100644 --- a/packages/compass-e2e-tests/tsconfig.json +++ b/packages/compass-e2e-tests/tsconfig.json @@ -1,7 +1,4 @@ { "extends": "@mongodb-js/tsconfig-compass/tsconfig.common.json", - "compilerOptions": { - // https://webdriver.io/docs/typescript/#framework-setup - //"types": ["node", "@wdio/globals/types"] - } + "compilerOptions": {} } diff --git a/packages/hadron-build/commands/download.d.ts b/packages/hadron-build/commands/download.d.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/hadron-build/commands/info.d.ts b/packages/hadron-build/commands/info.d.ts new file mode 100644 index 00000000000..e69de29bb2d From 77fb9aa02b7e685d58fd235060ff408bf5f88c5a Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Mon, 16 Dec 2024 10:58:50 +0000 Subject: [PATCH 02/13] wip --- packages/hadron-build/commands/download.d.ts | 1 + packages/hadron-build/commands/download.js | 13 +++++++++---- packages/hadron-build/commands/info.d.ts | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/hadron-build/commands/download.d.ts b/packages/hadron-build/commands/download.d.ts index e69de29bb2d..110182f0c73 100644 --- a/packages/hadron-build/commands/download.d.ts +++ b/packages/hadron-build/commands/download.d.ts @@ -0,0 +1 @@ +export function run(argv: any): Promise; diff --git a/packages/hadron-build/commands/download.js b/packages/hadron-build/commands/download.js index fd0468f4657..4632957d7b9 100644 --- a/packages/hadron-build/commands/download.js +++ b/packages/hadron-build/commands/download.js @@ -23,8 +23,7 @@ const builder = { }, }; -const handler = function handler(argv) { - cli.argv = argv; +const run = async function run (argv) { argv.version = argv.version.replace(/^v/, ''); const assets = Target.getAssetsForVersion(argv.dir, argv.version); @@ -43,12 +42,18 @@ const handler = function handler(argv) { cli.info(`${asset.name}: download from evg bucket complete`); }); - Promise.all(downloads).catch(abortIfError); -}; + return Promise.all(downloads) +} + +const handler = function handler(argv) { + cli.argv = argv; + run(argv).catch(abortIfError); +} module.exports = { command, describe, builder, + run, handler, }; diff --git a/packages/hadron-build/commands/info.d.ts b/packages/hadron-build/commands/info.d.ts index e69de29bb2d..e0d57f58fc9 100644 --- a/packages/hadron-build/commands/info.d.ts +++ b/packages/hadron-build/commands/info.d.ts @@ -0,0 +1 @@ +export function handler(argv: any): void; From db7d75291f9fd7c51c3d8fd81ace8f55b68fb119 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Mon, 16 Dec 2024 12:01:06 +0000 Subject: [PATCH 03/13] WIP --- packages/compass-e2e-tests/smoke-test.ts | 152 +++++++++++++++-------- 1 file changed, 97 insertions(+), 55 deletions(-) diff --git a/packages/compass-e2e-tests/smoke-test.ts b/packages/compass-e2e-tests/smoke-test.ts index 66a1233d336..3c791db798d 100755 --- a/packages/compass-e2e-tests/smoke-test.ts +++ b/packages/compass-e2e-tests/smoke-test.ts @@ -2,6 +2,9 @@ import yargs from 'yargs'; import type { Argv } from 'yargs'; import { hideBin } from 'yargs/helpers'; +import { promises as fs } from 'fs'; +import { handler as writeBuildInfo } from 'hadron-build/commands/info'; +import { run as downloadPackages } from 'hadron-build/commands/download'; const argv = yargs(hideBin(process.argv)) .middleware((argv) => { @@ -16,15 +19,30 @@ const argv = yargs(hideBin(process.argv)) argv.isOSX = process.env.IS_OSX === 'true'; argv.isRHEL = process.env.IS_RHEL === 'true'; argv.isUbuntu = process.env.IS_UBUNTU === 'true'; + if (process.arch) { + argv.arch = process.env.ARCH; + } }) .scriptName('smoke-tests') .detectLocale(false) .version(false) .strict() + .option('arch', { + type: 'string', + choices: ['x64', 'arm64'], + default: () => { + process.arch; + }, + }) .option('skip-download', { type: 'boolean', description: "Don't download all assets before starting", }) + .option('extension', { + type: 'string', + description: + 'If specified it will only run the smoke tests for the specified installer/package', + }) .check((argv) => { if (!argv.skipDownload) { if (!(argv.bucketName && argv.bucketKeyPrefix)) { @@ -40,6 +58,10 @@ const argv = yargs(hideBin(process.argv)) ); } + if (!argv.arch) { + throw new Error('Please provice ARCH (x64 or arm64)'); + } + return true; }); @@ -63,71 +85,91 @@ async function run() { // download } - // -} - -run() - .then(function () { - console.log('done'); - }) - .catch(function (err) { - console.error(err.stack); - process.exit(1); + // build-info + const infoArgs = { + format: 'json', + // TODO + dir: '', + version: '', + platform: '', + arch: '', + out: '', + }; + writeBuildInfo(infoArgs); + + // read the file + const buildInfo = JSON.parse(await fs.readFile(infoArgs.out, 'utf8')); + + // filter the extensions given the platform (isWindows, isOSX, isUbuntu, isRHEL) and extension + const { isWindows, isOSX, isRHEL, isUbuntu, extension } = context; + + const filenames = filterPackages(buildInfo, { + isWindows, + isOSX, + isRHEL, + isUbuntu, + extension, }); -// for later (once we can test upgrading TO this version), which channel are we on? dev, beta or staging - -// params needed for downloading all the assets -// EVERGREEN_BUCKET_NAME: mciuploads -// EVERGREEN_BUCKET_KEY_PREFIX: ${project}/${revision}_${revision_order_id} -// npm run --workspace mongodb-compass download - -// use build-info to get the info about the files -// npm run --workspace mongodb-compass build-info - -// from print-compass-env.sh -/* -IS_WINDOWS -IS_OSX -IS_UBUNTU -IS_RHEL -*/ + // loop through the remaining filenames and install each then run the tests + for (const filename of filenames) { + } +} -/* -// expansions are from apply-compass-target-expansion func -// or npm run --workspace mongodb-compass build-info -- --format=yaml --flatten --out expansions.raw.yml -// env vars have to be set from that output somehow -WINDOWS_EXE_NAME: ${windows_setup_filename} -WINDOWS_MSI_NAME: ${windows_msi_filename} -WINDOWS_ZIP_NAME: ${windows_zip_filename} -WINDOWS_NUPKG_NAME: ${windows_nupkg_full_filename} +type PackageFilterConfig = Pick< + SmokeTestsContext, + 'isWindows' | 'isOSX' | 'isRHEL' | 'isUbuntu' | 'extension' +>; -OSX_DMG_NAME: ${osx_dmg_filename} -OSX_ZIP_NAME: ${osx_zip_filename} +type WindowsBuildInfo = { + windows_setup_filename: string; + windows_msi_filename: string; + windows_zip_filename: string; + windows_nupkg_full_filename: string; +}; -RHEL_RPM_NAME: ${linux_rpm_filename} -RHEL_TAR_NAME: ${rhel_tar_filename} +type OSXBuildInfo = { + osx_dmg_filename: string; + osx_zip_filename: string; +}; -LINUX_DEB_NAME: ${linux_deb_filename} -LINUX_TAR_NAME: ${linux_tar_filename} -*/ +type UbuntuBuildInfo = {}; -/* -- &get-artifact-params -aws_key: ${aws_key} -aws_secret: ${aws_secret} -bucket: mciuploads -content_type: application/octet-stream +type RHELBuildInfo = {}; +function buildInfoIsWindows(buildInfo: any): buildInfo is WindowsBuildInfo {} -// see get-all-artifacts +function buildInfoIsOSX(buildInfo: any): buildInfo is OSXBuildInfo {} -EVERGREEN_BUCKET_NAME: mciuploads -EVERGREEN_BUCKET_KEY_PREFIX: ${project}/${revision}_${revision_order_id} +function buildInfoIsUbuntu(buildInfo: any): buildInfo is UbuntuBuildInfo {} -npm run --workspace mongodb-compass download +function buildInfoIsRHEL(buildInfo: any): buildInfo is RHELBuildInfo {} -// takes dir and version +function filterPackages(buildInfo: any, config: PackageFilterConfig) { + if (config.isWindows) { + if (!buildInfoIsWindows(buildInfo)) { + throw new Error('missing windows package keys'); + } + } else if (config.isOSX) { + if (!buildInfoIsOSX(buildInfo)) { + throw new Error('missing osx package keys'); + } + } else if (config.isRHEL) { + if (!buildInfoIsOSX(buildInfo)) { + throw new Error('missing rhel package keys'); + } + } else if (config.isUbuntu) { + if (!buildInfoIsOSX(buildInfo)) { + throw new Error('missing ubuntu package keys'); + } + } +} -can also be used with generateVersionsForAssets to figure out the download links for beta/stable if we have the version -*/ +run() + .then(function () { + console.log('done'); + }) + .catch(function (err) { + console.error(err.stack); + process.exit(1); + }); From a52b299af4610994395d8fcbbd39cf754b63f190 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Mon, 16 Dec 2024 14:24:23 +0000 Subject: [PATCH 04/13] WIP --- packages/compass-e2e-tests/smoke-test.ts | 93 +++++++++++++++++++----- 1 file changed, 75 insertions(+), 18 deletions(-) diff --git a/packages/compass-e2e-tests/smoke-test.ts b/packages/compass-e2e-tests/smoke-test.ts index 3c791db798d..30d44fb86cb 100755 --- a/packages/compass-e2e-tests/smoke-test.ts +++ b/packages/compass-e2e-tests/smoke-test.ts @@ -81,8 +81,15 @@ async function run() { console.log(context); + // TODO: load version from either DEV_VERSION_IDENTIFIER if set or version in packages/compass/package.json + if (!context.skipDownload) { // download + downloadPackages({ + // TODO + dir: '', + version: '', + }); } // build-info @@ -113,6 +120,8 @@ async function run() { // loop through the remaining filenames and install each then run the tests for (const filename of filenames) { + console.log(filename); + // TODO(COMPASS-8533): extract or install filename and then test the Compass binary } } @@ -121,48 +130,96 @@ type PackageFilterConfig = Pick< 'isWindows' | 'isOSX' | 'isRHEL' | 'isUbuntu' | 'extension' >; -type WindowsBuildInfo = { - windows_setup_filename: string; - windows_msi_filename: string; - windows_zip_filename: string; - windows_nupkg_full_filename: string; -}; +// subsets of the hadron-build info result -type OSXBuildInfo = { - osx_dmg_filename: string; - osx_zip_filename: string; -}; +const windowsFilenameKeys = [ + 'windows_setup_filename', + 'windows_msi_filename', + 'windows_zip_filename', + 'windows_nupkg_full_filename', +] as const; +type WindowsBuildInfo = Record; -type UbuntuBuildInfo = {}; +const osxFilenameKeys = ['osx_dmg_filename', 'osx_zip_filename'] as const; +type OSXBuildInfo = Record; -type RHELBuildInfo = {}; +const ubuntuFilenameKeys = [ + 'linux_deb_filename', + 'linux_tar_filename', +] as const; +type UbuntuBuildInfo = Record; -function buildInfoIsWindows(buildInfo: any): buildInfo is WindowsBuildInfo {} +const rhelFilenameKeys = ['linux_rpm_filename', 'rhel_tar_filename'] as const; +type RHELBuildInfo = Record; -function buildInfoIsOSX(buildInfo: any): buildInfo is OSXBuildInfo {} +function buildInfoIsWindows(buildInfo: any): buildInfo is WindowsBuildInfo { + for (const key of windowsFilenameKeys) { + if (!buildInfo[key]) { + return false; + } + } + return true; +} -function buildInfoIsUbuntu(buildInfo: any): buildInfo is UbuntuBuildInfo {} +function buildInfoIsOSX(buildInfo: any): buildInfo is OSXBuildInfo { + for (const key of osxFilenameKeys) { + if (!buildInfo[key]) { + return false; + } + } + return true; +} -function buildInfoIsRHEL(buildInfo: any): buildInfo is RHELBuildInfo {} +function buildInfoIsUbuntu(buildInfo: any): buildInfo is UbuntuBuildInfo { + for (const key of ubuntuFilenameKeys) { + if (!buildInfo[key]) { + return false; + } + } + return true; +} + +function buildInfoIsRHEL(buildInfo: any): buildInfo is RHELBuildInfo { + for (const key of rhelFilenameKeys) { + if (!buildInfo[key]) { + return false; + } + } + return true; +} function filterPackages(buildInfo: any, config: PackageFilterConfig) { + let filenames: string[] = []; + if (config.isWindows) { if (!buildInfoIsWindows(buildInfo)) { throw new Error('missing windows package keys'); } + filenames = windowsFilenameKeys.map((key) => buildInfo[key]); } else if (config.isOSX) { if (!buildInfoIsOSX(buildInfo)) { throw new Error('missing osx package keys'); } + filenames = osxFilenameKeys.map((key) => buildInfo[key]); } else if (config.isRHEL) { - if (!buildInfoIsOSX(buildInfo)) { + if (!buildInfoIsRHEL(buildInfo)) { throw new Error('missing rhel package keys'); } + filenames = rhelFilenameKeys.map((key) => buildInfo[key]); } else if (config.isUbuntu) { - if (!buildInfoIsOSX(buildInfo)) { + if (!buildInfoIsUbuntu(buildInfo)) { throw new Error('missing ubuntu package keys'); } + filenames = ubuntuFilenameKeys.map((key) => buildInfo[key]); } + + const extension = config.extension; + + if (extension !== undefined) { + return filenames.filter((filename) => filename.endsWith(extension)); + } + + return filenames; } run() From 1e72a543e442674db3c078eb0c2773d513db965c Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Tue, 17 Dec 2024 09:34:49 +0000 Subject: [PATCH 05/13] WIP --- packages/compass-e2e-tests/.gitignore | 1 + packages/compass-e2e-tests/smoke-test.ts | 72 ++++++++++++++++++------ 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/packages/compass-e2e-tests/.gitignore b/packages/compass-e2e-tests/.gitignore index 74d7b19ca26..ae91dfc1056 100644 --- a/packages/compass-e2e-tests/.gitignore +++ b/packages/compass-e2e-tests/.gitignore @@ -2,3 +2,4 @@ .log fixtures/*.csv fixtures/*.json +hadron-build-info.json diff --git a/packages/compass-e2e-tests/smoke-test.ts b/packages/compass-e2e-tests/smoke-test.ts index 30d44fb86cb..2d6d38570f8 100755 --- a/packages/compass-e2e-tests/smoke-test.ts +++ b/packages/compass-e2e-tests/smoke-test.ts @@ -3,8 +3,8 @@ import yargs from 'yargs'; import type { Argv } from 'yargs'; import { hideBin } from 'yargs/helpers'; import { promises as fs } from 'fs'; +import path from 'path'; import { handler as writeBuildInfo } from 'hadron-build/commands/info'; -import { run as downloadPackages } from 'hadron-build/commands/download'; const argv = yargs(hideBin(process.argv)) .middleware((argv) => { @@ -15,6 +15,12 @@ const argv = yargs(hideBin(process.argv)) argv.bucketKeyPrefix = process.env.EVERGREEN_BUCKET_KEY_PREFIX; } + // Dor dev versions we need this from evergreen. For beta or stable we get + // it from the package.json + if (process.env.DEV_VERSION_IDENTIFIER) { + argv.version = process.env.DEV_VERSION_IDENTIFIER; + } + argv.isWindows = process.env.IS_WINDOWS === 'true'; argv.isOSX = process.env.IS_OSX === 'true'; argv.isRHEL = process.env.IS_RHEL === 'true'; @@ -79,29 +85,26 @@ async function run() { const context = parsedArgs as SmokeTestsContext; - console.log(context); + console.log('context', context); + const compassDir = path.resolve(__dirname, '..', '..', 'packages', 'compass'); // TODO: load version from either DEV_VERSION_IDENTIFIER if set or version in packages/compass/package.json - - if (!context.skipDownload) { - // download - downloadPackages({ - // TODO - dir: '', - version: '', - }); - } + const version = JSON.parse( + await fs.readFile(path.join(compassDir, 'package.json'), 'utf8') + ).version as string; + const platform = platformFromContext(context); + const outPath = path.resolve(__dirname, 'hadron-build-info.json'); // build-info const infoArgs = { format: 'json', - // TODO - dir: '', - version: '', - platform: '', - arch: '', - out: '', + dir: compassDir, + version, + platform, + arch: context.arch, + out: outPath, }; + console.log('infoArgs', infoArgs); writeBuildInfo(infoArgs); // read the file @@ -118,6 +121,23 @@ async function run() { extension, }); + const downloadArgs = { + dir: compassDir, + version, + }; + console.log('downloadArgs', downloadArgs); + if (context.skipDownload) { + // TODO: check that all the files are there + } else { + // download + // TODO: one problem here is that right now it will download EVERY packaged + // app, so in effect it has to depend on every package task. + for (const filename of filenames) { + const url = `https://${context.bucketName}.s3.amazonaws.com/${context.bucketKeyPrefix}/${filename}`; + console.log(url); + } + } + // loop through the remaining filenames and install each then run the tests for (const filename of filenames) { console.log(filename); @@ -125,6 +145,24 @@ async function run() { } } +function platformFromContext( + context: SmokeTestsContext +): typeof process.platform { + if (context.isWindows) { + return 'win32'; + } + + if (context.isOSX) { + return 'darwin'; + } + + if (context.isRHEL || context.isUbuntu) { + return 'linux'; + } + + return process.platform; +} + type PackageFilterConfig = Pick< SmokeTestsContext, 'isWindows' | 'isOSX' | 'isRHEL' | 'isUbuntu' | 'extension' From 92bdb850034040bf14f371b5111c266ef2d73a98 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Tue, 17 Dec 2024 10:44:34 +0000 Subject: [PATCH 06/13] wip --- .evergreen/preinstall.sh | 5 ++++ packages/compass-e2e-tests/smoke-test.ts | 35 ++++++++++++++++++++---- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/.evergreen/preinstall.sh b/.evergreen/preinstall.sh index 3a8a0382227..3093b9063c0 100755 --- a/.evergreen/preinstall.sh +++ b/.evergreen/preinstall.sh @@ -12,6 +12,11 @@ echo "NPM_VERSION: $NPM_VERSION" echo "APPDATA: $APPDATA" echo "PATH: $PATH" +# these are super useful if you want to run the smoke tests locally +echo "DEV_VERSION_IDENTIFIER: $DEV_VERSION_IDENTIFIER" +echo "EVERGREEN_BUCKET_NAME: $EVERGREEN_BUCKET_NAME" +echo "EVERGREEN_BUCKET_KEY_PREFIX: $EVERGREEN_BUCKET_KEY_PREFIX" + echo "IS_OSX: $IS_OSX" echo "IS_LINUX: $IS_LINUX" echo "IS_WINDOWS: $IS_WINDOWS" diff --git a/packages/compass-e2e-tests/smoke-test.ts b/packages/compass-e2e-tests/smoke-test.ts index 2d6d38570f8..b784cae485f 100755 --- a/packages/compass-e2e-tests/smoke-test.ts +++ b/packages/compass-e2e-tests/smoke-test.ts @@ -1,5 +1,5 @@ #!/usr/bin/env npx ts-node -import yargs from 'yargs'; +import yargs, { boolean } from 'yargs'; import type { Argv } from 'yargs'; import { hideBin } from 'yargs/helpers'; import { promises as fs } from 'fs'; @@ -18,7 +18,7 @@ const argv = yargs(hideBin(process.argv)) // Dor dev versions we need this from evergreen. For beta or stable we get // it from the package.json if (process.env.DEV_VERSION_IDENTIFIER) { - argv.version = process.env.DEV_VERSION_IDENTIFIER; + argv.devVersion = process.env.DEV_VERSION_IDENTIFIER; } argv.isWindows = process.env.IS_WINDOWS === 'true'; @@ -33,6 +33,27 @@ const argv = yargs(hideBin(process.argv)) .detectLocale(false) .version(false) .strict() + .option('bucketName', { + type: 'string', + }) + .option('bucketKeyPrefix', { + type: 'string', + }) + .option('devVersion', { + type: 'string', + }) + .option('isWindows', { + type: 'boolean', + }) + .option('isOSX', { + type: 'boolean', + }) + .option('isRHEL', { + type: 'boolean', + }) + .option('isUbuntu', { + type: 'boolean', + }) .option('arch', { type: 'string', choices: ['x64', 'arm64'], @@ -88,10 +109,12 @@ async function run() { console.log('context', context); const compassDir = path.resolve(__dirname, '..', '..', 'packages', 'compass'); - // TODO: load version from either DEV_VERSION_IDENTIFIER if set or version in packages/compass/package.json - const version = JSON.parse( - await fs.readFile(path.join(compassDir, 'package.json'), 'utf8') - ).version as string; + // use the specified DEV_VERSION_IDENTIFIER if set or load version from packages/compass/package.json + const version = context.devVersion + ? context.devVersion + : (JSON.parse( + await fs.readFile(path.join(compassDir, 'package.json'), 'utf8') + ).version as string); const platform = platformFromContext(context); const outPath = path.resolve(__dirname, 'hadron-build-info.json'); From fcb5ad6dc7cafc4e9a7637cf6a5acc2e5a03ffc9 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Tue, 17 Dec 2024 13:20:55 +0000 Subject: [PATCH 07/13] initial smoketest task & entrypoint --- .evergreen/buildvariants-and-tasks.in.yml | 60 ++++++++ .evergreen/buildvariants-and-tasks.yml | 165 +++++++++++++++++++++ .evergreen/functions.yml | 25 ++++ packages/compass-e2e-tests/package.json | 3 +- packages/compass-e2e-tests/smoke-test.ts | 171 ++++++++++++++-------- 5 files changed, 360 insertions(+), 64 deletions(-) diff --git a/.evergreen/buildvariants-and-tasks.in.yml b/.evergreen/buildvariants-and-tasks.in.yml index e5113d00f49..d1a1fa60d78 100644 --- a/.evergreen/buildvariants-and-tasks.in.yml +++ b/.evergreen/buildvariants-and-tasks.in.yml @@ -60,6 +60,39 @@ const PACKAGE_BUILD_VARIANTS = [ } ]; +const SMOKETEST_BUILD_VARIANTS = [ + { + name: 'smoketest-ubuntu', + display_name: 'Smoketest Ubuntu', + run_on: 'ubuntu1804-large', + depends_on: 'package-ubuntu', + }, + { + name: 'smoketest-windows', + display_name: 'Smoketest Windows', + run_on: 'windows-vsCurrent-large', + depends_on: 'package-windows', + }, + { + name: 'smoketest-rhel', + display_name: 'Smoketest RHEL', + run_on: 'rhel80-large', + depends_on: 'package-rhel', + }, + { + name: 'smoketest-macos-x64', + display_name: 'Smoketest MacOS Intel', + run_on: 'macos-14', + depends_on: 'package-macos-x64', + }, + { + name: 'smoketest-macos-arm', + display_name: 'Smoketest MacOS Arm64', + run_on: 'macos-14-arm64', + depends_on: 'package-macos-arm', + } +]; + const TEST_PACKAGED_APP_BUILD_VARIANTS = [ { name: 'test-packaged-app-ubuntu', @@ -180,6 +213,19 @@ buildvariants: <% } %> <% } %> +<% for (const buildVariant of SMOKETEST_BUILD_VARIANTS) { %> +<% for (const distribution of COMPASS_DISTRIBUTIONS) { %> + - name: <%= buildVariant.name %>-<%= distribution %> + display_name: <%= buildVariant.display_name %> (<%= distribution %>) + run_on: <%= buildVariant.run_on %> + depends_on: + - name: package-<%= distribution %> + variant: <%= buildVariant.depends_on %> + tasks: + - name: smoketest-<%= distribution %> +<% } %> +<% } %> + - name: test-eol-servers display_name: Test EoL Servers run_on: ubuntu1804-large @@ -424,6 +470,20 @@ tasks: - func: save-all-artifacts vars: compass_distribution: <%= distribution %> + + - name: smoketest-<%= distribution %> + tags: ['required-for-publish', 'run-on-pr'] + commands: + - func: prepare + - func: install + - func: bootstrap + vars: + scope: '@mongodb-js/compass-e2e-tests' + - func: smoketest-packaged-app + vars: + mongodb_version: latest-enterprise + compass_distribution: <%= distribution %> + debug: 'compass-e2e-tests*,electron*,hadron*,mongo*' <% } %> <% for (const serverVersion of SERVER_VERSIONS) { %> diff --git a/.evergreen/buildvariants-and-tasks.yml b/.evergreen/buildvariants-and-tasks.yml index 48f1314bdc8..86e4c0db64c 100644 --- a/.evergreen/buildvariants-and-tasks.yml +++ b/.evergreen/buildvariants-and-tasks.yml @@ -76,6 +76,126 @@ buildvariants: - name: package-compass - name: package-compass-isolated - name: package-compass-readonly + - name: smoketest-ubuntu-compass + display_name: Smoketest Ubuntu (compass) + run_on: ubuntu1804-large + depends_on: + - name: package-compass + variant: package-ubuntu + tasks: + - name: smoketest-compass + - name: smoketest-ubuntu-compass-isolated + display_name: Smoketest Ubuntu (compass-isolated) + run_on: ubuntu1804-large + depends_on: + - name: package-compass-isolated + variant: package-ubuntu + tasks: + - name: smoketest-compass-isolated + - name: smoketest-ubuntu-compass-readonly + display_name: Smoketest Ubuntu (compass-readonly) + run_on: ubuntu1804-large + depends_on: + - name: package-compass-readonly + variant: package-ubuntu + tasks: + - name: smoketest-compass-readonly + - name: smoketest-windows-compass + display_name: Smoketest Windows (compass) + run_on: windows-vsCurrent-large + depends_on: + - name: package-compass + variant: package-windows + tasks: + - name: smoketest-compass + - name: smoketest-windows-compass-isolated + display_name: Smoketest Windows (compass-isolated) + run_on: windows-vsCurrent-large + depends_on: + - name: package-compass-isolated + variant: package-windows + tasks: + - name: smoketest-compass-isolated + - name: smoketest-windows-compass-readonly + display_name: Smoketest Windows (compass-readonly) + run_on: windows-vsCurrent-large + depends_on: + - name: package-compass-readonly + variant: package-windows + tasks: + - name: smoketest-compass-readonly + - name: smoketest-rhel-compass + display_name: Smoketest RHEL (compass) + run_on: rhel80-large + depends_on: + - name: package-compass + variant: package-rhel + tasks: + - name: smoketest-compass + - name: smoketest-rhel-compass-isolated + display_name: Smoketest RHEL (compass-isolated) + run_on: rhel80-large + depends_on: + - name: package-compass-isolated + variant: package-rhel + tasks: + - name: smoketest-compass-isolated + - name: smoketest-rhel-compass-readonly + display_name: Smoketest RHEL (compass-readonly) + run_on: rhel80-large + depends_on: + - name: package-compass-readonly + variant: package-rhel + tasks: + - name: smoketest-compass-readonly + - name: smoketest-macos-x64-compass + display_name: Smoketest MacOS Intel (compass) + run_on: macos-14 + depends_on: + - name: package-compass + variant: package-macos-x64 + tasks: + - name: smoketest-compass + - name: smoketest-macos-x64-compass-isolated + display_name: Smoketest MacOS Intel (compass-isolated) + run_on: macos-14 + depends_on: + - name: package-compass-isolated + variant: package-macos-x64 + tasks: + - name: smoketest-compass-isolated + - name: smoketest-macos-x64-compass-readonly + display_name: Smoketest MacOS Intel (compass-readonly) + run_on: macos-14 + depends_on: + - name: package-compass-readonly + variant: package-macos-x64 + tasks: + - name: smoketest-compass-readonly + - name: smoketest-macos-arm-compass + display_name: Smoketest MacOS Arm64 (compass) + run_on: macos-14-arm64 + depends_on: + - name: package-compass + variant: package-macos-arm + tasks: + - name: smoketest-compass + - name: smoketest-macos-arm-compass-isolated + display_name: Smoketest MacOS Arm64 (compass-isolated) + run_on: macos-14-arm64 + depends_on: + - name: package-compass-isolated + variant: package-macos-arm + tasks: + - name: smoketest-compass-isolated + - name: smoketest-macos-arm-compass-readonly + display_name: Smoketest MacOS Arm64 (compass-readonly) + run_on: macos-14-arm64 + depends_on: + - name: package-compass-readonly + variant: package-macos-arm + tasks: + - name: smoketest-compass-readonly - name: test-eol-servers display_name: Test EoL Servers run_on: ubuntu1804-large @@ -426,6 +546,21 @@ tasks: - func: save-all-artifacts vars: compass_distribution: compass + - name: smoketest-compass + tags: + - required-for-publish + - run-on-pr + commands: + - func: prepare + - func: install + - func: bootstrap + vars: + scope: '@mongodb-js/compass-e2e-tests' + - func: smoketest-packaged-app + vars: + mongodb_version: latest-enterprise + compass_distribution: compass + debug: compass-e2e-tests*,electron*,hadron*,mongo* - name: package-compass-isolated tags: - required-for-publish @@ -449,6 +584,21 @@ tasks: - func: save-all-artifacts vars: compass_distribution: compass-isolated + - name: smoketest-compass-isolated + tags: + - required-for-publish + - run-on-pr + commands: + - func: prepare + - func: install + - func: bootstrap + vars: + scope: '@mongodb-js/compass-e2e-tests' + - func: smoketest-packaged-app + vars: + mongodb_version: latest-enterprise + compass_distribution: compass-isolated + debug: compass-e2e-tests*,electron*,hadron*,mongo* - name: package-compass-readonly tags: - required-for-publish @@ -472,6 +622,21 @@ tasks: - func: save-all-artifacts vars: compass_distribution: compass-readonly + - name: smoketest-compass-readonly + tags: + - required-for-publish + - run-on-pr + commands: + - func: prepare + - func: install + - func: bootstrap + vars: + scope: '@mongodb-js/compass-e2e-tests' + - func: smoketest-packaged-app + vars: + mongodb_version: latest-enterprise + compass_distribution: compass-readonly + debug: compass-e2e-tests*,electron*,hadron*,mongo* - name: test-server-40x-community-1 tags: - required-for-publish diff --git a/.evergreen/functions.yml b/.evergreen/functions.yml index f0925ebba01..245309cfac5 100644 --- a/.evergreen/functions.yml +++ b/.evergreen/functions.yml @@ -651,6 +651,31 @@ functions: npm run --unsafe-perm --workspace compass-e2e-tests test-packaged-ci + smoketest-packaged-app: + - command: shell.exec + # Fail the task if it's idle for 10 mins + timeout_secs: 600 + params: + working_dir: src + shell: bash + env: + <<: *compass-env + DEBUG: ${debug|} + MONGODB_VERSION: ${mongodb_version|} + MONGODB_RUNNER_VERSION: ${mongodb_version|} + HADRON_DISTRIBUTION: ${compass_distribution} + script: | + set -e + # Load environment variables + eval $(.evergreen/print-compass-env.sh) + + if [[ "$IS_OSX" == "true" ]]; then + echo "Disabling clipboard usage in e2e tests (TODO: https://jira.mongodb.org/browse/BUILD-14780)" + export COMPASS_E2E_DISABLE_CLIPBOARD_USAGE="true" + fi + + npm run --workspace compass-e2e-tests smoketest + test-web-sandbox: - command: shell.exec # Fail the task if it's idle for 10 mins diff --git a/packages/compass-e2e-tests/package.json b/packages/compass-e2e-tests/package.json index e199daf062c..be26d7351c8 100644 --- a/packages/compass-e2e-tests/package.json +++ b/packages/compass-e2e-tests/package.json @@ -28,7 +28,8 @@ "test-web": "env DEBUG=hadron*,mongo*,compass*,xvfb-maybe* npm run test web", "test-web-noserver": "env DEBUG=hadron*,mongo*,compass*,xvfb-maybe* npm run test web -- --disable-start-stop --bail", "coverage-merge": "nyc merge .log/coverage .nyc_output/coverage.json", - "coverage-report": "npm run coverage-merge && nyc report" + "coverage-report": "npm run coverage-merge && nyc report", + "smoketest": "./smoke-test.ts" }, "devDependencies": { "@electron/rebuild": "^3.7.1", diff --git a/packages/compass-e2e-tests/smoke-test.ts b/packages/compass-e2e-tests/smoke-test.ts index b784cae485f..c05e3d408a7 100755 --- a/packages/compass-e2e-tests/smoke-test.ts +++ b/packages/compass-e2e-tests/smoke-test.ts @@ -1,67 +1,61 @@ #!/usr/bin/env npx ts-node -import yargs, { boolean } from 'yargs'; +import { createWriteStream, existsSync, promises as fs } from 'fs'; +import path from 'path'; +import yargs from 'yargs'; import type { Argv } from 'yargs'; import { hideBin } from 'yargs/helpers'; -import { promises as fs } from 'fs'; -import path from 'path'; +import https from 'https'; +import { pick } from 'lodash'; import { handler as writeBuildInfo } from 'hadron-build/commands/info'; const argv = yargs(hideBin(process.argv)) - .middleware((argv) => { - if (process.env.EVERGREEN_BUCKET_NAME) { - argv.bucketName = process.env.EVERGREEN_BUCKET_NAME; - } - if (process.env.EVERGREEN_BUCKET_KEY_PREFIX) { - argv.bucketKeyPrefix = process.env.EVERGREEN_BUCKET_KEY_PREFIX; - } - - // Dor dev versions we need this from evergreen. For beta or stable we get - // it from the package.json - if (process.env.DEV_VERSION_IDENTIFIER) { - argv.devVersion = process.env.DEV_VERSION_IDENTIFIER; - } - - argv.isWindows = process.env.IS_WINDOWS === 'true'; - argv.isOSX = process.env.IS_OSX === 'true'; - argv.isRHEL = process.env.IS_RHEL === 'true'; - argv.isUbuntu = process.env.IS_UBUNTU === 'true'; - if (process.arch) { - argv.arch = process.env.ARCH; - } - }) .scriptName('smoke-tests') .detectLocale(false) .version(false) .strict() .option('bucketName', { type: 'string', + default: () => process.env.EVERGREEN_BUCKET_NAME, }) .option('bucketKeyPrefix', { type: 'string', + default: () => process.env.EVERGREEN_BUCKET_KEY_PREFIX, }) .option('devVersion', { type: 'string', + // For dev versions we need this from evergreen. For beta or stable (or by + // default, ie. when testing a locally packaged app) we get it from the + // package.json + default: () => process.env.DEV_VERSION_IDENTIFIER, }) .option('isWindows', { type: 'boolean', + default: () => process.env.IS_WINDOWS === 'true', }) .option('isOSX', { type: 'boolean', + default: () => process.env.IS_OSX === 'true', }) .option('isRHEL', { type: 'boolean', + default: () => process.env.IS_RHEL === 'true', }) .option('isUbuntu', { type: 'boolean', + default: () => process.env.IS_UBUNTU === 'true', }) .option('arch', { type: 'string', choices: ['x64', 'arm64'], + demandOption: true, default: () => { - process.arch; + if (process.env.ARCH) { + return process.env.ARCH; + } + return process.arch; }, }) - .option('skip-download', { + .option('skipDownload', { type: 'boolean', description: "Don't download all assets before starting", }) @@ -85,10 +79,6 @@ const argv = yargs(hideBin(process.argv)) ); } - if (!argv.arch) { - throw new Error('Please provice ARCH (x64 or arm64)'); - } - return true; }); @@ -106,7 +96,21 @@ async function run() { const context = parsedArgs as SmokeTestsContext; - console.log('context', context); + console.log( + 'context', + pick(context, [ + 'skipDownload', + 'bucketName', + 'bucketKeyPrefix', + 'devVersion', + 'isWindows', + 'isOSX', + 'isRHEL', + 'isUbuntu', + 'arch', + 'extension', + ]) + ); const compassDir = path.resolve(__dirname, '..', '..', 'packages', 'compass'); // use the specified DEV_VERSION_IDENTIFIER if set or load version from packages/compass/package.json @@ -129,14 +133,12 @@ async function run() { }; console.log('infoArgs', infoArgs); writeBuildInfo(infoArgs); - - // read the file const buildInfo = JSON.parse(await fs.readFile(infoArgs.out, 'utf8')); // filter the extensions given the platform (isWindows, isOSX, isUbuntu, isRHEL) and extension const { isWindows, isOSX, isRHEL, isUbuntu, extension } = context; - const filenames = filterPackages(buildInfo, { + const packages = getFilteredPackages(compassDir, buildInfo, { isWindows, isOSX, isRHEL, @@ -144,28 +146,21 @@ async function run() { extension, }); - const downloadArgs = { - dir: compassDir, - version, - }; - console.log('downloadArgs', downloadArgs); if (context.skipDownload) { - // TODO: check that all the files are there + verifyPackagesExist(packages); } else { - // download - // TODO: one problem here is that right now it will download EVERY packaged - // app, so in effect it has to depend on every package task. - for (const filename of filenames) { - const url = `https://${context.bucketName}.s3.amazonaws.com/${context.bucketKeyPrefix}/${filename}`; - console.log(url); - } + await Promise.all( + packages.map(async ({ name, filepath }) => { + await fs.mkdir(path.dirname(filepath), { recursive: true }); + const url = `https://${context.bucketName}.s3.amazonaws.com/${context.bucketKeyPrefix}/${name}`; + console.log(url); + return downloadFile(url, filepath); + }) + ); + verifyPackagesExist(packages); } - // loop through the remaining filenames and install each then run the tests - for (const filename of filenames) { - console.log(filename); - // TODO(COMPASS-8533): extract or install filename and then test the Compass binary - } + // TODO(COMPASS-8533): extract or install each package and then test the Compass binary } function platformFromContext( @@ -249,38 +244,88 @@ function buildInfoIsRHEL(buildInfo: any): buildInfo is RHELBuildInfo { return true; } -function filterPackages(buildInfo: any, config: PackageFilterConfig) { - let filenames: string[] = []; +type Package = { + name: string; + filepath: string; +}; + +function getFilteredPackages( + compassDir: string, + buildInfo: any, + config: PackageFilterConfig +): Package[] { + let names: string[] = []; if (config.isWindows) { if (!buildInfoIsWindows(buildInfo)) { throw new Error('missing windows package keys'); } - filenames = windowsFilenameKeys.map((key) => buildInfo[key]); + names = windowsFilenameKeys.map((key) => buildInfo[key]); } else if (config.isOSX) { if (!buildInfoIsOSX(buildInfo)) { throw new Error('missing osx package keys'); } - filenames = osxFilenameKeys.map((key) => buildInfo[key]); + names = osxFilenameKeys.map((key) => buildInfo[key]); } else if (config.isRHEL) { if (!buildInfoIsRHEL(buildInfo)) { throw new Error('missing rhel package keys'); } - filenames = rhelFilenameKeys.map((key) => buildInfo[key]); + names = rhelFilenameKeys.map((key) => buildInfo[key]); } else if (config.isUbuntu) { if (!buildInfoIsUbuntu(buildInfo)) { throw new Error('missing ubuntu package keys'); } - filenames = ubuntuFilenameKeys.map((key) => buildInfo[key]); + names = ubuntuFilenameKeys.map((key) => buildInfo[key]); } const extension = config.extension; - if (extension !== undefined) { - return filenames.filter((filename) => filename.endsWith(extension)); - } + return names + .filter((name) => !extension || name.endsWith(extension)) + .map((name) => { + return { + name, + filepath: path.join(compassDir, 'dist', name), + }; + }); +} - return filenames; +async function downloadFile(url: string, targetFile: string): Promise { + return await new Promise((resolve, reject) => { + https + .get(url, (response) => { + const code = response.statusCode ?? 0; + + if (code >= 400) { + return reject(new Error(response.statusMessage)); + } + + // handle redirects + if (code > 300 && code < 400 && !!response.headers.location) { + return resolve(downloadFile(response.headers.location, targetFile)); + } + + // save the file to disk + const fileWriter = createWriteStream(targetFile).on('finish', () => { + resolve(); + }); + + response.pipe(fileWriter); + }) + .on('error', (error: any) => { + reject(error); + }); + }); +} + +function verifyPackagesExist(packages: Package[]): void { + for (const { filepath } of packages) { + if (!existsSync(filepath)) { + throw new Error( + `${filepath} does not exist. Did you forget to download or package?` + ); + } + } } run() From c8f0a6b3869fba35ab8ad80e2f3095e2eab09224 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Tue, 17 Dec 2024 13:23:23 +0000 Subject: [PATCH 08/13] limit to just ubuntu and just the compass distribution for now --- .evergreen/buildvariants-and-tasks.in.yml | 55 ++++---- .evergreen/buildvariants-and-tasks.yml | 148 +--------------------- 2 files changed, 32 insertions(+), 171 deletions(-) diff --git a/.evergreen/buildvariants-and-tasks.in.yml b/.evergreen/buildvariants-and-tasks.in.yml index d1a1fa60d78..bdedc59a7fb 100644 --- a/.evergreen/buildvariants-and-tasks.in.yml +++ b/.evergreen/buildvariants-and-tasks.in.yml @@ -64,33 +64,34 @@ const SMOKETEST_BUILD_VARIANTS = [ { name: 'smoketest-ubuntu', display_name: 'Smoketest Ubuntu', - run_on: 'ubuntu1804-large', + run_on: 'ubuntu2004-large', depends_on: 'package-ubuntu', }, - { - name: 'smoketest-windows', - display_name: 'Smoketest Windows', - run_on: 'windows-vsCurrent-large', - depends_on: 'package-windows', - }, - { - name: 'smoketest-rhel', - display_name: 'Smoketest RHEL', - run_on: 'rhel80-large', - depends_on: 'package-rhel', - }, - { - name: 'smoketest-macos-x64', - display_name: 'Smoketest MacOS Intel', - run_on: 'macos-14', - depends_on: 'package-macos-x64', - }, - { - name: 'smoketest-macos-arm', - display_name: 'Smoketest MacOS Arm64', - run_on: 'macos-14-arm64', - depends_on: 'package-macos-arm', - } + +// { +// name: 'smoketest-windows', +// display_name: 'Smoketest Windows', +// run_on: 'windows-vsCurrent-large', +// depends_on: 'package-windows', +// }, +// { +// name: 'smoketest-rhel', +// display_name: 'Smoketest RHEL', +// run_on: 'rhel80-large', +// depends_on: 'package-rhel', +// }, +// { +// name: 'smoketest-macos-x64', +// display_name: 'Smoketest MacOS Intel', +// run_on: 'macos-14', +// depends_on: 'package-macos-x64', +// }, +// { +// name: 'smoketest-macos-arm', +// display_name: 'Smoketest MacOS Arm64', +// run_on: 'macos-14-arm64', +// depends_on: 'package-macos-arm', +// } ]; const TEST_PACKAGED_APP_BUILD_VARIANTS = [ @@ -214,7 +215,7 @@ buildvariants: <% } %> <% for (const buildVariant of SMOKETEST_BUILD_VARIANTS) { %> -<% for (const distribution of COMPASS_DISTRIBUTIONS) { %> +<% for (const distribution of ['compass']) { %> - name: <%= buildVariant.name %>-<%= distribution %> display_name: <%= buildVariant.display_name %> (<%= distribution %>) run_on: <%= buildVariant.run_on %> @@ -470,7 +471,9 @@ tasks: - func: save-all-artifacts vars: compass_distribution: <%= distribution %> + <% } %> +<% for (const distribution of ['compass']) { %> - name: smoketest-<%= distribution %> tags: ['required-for-publish', 'run-on-pr'] commands: diff --git a/.evergreen/buildvariants-and-tasks.yml b/.evergreen/buildvariants-and-tasks.yml index 86e4c0db64c..90bcbd87985 100644 --- a/.evergreen/buildvariants-and-tasks.yml +++ b/.evergreen/buildvariants-and-tasks.yml @@ -78,124 +78,12 @@ buildvariants: - name: package-compass-readonly - name: smoketest-ubuntu-compass display_name: Smoketest Ubuntu (compass) - run_on: ubuntu1804-large + run_on: ubuntu2004-large depends_on: - name: package-compass variant: package-ubuntu tasks: - name: smoketest-compass - - name: smoketest-ubuntu-compass-isolated - display_name: Smoketest Ubuntu (compass-isolated) - run_on: ubuntu1804-large - depends_on: - - name: package-compass-isolated - variant: package-ubuntu - tasks: - - name: smoketest-compass-isolated - - name: smoketest-ubuntu-compass-readonly - display_name: Smoketest Ubuntu (compass-readonly) - run_on: ubuntu1804-large - depends_on: - - name: package-compass-readonly - variant: package-ubuntu - tasks: - - name: smoketest-compass-readonly - - name: smoketest-windows-compass - display_name: Smoketest Windows (compass) - run_on: windows-vsCurrent-large - depends_on: - - name: package-compass - variant: package-windows - tasks: - - name: smoketest-compass - - name: smoketest-windows-compass-isolated - display_name: Smoketest Windows (compass-isolated) - run_on: windows-vsCurrent-large - depends_on: - - name: package-compass-isolated - variant: package-windows - tasks: - - name: smoketest-compass-isolated - - name: smoketest-windows-compass-readonly - display_name: Smoketest Windows (compass-readonly) - run_on: windows-vsCurrent-large - depends_on: - - name: package-compass-readonly - variant: package-windows - tasks: - - name: smoketest-compass-readonly - - name: smoketest-rhel-compass - display_name: Smoketest RHEL (compass) - run_on: rhel80-large - depends_on: - - name: package-compass - variant: package-rhel - tasks: - - name: smoketest-compass - - name: smoketest-rhel-compass-isolated - display_name: Smoketest RHEL (compass-isolated) - run_on: rhel80-large - depends_on: - - name: package-compass-isolated - variant: package-rhel - tasks: - - name: smoketest-compass-isolated - - name: smoketest-rhel-compass-readonly - display_name: Smoketest RHEL (compass-readonly) - run_on: rhel80-large - depends_on: - - name: package-compass-readonly - variant: package-rhel - tasks: - - name: smoketest-compass-readonly - - name: smoketest-macos-x64-compass - display_name: Smoketest MacOS Intel (compass) - run_on: macos-14 - depends_on: - - name: package-compass - variant: package-macos-x64 - tasks: - - name: smoketest-compass - - name: smoketest-macos-x64-compass-isolated - display_name: Smoketest MacOS Intel (compass-isolated) - run_on: macos-14 - depends_on: - - name: package-compass-isolated - variant: package-macos-x64 - tasks: - - name: smoketest-compass-isolated - - name: smoketest-macos-x64-compass-readonly - display_name: Smoketest MacOS Intel (compass-readonly) - run_on: macos-14 - depends_on: - - name: package-compass-readonly - variant: package-macos-x64 - tasks: - - name: smoketest-compass-readonly - - name: smoketest-macos-arm-compass - display_name: Smoketest MacOS Arm64 (compass) - run_on: macos-14-arm64 - depends_on: - - name: package-compass - variant: package-macos-arm - tasks: - - name: smoketest-compass - - name: smoketest-macos-arm-compass-isolated - display_name: Smoketest MacOS Arm64 (compass-isolated) - run_on: macos-14-arm64 - depends_on: - - name: package-compass-isolated - variant: package-macos-arm - tasks: - - name: smoketest-compass-isolated - - name: smoketest-macos-arm-compass-readonly - display_name: Smoketest MacOS Arm64 (compass-readonly) - run_on: macos-14-arm64 - depends_on: - - name: package-compass-readonly - variant: package-macos-arm - tasks: - - name: smoketest-compass-readonly - name: test-eol-servers display_name: Test EoL Servers run_on: ubuntu1804-large @@ -546,21 +434,6 @@ tasks: - func: save-all-artifacts vars: compass_distribution: compass - - name: smoketest-compass - tags: - - required-for-publish - - run-on-pr - commands: - - func: prepare - - func: install - - func: bootstrap - vars: - scope: '@mongodb-js/compass-e2e-tests' - - func: smoketest-packaged-app - vars: - mongodb_version: latest-enterprise - compass_distribution: compass - debug: compass-e2e-tests*,electron*,hadron*,mongo* - name: package-compass-isolated tags: - required-for-publish @@ -584,21 +457,6 @@ tasks: - func: save-all-artifacts vars: compass_distribution: compass-isolated - - name: smoketest-compass-isolated - tags: - - required-for-publish - - run-on-pr - commands: - - func: prepare - - func: install - - func: bootstrap - vars: - scope: '@mongodb-js/compass-e2e-tests' - - func: smoketest-packaged-app - vars: - mongodb_version: latest-enterprise - compass_distribution: compass-isolated - debug: compass-e2e-tests*,electron*,hadron*,mongo* - name: package-compass-readonly tags: - required-for-publish @@ -622,7 +480,7 @@ tasks: - func: save-all-artifacts vars: compass_distribution: compass-readonly - - name: smoketest-compass-readonly + - name: smoketest-compass tags: - required-for-publish - run-on-pr @@ -635,7 +493,7 @@ tasks: - func: smoketest-packaged-app vars: mongodb_version: latest-enterprise - compass_distribution: compass-readonly + compass_distribution: compass debug: compass-e2e-tests*,electron*,hadron*,mongo* - name: test-server-40x-community-1 tags: From 24b4665c802177f8ab00633b0f7a58d91df780a3 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Tue, 17 Dec 2024 14:19:17 +0000 Subject: [PATCH 09/13] correct package --- .evergreen/buildvariants-and-tasks.in.yml | 2 +- .evergreen/buildvariants-and-tasks.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.evergreen/buildvariants-and-tasks.in.yml b/.evergreen/buildvariants-and-tasks.in.yml index bdedc59a7fb..ddc112525cf 100644 --- a/.evergreen/buildvariants-and-tasks.in.yml +++ b/.evergreen/buildvariants-and-tasks.in.yml @@ -481,7 +481,7 @@ tasks: - func: install - func: bootstrap vars: - scope: '@mongodb-js/compass-e2e-tests' + scope: 'compass-e2e-tests' - func: smoketest-packaged-app vars: mongodb_version: latest-enterprise diff --git a/.evergreen/buildvariants-and-tasks.yml b/.evergreen/buildvariants-and-tasks.yml index 90bcbd87985..80ca75e0a98 100644 --- a/.evergreen/buildvariants-and-tasks.yml +++ b/.evergreen/buildvariants-and-tasks.yml @@ -489,7 +489,7 @@ tasks: - func: install - func: bootstrap vars: - scope: '@mongodb-js/compass-e2e-tests' + scope: compass-e2e-tests - func: smoketest-packaged-app vars: mongodb_version: latest-enterprise From a712bfc1d33c483f4d63c115308bec8f26e45ba6 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Tue, 17 Dec 2024 15:19:30 +0000 Subject: [PATCH 10/13] fine. no shebang --- packages/compass-e2e-tests/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/compass-e2e-tests/package.json b/packages/compass-e2e-tests/package.json index be26d7351c8..e7539381f24 100644 --- a/packages/compass-e2e-tests/package.json +++ b/packages/compass-e2e-tests/package.json @@ -29,7 +29,7 @@ "test-web-noserver": "env DEBUG=hadron*,mongo*,compass*,xvfb-maybe* npm run test web -- --disable-start-stop --bail", "coverage-merge": "nyc merge .log/coverage .nyc_output/coverage.json", "coverage-report": "npm run coverage-merge && nyc report", - "smoketest": "./smoke-test.ts" + "smoketest": "ts-node smoke-test.ts" }, "devDependencies": { "@electron/rebuild": "^3.7.1", From 2badcfd8db1c91c0469ea7e0c35292c95180690b Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Wed, 18 Dec 2024 12:36:41 +0000 Subject: [PATCH 11/13] xor the IS_* platform options --- packages/compass-e2e-tests/smoke-test.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/compass-e2e-tests/smoke-test.ts b/packages/compass-e2e-tests/smoke-test.ts index c05e3d408a7..7b0ed1dbdf9 100755 --- a/packages/compass-e2e-tests/smoke-test.ts +++ b/packages/compass-e2e-tests/smoke-test.ts @@ -48,12 +48,7 @@ const argv = yargs(hideBin(process.argv)) type: 'string', choices: ['x64', 'arm64'], demandOption: true, - default: () => { - if (process.env.ARCH) { - return process.env.ARCH; - } - return process.arch; - }, + default: () => process.env.ARCH ?? process.arch, }) .option('skipDownload', { type: 'boolean', @@ -73,9 +68,16 @@ const argv = yargs(hideBin(process.argv)) } } - if (!(argv.isWindows || argv.isOSX || argv.isUbuntu || argv.isRHEL)) { + // hadron-build info can only do one platform & arch at a time + const platformsCount = [ + argv.isWindows, + argv.isOSX, + argv.isUbuntu, + argv.isRHEL, + ].filter((x) => x).length; + if (platformsCount !== 1) { throw new Error( - 'Set at least one of IS_WINDOWS, IS_OSX, IS_UBUNTU, IS_RHEL' + 'Set exactly one of IS_WINDOWS, IS_OSX, IS_UBUNTU, IS_RHEL to true' ); } From 17f41526d64608dc12b81cf7b5376e596bc34bb9 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Wed, 18 Dec 2024 12:38:22 +0000 Subject: [PATCH 12/13] verify once --- packages/compass-e2e-tests/smoke-test.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/compass-e2e-tests/smoke-test.ts b/packages/compass-e2e-tests/smoke-test.ts index 7b0ed1dbdf9..2057e87c175 100755 --- a/packages/compass-e2e-tests/smoke-test.ts +++ b/packages/compass-e2e-tests/smoke-test.ts @@ -148,9 +148,7 @@ async function run() { extension, }); - if (context.skipDownload) { - verifyPackagesExist(packages); - } else { + if (!context.skipDownload) { await Promise.all( packages.map(async ({ name, filepath }) => { await fs.mkdir(path.dirname(filepath), { recursive: true }); @@ -159,9 +157,10 @@ async function run() { return downloadFile(url, filepath); }) ); - verifyPackagesExist(packages); } + verifyPackagesExist(packages); + // TODO(COMPASS-8533): extract or install each package and then test the Compass binary } From 47e2816dc3fb05742af3ecbacdf3655260e25b54 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Wed, 18 Dec 2024 12:42:17 +0000 Subject: [PATCH 13/13] add error callback --- packages/compass-e2e-tests/smoke-test.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/compass-e2e-tests/smoke-test.ts b/packages/compass-e2e-tests/smoke-test.ts index 2057e87c175..67a9cd2de64 100755 --- a/packages/compass-e2e-tests/smoke-test.ts +++ b/packages/compass-e2e-tests/smoke-test.ts @@ -307,9 +307,13 @@ async function downloadFile(url: string, targetFile: string): Promise { } // save the file to disk - const fileWriter = createWriteStream(targetFile).on('finish', () => { - resolve(); - }); + const fileWriter = createWriteStream(targetFile) + .on('finish', () => { + resolve(); + }) + .on('error', (error: any) => { + reject(error); + }); response.pipe(fileWriter); })