Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .evergreen/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ functions:
fi

if [[ "$IS_UBUNTU" == "true" ]]; then
# TODO: linux_deb
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=linux_deb --tests=time-to-first-query
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=linux_tar --tests=time-to-first-query
fi

Expand Down
20 changes: 20 additions & 0 deletions packages/compass-smoke-tests/src/installers/apt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import assert from 'node:assert/strict';
import cp from 'node:child_process';

/**
* Call apt to get the package name
*/
export function getPackageName(filepath: string) {
const result = cp.spawnSync('apt', ['show', filepath], { encoding: 'utf8' });
assert.equal(
result.status,
0,
`Expected a clean exit, got status ${result.status || 'null'}`
);
const packageMatch = result.stdout.match(/Package: (?<name>.+)/);
assert(packageMatch, 'Expected a line in the output with the package name');
assert(packageMatch.groups);
const { name } = packageMatch.groups;
assert(typeof name === 'string');
return name;
}
3 changes: 3 additions & 0 deletions packages/compass-smoke-tests/src/installers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { installWindowsZIP } from './windows-zip';
import { installWindowsMSI } from './windows-msi';
import { installWindowsSetup } from './windows-setup';
import { installLinuxTar } from './linux-tar';
import { installLinuxDeb } from './linux-deb';

export function getInstaller(kind: PackageKind) {
if (kind === 'osx_dmg') {
Expand All @@ -19,6 +20,8 @@ export function getInstaller(kind: PackageKind) {
return installWindowsSetup;
} else if (kind === 'linux_tar') {
return installLinuxTar;
} else if (kind === 'linux_deb') {
return installLinuxDeb;
} else {
throw new Error(`Installer for '${kind}' is not yet implemented`);
}
Expand Down
53 changes: 53 additions & 0 deletions packages/compass-smoke-tests/src/installers/linux-deb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';

import type { InstalledAppInfo, InstallablePackage } from './types';
import { execute } from '../execute';
import * as apt from './apt';

export function installLinuxDeb({
appName,
filepath,
}: InstallablePackage): InstalledAppInfo {
const packageName = apt.getPackageName(filepath);
const installPath = `/usr/lib/${packageName}`;
const appPath = path.resolve(installPath, appName);

function uninstall() {
execute('sudo', ['apt', 'remove', '--yes', '--purge', packageName]);
}

console.warn(
"Installing globally, since we haven't discovered a way to specify an install path"
);

if (fs.existsSync(installPath)) {
console.warn(
'Found an existing install directory (likely from a previous run): Uninstalling first'
);
uninstall();
}

assert(
!fs.existsSync(installPath),
`Expected no install directory to exist: ${installPath}`
);
console.warn(
"Installing globally, since we haven't discovered a way to specify an install path"
);
execute('sudo', ['apt', 'install', filepath]);

assert(
fs.existsSync(installPath),
`Expected an install directory to exist: ${installPath}`
);

// Check that the executable will run without being quarantined or similar
execute('xvfb-run', [appPath, '--version']);

return {
appPath: installPath,
uninstall,
};
}
Loading