Skip to content

Commit 818c663

Browse files
authored
feat(smoke-tests): test deb installer for on Ubuntu COMPASS-8712 (#6699)
* Implement Linux deb installer * Arm CI to run time-to-first-query for linux_deb
1 parent 10e4f0d commit 818c663

File tree

4 files changed

+77
-1
lines changed

4 files changed

+77
-1
lines changed

.evergreen/functions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ functions:
693693
fi
694694
695695
if [[ "$IS_UBUNTU" == "true" ]]; then
696-
# TODO: linux_deb
696+
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=linux_deb --tests=time-to-first-query
697697
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=linux_tar --tests=time-to-first-query
698698
fi
699699
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import assert from 'node:assert/strict';
2+
import cp from 'node:child_process';
3+
4+
/**
5+
* Call apt to get the package name
6+
*/
7+
export function getPackageName(filepath: string) {
8+
const result = cp.spawnSync('apt', ['show', filepath], { encoding: 'utf8' });
9+
assert.equal(
10+
result.status,
11+
0,
12+
`Expected a clean exit, got status ${result.status || 'null'}`
13+
);
14+
const packageMatch = result.stdout.match(/Package: (?<name>.+)/);
15+
assert(packageMatch, 'Expected a line in the output with the package name');
16+
assert(packageMatch.groups);
17+
const { name } = packageMatch.groups;
18+
assert(typeof name === 'string');
19+
return name;
20+
}

packages/compass-smoke-tests/src/installers/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { installWindowsZIP } from './windows-zip';
55
import { installWindowsMSI } from './windows-msi';
66
import { installWindowsSetup } from './windows-setup';
77
import { installLinuxTar } from './linux-tar';
8+
import { installLinuxDeb } from './linux-deb';
89

910
export function getInstaller(kind: PackageKind) {
1011
if (kind === 'osx_dmg') {
@@ -19,6 +20,8 @@ export function getInstaller(kind: PackageKind) {
1920
return installWindowsSetup;
2021
} else if (kind === 'linux_tar') {
2122
return installLinuxTar;
23+
} else if (kind === 'linux_deb') {
24+
return installLinuxDeb;
2225
} else {
2326
throw new Error(`Installer for '${kind}' is not yet implemented`);
2427
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import assert from 'node:assert/strict';
2+
import fs from 'node:fs';
3+
import path from 'node:path';
4+
5+
import type { InstalledAppInfo, InstallablePackage } from './types';
6+
import { execute } from '../execute';
7+
import * as apt from './apt';
8+
9+
export function installLinuxDeb({
10+
appName,
11+
filepath,
12+
}: InstallablePackage): InstalledAppInfo {
13+
const packageName = apt.getPackageName(filepath);
14+
const installPath = `/usr/lib/${packageName}`;
15+
const appPath = path.resolve(installPath, appName);
16+
17+
function uninstall() {
18+
execute('sudo', ['apt', 'remove', '--yes', '--purge', packageName]);
19+
}
20+
21+
console.warn(
22+
"Installing globally, since we haven't discovered a way to specify an install path"
23+
);
24+
25+
if (fs.existsSync(installPath)) {
26+
console.warn(
27+
'Found an existing install directory (likely from a previous run): Uninstalling first'
28+
);
29+
uninstall();
30+
}
31+
32+
assert(
33+
!fs.existsSync(installPath),
34+
`Expected no install directory to exist: ${installPath}`
35+
);
36+
console.warn(
37+
"Installing globally, since we haven't discovered a way to specify an install path"
38+
);
39+
execute('sudo', ['apt', 'install', filepath]);
40+
41+
assert(
42+
fs.existsSync(installPath),
43+
`Expected an install directory to exist: ${installPath}`
44+
);
45+
46+
// Check that the executable will run without being quarantined or similar
47+
execute('xvfb-run', [appPath, '--version']);
48+
49+
return {
50+
appPath: installPath,
51+
uninstall,
52+
};
53+
}

0 commit comments

Comments
 (0)