Skip to content

Commit c6af6bf

Browse files
lerouxbkraenhansen
andauthored
chore(e2e): refactor smoke-test.ts structure COMPASS-8795 (#6602)
* refactor smoke-test.ts structure * might help if I use bash comments in a bash script * more uncommenting * Update packages/compass-e2e-tests/installers/mac-dmg.ts Co-authored-by: Kræn Hansen <[email protected]> * Update packages/compass-e2e-tests/helpers/buildinfo.ts Co-authored-by: Kræn Hansen <[email protected]> * Update packages/compass-e2e-tests/helpers/buildinfo.ts Co-authored-by: Kræn Hansen <[email protected]> * Update packages/compass-e2e-tests/helpers/buildinfo.ts Co-authored-by: Kræn Hansen <[email protected]> * Update packages/compass-e2e-tests/helpers/buildinfo.ts Co-authored-by: Kræn Hansen <[email protected]> * Update packages/compass-e2e-tests/helpers/buildinfo.ts Co-authored-by: Kræn Hansen <[email protected]> * prettier --------- Co-authored-by: Kræn Hansen <[email protected]>
1 parent 307e22f commit c6af6bf

File tree

7 files changed

+263
-253
lines changed

7 files changed

+263
-253
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ const PACKAGE_BUILD_VARIANTS = [
6161
];
6262
6363
const SMOKETEST_BUILD_VARIANTS = [
64-
{
65-
name: 'smoketest-ubuntu',
66-
display_name: 'Smoketest Ubuntu',
67-
run_on: 'ubuntu2004-large',
68-
depends_on: 'package-ubuntu',
69-
},
64+
// {
65+
// name: 'smoketest-ubuntu',
66+
// display_name: 'Smoketest Ubuntu',
67+
// run_on: 'ubuntu2004-large',
68+
// depends_on: 'package-ubuntu',
69+
// },
7070
7171
// {
7272
// name: 'smoketest-windows',

.evergreen/buildvariants-and-tasks.yml

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

.evergreen/functions.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,12 +669,29 @@ functions:
669669
# Load environment variables
670670
eval $(.evergreen/print-compass-env.sh)
671671
672+
#if [[ "$IS_WINDOWS" == "true" ]]; then
673+
# TODO: windows_setup
674+
# TODO: windows_msi
675+
# TODO: windows_zip
676+
#fi
677+
672678
if [[ "$IS_OSX" == "true" ]]; then
673679
echo "Disabling clipboard usage in e2e tests (TODO: https://jira.mongodb.org/browse/BUILD-14780)"
674680
export COMPASS_E2E_DISABLE_CLIPBOARD_USAGE="true"
681+
npm run --unsafe-perm --workspace compass-e2e-tests smoketest -- --package=osx_dmg
682+
# TODO: osx_zip
675683
fi
676684
677-
npm run --unsafe-perm --workspace compass-e2e-tests smoketest
685+
#if [[ "$IS_UBUNTU" == "true" ]]; then
686+
# TODO: linux_deb
687+
# TODO: linux_tar
688+
#fi
689+
690+
#if [[ "$IS_RHEL" == "true" ]]; then
691+
# TODO: linux_rpm
692+
# TODO: rhel_tar
693+
#fi
694+
678695
679696
test-web-sandbox:
680697
- command: shell.exec
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import assert from 'node:assert/strict';
2+
3+
// subsets of the hadron-build info result
4+
5+
const commonKeys = ['productName'];
6+
type CommonBuildInfo = Record<typeof commonKeys[number], string>;
7+
8+
function assertObjectHasKeys(
9+
obj: unknown,
10+
name: string,
11+
keys: readonly string[]
12+
) {
13+
assert(
14+
typeof obj === 'object' && obj !== null,
15+
'Expected buildInfo to be an object'
16+
);
17+
18+
for (const key of keys) {
19+
assert(key in obj, `Expected '${name}' to have '${key}'`);
20+
}
21+
}
22+
23+
export function assertCommonBuildInfo(
24+
buildInfo: unknown
25+
): asserts buildInfo is CommonBuildInfo {
26+
assertObjectHasKeys(buildInfo, 'buildInfo', commonKeys);
27+
}
28+
29+
const windowsFilenameKeys = [
30+
'windows_setup_filename',
31+
'windows_msi_filename',
32+
'windows_zip_filename',
33+
'windows_nupkg_full_filename',
34+
] as const;
35+
type WindowsBuildInfo = CommonBuildInfo &
36+
Record<typeof windowsFilenameKeys[number], string>;
37+
38+
const osxFilenameKeys = ['osx_dmg_filename', 'osx_zip_filename'] as const;
39+
type OSXBuildInfo = CommonBuildInfo &
40+
Record<typeof osxFilenameKeys[number], string>;
41+
42+
const ubuntuFilenameKeys = [
43+
'linux_deb_filename',
44+
'linux_tar_filename',
45+
] as const;
46+
type UbuntuBuildInfo = CommonBuildInfo &
47+
Record<typeof ubuntuFilenameKeys[number], string>;
48+
49+
const rhelFilenameKeys = ['linux_rpm_filename', 'rhel_tar_filename'] as const;
50+
type RHELBuildInfo = CommonBuildInfo &
51+
Record<typeof rhelFilenameKeys[number], string>;
52+
53+
export function assertBuildInfoIsWindows(
54+
buildInfo: unknown
55+
): asserts buildInfo is WindowsBuildInfo {
56+
assertObjectHasKeys(buildInfo, 'buildInfo', commonKeys);
57+
assertObjectHasKeys(buildInfo, 'buildInfo', windowsFilenameKeys);
58+
}
59+
60+
export function assertBuildInfoIsOSX(
61+
buildInfo: unknown
62+
): asserts buildInfo is OSXBuildInfo {
63+
assertObjectHasKeys(buildInfo, 'buildInfo', commonKeys);
64+
assertObjectHasKeys(buildInfo, 'buildInfo', osxFilenameKeys);
65+
}
66+
67+
export function assertBuildInfoIsUbuntu(
68+
buildInfo: unknown
69+
): buildInfo is UbuntuBuildInfo {
70+
assertObjectHasKeys(buildInfo, 'buildInfo', commonKeys);
71+
assertObjectHasKeys(buildInfo, 'buildInfo', ubuntuFilenameKeys);
72+
return true;
73+
}
74+
75+
export function assertBuildInfoIsRHEL(
76+
buildInfo: unknown
77+
): asserts buildInfo is RHELBuildInfo {
78+
assertObjectHasKeys(buildInfo, 'buildInfo', commonKeys);
79+
assertObjectHasKeys(buildInfo, 'buildInfo', rhelFilenameKeys);
80+
}

packages/compass-e2e-tests/installers/mac-dmg.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import path from 'path';
22
import { existsSync } from 'fs';
3-
import type { InstalledAppInfo, Package } from './types';
3+
import type { InstalledAppInfo, InstallablePackage } from './types';
44
import { execute } from './helpers';
55

6-
export async function installMacDMG(
7-
appName: string,
8-
{ filepath }: Package
9-
): Promise<InstalledAppInfo> {
6+
export async function installMacDMG({
7+
appName,
8+
filepath,
9+
}: InstallablePackage): Promise<InstalledAppInfo> {
10+
// TODO: rather copy this to a temporary directory
1011
const fullDestinationPath = `/Applications/${appName}.app`;
1112

1213
if (existsSync(fullDestinationPath)) {
@@ -47,7 +48,9 @@ export async function installMacDMG(
4748
}
4849

4950
return Promise.resolve({
50-
appName,
51-
appPath: `/Applications/${appName}.app`,
51+
appPath: fullDestinationPath,
52+
uninstall: async function () {
53+
/* TODO */
54+
},
5255
});
5356
}
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
export type Installer = (pkg: InstallablePackage) => Promise<InstalledAppInfo>;
2+
13
export type Package = {
2-
filename: string;
4+
appName: string;
5+
packageFilepath: string;
6+
// TODO: once we can download the most recent release
7+
//releaseFilepath: string;
8+
installer: Installer;
9+
};
10+
11+
export type InstallablePackage = {
12+
appName: string;
313
filepath: string;
414
};
515

616
export type InstalledAppInfo = {
7-
appName: string;
817
appPath: string;
18+
uninstall: () => Promise<void>;
919
};

0 commit comments

Comments
 (0)