Skip to content

Commit d9ed946

Browse files
authored
feat(smoke-tests): test zip installer for on Windows COMPASS-8710 (#6637)
* Derive a target specific app name * Implement Windows ZIP installer * Enable shell when running tests * Arm the CI to execute the tests * Add Windows variant
1 parent 67fe59b commit d9ed946

File tree

6 files changed

+95
-17
lines changed

6 files changed

+95
-17
lines changed

.evergreen/buildvariants-and-tasks.in.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,12 @@ const SMOKETEST_BUILD_VARIANTS = [
6767
// run_on: 'ubuntu2004-large',
6868
// depends_on: 'package-ubuntu',
6969
// },
70-
71-
// {
72-
// name: 'smoketest-windows',
73-
// display_name: 'Smoketest Windows',
74-
// run_on: 'windows-vsCurrent-large',
75-
// depends_on: 'package-windows',
76-
// },
70+
{
71+
name: 'smoketest-windows',
72+
display_name: 'Smoketest Windows',
73+
run_on: 'windows-vsCurrent-large',
74+
depends_on: 'package-windows',
75+
},
7776
// {
7877
// name: 'smoketest-rhel',
7978
// display_name: 'Smoketest RHEL',

.evergreen/buildvariants-and-tasks.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ buildvariants:
7676
- name: package-compass
7777
- name: package-compass-isolated
7878
- name: package-compass-readonly
79+
- name: smoketest-windows-compass
80+
display_name: Smoketest Windows (compass)
81+
run_on: windows-vsCurrent-large
82+
depends_on:
83+
- name: package-compass
84+
variant: package-windows
85+
tasks:
86+
- name: smoketest-compass
7987
- name: smoketest-macos-x64-compass
8088
display_name: Smoketest MacOS Intel (compass)
8189
run_on: macos-14-gui

.evergreen/functions.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,17 +678,17 @@ functions:
678678
# Load environment variables
679679
eval $(.evergreen/print-compass-env.sh)
680680
681-
#if [[ "$IS_WINDOWS" == "true" ]]; then
681+
if [[ "$IS_WINDOWS" == "true" ]]; then
682682
# TODO: windows_setup
683683
# TODO: windows_msi
684-
# TODO: windows_zip
685-
#fi
684+
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=windows_zip
685+
fi
686686
687687
if [[ "$IS_OSX" == "true" ]]; then
688688
echo "Disabling clipboard usage in e2e tests (TODO: https://jira.mongodb.org/browse/BUILD-14780)"
689689
export COMPASS_E2E_DISABLE_CLIPBOARD_USAGE="true"
690690
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=osx_dmg
691-
# TODO: osx_zip
691+
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=osx_zip
692692
fi
693693
694694
#if [[ "$IS_UBUNTU" == "true" ]]; then

packages/compass-smoke-tests/src/build-info.ts

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,65 @@ export const windowsFilenameKeys = [
4141
'windows_nupkg_full_filename',
4242
] as const;
4343
export type WindowsBuildInfo = CommonBuildInfo &
44-
Record<typeof windowsFilenameKeys[number], string>;
44+
Record<typeof windowsFilenameKeys[number], string> & {
45+
installerOptions: {
46+
name: string;
47+
};
48+
};
4549

4650
export function assertBuildInfoIsWindows(
4751
buildInfo: unknown
4852
): asserts buildInfo is WindowsBuildInfo {
4953
assertObjectHasKeys(buildInfo, 'buildInfo', commonKeys);
5054
assertObjectHasKeys(buildInfo, 'buildInfo', windowsFilenameKeys);
55+
assert(typeof buildInfo === 'object', 'Expected buildInfo to be an object');
56+
assert(buildInfo !== null, 'Expected buildInfo to be an object');
57+
assert(
58+
'installerOptions' in buildInfo &&
59+
typeof buildInfo.installerOptions === 'object',
60+
'Expected buildInfo.installerOptions to be an object'
61+
);
62+
const { installerOptions } = buildInfo;
63+
assert(
64+
typeof installerOptions === 'object' &&
65+
installerOptions !== null &&
66+
'name' in installerOptions &&
67+
typeof installerOptions.name === 'string',
68+
'Expected buildInfo.installerOptions.name to be a string'
69+
);
5170
}
5271

5372
export const osxFilenameKeys = [
5473
'osx_dmg_filename',
5574
'osx_zip_filename',
5675
] as const;
5776
export type OSXBuildInfo = CommonBuildInfo &
58-
Record<typeof osxFilenameKeys[number], string>;
77+
Record<typeof osxFilenameKeys[number], string> & {
78+
installerOptions: {
79+
title: string;
80+
};
81+
};
5982

6083
export function assertBuildInfoIsOSX(
6184
buildInfo: unknown
6285
): asserts buildInfo is OSXBuildInfo {
6386
assertObjectHasKeys(buildInfo, 'buildInfo', commonKeys);
6487
assertObjectHasKeys(buildInfo, 'buildInfo', osxFilenameKeys);
88+
assert(typeof buildInfo === 'object', 'Expected buildInfo to be an object');
89+
assert(buildInfo !== null, 'Expected buildInfo to be an object');
90+
assert(
91+
'installerOptions' in buildInfo &&
92+
typeof buildInfo.installerOptions === 'object',
93+
'Expected buildInfo.installerOptions to be an object'
94+
);
95+
const { installerOptions } = buildInfo;
96+
assert(
97+
typeof installerOptions === 'object' &&
98+
installerOptions !== null &&
99+
'title' in installerOptions &&
100+
typeof installerOptions.title === 'string',
101+
'Expected buildInfo.installerOptions.title to be a string'
102+
);
65103
}
66104

67105
export const ubuntuFilenameKeys = [
@@ -93,6 +131,7 @@ export type PackageDetails = {
93131
kind: PackageKind;
94132
filename: string;
95133
autoUpdatable: boolean;
134+
appName: string;
96135
} & (
97136
| {
98137
kind: 'windows_setup' | 'windows_msi' | 'windows_zip';
@@ -129,6 +168,7 @@ export function getPackageDetails(
129168
kind,
130169
buildInfo,
131170
filename: buildInfo[`${kind}_filename`],
171+
appName: buildInfo.installerOptions.name,
132172
autoUpdatable: kind === 'windows_setup',
133173
};
134174
} else if (kind === 'osx_dmg' || kind === 'osx_zip') {
@@ -137,6 +177,7 @@ export function getPackageDetails(
137177
kind,
138178
buildInfo,
139179
filename: buildInfo[`${kind}_filename`],
180+
appName: buildInfo.installerOptions.title,
140181
autoUpdatable: true,
141182
};
142183
} else if (kind === 'linux_deb' || kind === 'linux_tar') {
@@ -145,6 +186,7 @@ export function getPackageDetails(
145186
kind,
146187
buildInfo,
147188
filename: buildInfo[`${kind}_filename`],
189+
appName: buildInfo.productName,
148190
autoUpdatable: false,
149191
};
150192
} else if (kind === 'linux_rpm' || kind === 'rhel_tar') {
@@ -153,6 +195,7 @@ export function getPackageDetails(
153195
kind,
154196
buildInfo,
155197
filename: buildInfo[`${kind}_filename`],
198+
appName: buildInfo.productName,
156199
autoUpdatable: false,
157200
};
158201
} else {

packages/compass-smoke-tests/src/cli.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import path from 'node:path';
66
import yargs from 'yargs';
77
import { hideBin } from 'yargs/helpers';
88
import { pick } from 'lodash';
9-
import { installMacDMG } from './installers/mac-dmg';
109
import { execute } from './execute';
1110
import {
1211
type PackageDetails,
@@ -17,7 +16,10 @@ import { createSandbox } from './directories';
1716
import { downloadFile } from './downloads';
1817
import { type PackageKind, SUPPORTED_PACKAGES } from './packages';
1918
import { type SmokeTestsContext } from './context';
19+
20+
import { installMacDMG } from './installers/mac-dmg';
2021
import { installMacZIP } from './installers/mac-zip';
22+
import { installWindowsZIP } from './installers/windows-zip';
2123

2224
const SUPPORTED_PLATFORMS = ['win32', 'darwin', 'linux'] as const;
2325
const SUPPORTED_ARCHS = ['x64', 'arm64'] as const;
@@ -150,6 +152,8 @@ function getInstaller(kind: PackageKind) {
150152
return installMacDMG;
151153
} else if (kind === 'osx_zip') {
152154
return installMacZIP;
155+
} else if (kind === 'windows_zip') {
156+
return installWindowsZIP;
153157
} else {
154158
throw new Error(`Installer for '${kind}' is not yet implemented`);
155159
}
@@ -175,12 +179,10 @@ async function run() {
175179
])
176180
);
177181

178-
const { kind, buildInfo, filepath } = await getTestSubject(context);
182+
const { kind, filepath, appName } = await getTestSubject(context);
179183
const install = getInstaller(kind);
180184

181185
try {
182-
const appName = buildInfo.productName;
183-
184186
const { appPath, uninstall } = install({
185187
appName,
186188
filepath,
@@ -216,6 +218,8 @@ function runTest({ appName, appPath }: RunTestOptions) {
216218
'--test-filter=time-to-first-query',
217219
],
218220
{
221+
// We need to use a shell to get environment variables setup correctly
222+
shell: true,
219223
env: {
220224
...process.env,
221225
COMPASS_APP_NAME: appName,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import path from 'node:path';
2+
3+
import type { InstalledAppInfo, InstallablePackage } from './types';
4+
import { execute } from '../execute';
5+
6+
export function installWindowsZIP({
7+
appName,
8+
filepath,
9+
destinationPath,
10+
}: InstallablePackage): InstalledAppInfo {
11+
const appPath = path.resolve(destinationPath, `${appName}.exe`);
12+
13+
execute('unzip', [filepath, '-d', destinationPath]);
14+
15+
// see if the executable will run without being quarantined or similar
16+
execute(appPath, ['--version']);
17+
18+
return {
19+
appPath: destinationPath,
20+
uninstall: async function () {
21+
/* TODO */
22+
},
23+
};
24+
}

0 commit comments

Comments
 (0)