Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b69b265
clone compass-mongodb-com and install it
lerouxb Jan 17, 2025
cdcb5ff
print the env vars in a copy/pastable way
lerouxb Jan 17, 2025
c1c619d
Test auto-updating from the version of Compass that was just packaged
lerouxb Jan 17, 2025
716ea1b
spawn parameters
lerouxb Jan 17, 2025
de07d7f
try git clone a different way
lerouxb Jan 17, 2025
15ff9df
try use modules
lerouxb Jan 17, 2025
f99421e
master
lerouxb Jan 17, 2025
0d01632
use a token rather
lerouxb Jan 17, 2025
6a1a527
Merge branch 'main' into autoupdate-from3
lerouxb Jan 20, 2025
fc00168
Merge branch 'main' into autoupdate-from3
lerouxb Jan 21, 2025
2870af1
@
lerouxb Jan 22, 2025
e67234c
Merge branch 'main' into autoupdate-from3
lerouxb Jan 22, 2025
3c3d6f2
maybe localhost doesn't work?
lerouxb Jan 22, 2025
e4b1ee5
do setup auto-update when testing auto-update
lerouxb Jan 22, 2025
8dcb191
I suppose we can now remove the comment
lerouxb Jan 22, 2025
99d9aa1
weirdness
lerouxb Jan 22, 2025
289f2f7
Merge branch 'main' into autoupdate-from3
lerouxb Jan 22, 2025
77c44e5
we have to preinstall
lerouxb Jan 22, 2025
c73efc2
make dirs
lerouxb Jan 22, 2025
72a6dad
actually we probably only need the env vars
lerouxb Jan 22, 2025
0edeb32
fix the expected download link
lerouxb Jan 22, 2025
2717bcf
copy mac shipit logs
lerouxb Jan 22, 2025
ecb2eb3
ShipIt shenanigans
lerouxb Jan 22, 2025
50a1fc2
print caches
lerouxb Jan 22, 2025
fa4d5d0
see if there is more info on error
lerouxb Jan 22, 2025
65403ed
add extra error keys
lerouxb Jan 22, 2025
19b63ee
more debugging
lerouxb Jan 23, 2025
ed7f6d8
remove some excessive logging
lerouxb Jan 23, 2025
604613a
Merge branch 'main' into autoupdate-from3
lerouxb Jan 23, 2025
9e7e4e1
see if compass will auto-update in CI with a day ago's nightly build …
lerouxb Jan 23, 2025
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
1 change: 1 addition & 0 deletions .evergreen/buildvariants-and-tasks.in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ tasks:
- func: bootstrap
vars:
scope: 'compass-e2e-tests'
- func: get-compass-mongodb-com
- func: smoketest-packaged-app
vars:
mongodb_version: latest-enterprise
Expand Down
1 change: 1 addition & 0 deletions .evergreen/buildvariants-and-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ tasks:
- func: bootstrap
vars:
scope: compass-e2e-tests
- func: get-compass-mongodb-com
- func: smoketest-packaged-app
vars:
mongodb_version: latest-enterprise
Expand Down
30 changes: 30 additions & 0 deletions .evergreen/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,36 @@ functions:

npm run --unsafe-perm --workspace compass-e2e-tests test-packaged-ci

get-compass-mongodb-com:
- command: github.generate_token
params:
owner: 10gen
repo: compass-mongodb-com
expansion_name: generated_token
permissions: # optional
contents: read
- command: shell.exec
type: setup
params:
working_dir: src
shell: bash
env:
<<: *compass-env
script: |
set -e
eval $(.evergreen/print-compass-env.sh)
git clone https://x-access-token:${generated_token}@github.com/10gen/compass-mongodb-com.git ../compass-mongodb-com
cd ../compass-mongodb-com
echo "Using node version:";
node -v;
echo "Using npm version:";
npm -v;
echo "Using gcc version:"
gcc --version;
echo "Using g++ version:"
g++ --version;
npm ci --engine-strict=false

smoketest-packaged-app:
- command: shell.exec
# Fail the task if it's idle for 10 mins
Expand Down
6 changes: 3 additions & 3 deletions .evergreen/preinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ 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 "export DEV_VERSION_IDENTIFIER=$DEV_VERSION_IDENTIFIER"
echo "export EVERGREEN_BUCKET_KEY_PREFIX=$EVERGREEN_BUCKET_KEY_PREFIX"
echo "export EVERGREEN_BUCKET_NAME=$EVERGREEN_BUCKET_NAME"

echo "IS_OSX: $IS_OSX"
echo "IS_LINUX: $IS_LINUX"
Expand Down
4 changes: 4 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions packages/compass-e2e-tests/helpers/compass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,10 @@ async function startCompassElectron(

process.env.APP_ENV = 'webdriverio';
// For webdriverio env we are changing appName so that keychain records do not
// overlap with anything else
process.env.HADRON_PRODUCT_NAME_OVERRIDE = 'MongoDB Compass WebdriverIO';
// overlap with anything else. But leave it alone if
if (!process.env.HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE) {
process.env.HADRON_PRODUCT_NAME_OVERRIDE = 'MongoDB Compass WebdriverIO';
}

// Guide cues might affect too many tests in a way where the auto showing of the cue prevents
// clicks from working on elements. Dealing with this case-by-case is way too much work, so
Expand Down
9 changes: 9 additions & 0 deletions packages/compass-e2e-tests/helpers/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1380,3 +1380,12 @@ export const GlobalWrites = {
SampleFindingDocuments: '[data-testid="sample-finding-documents"]',
SampleInsertingDocuments: '[data-testid="sample-inserting-documents"]',
};

// Auto-update toasts
export const AutoUpdateToast = '[data-testid="toast-compass-update"]';
export const AutoUpdateRestartButton =
'[data-testid="auto-update-restart-button"]';
export const AutoUpdateDownloadLink =
'[data-testid="auto-update-download-link"]';
export const AutoUpdateReleaseNotesLink =
'[data-testid="auto-update-release-notes-link"]';
87 changes: 87 additions & 0 deletions packages/compass-e2e-tests/tests/auto-update.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import fs from 'fs';
import path from 'path';
import { expect } from 'chai';
import {
init,
cleanup,
Selectors,
screenshotPathName,
} from '../helpers/compass';
import { LOG_PATH } from '../helpers/test-runner-paths';

describe('Auto-update', function () {
it('auto-update from', async function () {
if (process.env.TEST_NAME !== 'AUTO_UPDATE_FROM') {
// we don't want this test to execute along with all the others under
// normal circumstances because it is destructive - it overwrites Compass
// itself
this.skip();
}

// run the app and wait for it to auto-update
console.log('starting compass the first time');
const compass = await init('auto-update from', { firstRun: true });
const { browser } = compass;
try {
await browser.$(Selectors.AutoUpdateToast).waitForDisplayed();

if (process.env.AUTO_UPDATE_UPDATABLE === 'true') {
const restartButton = browser.$(Selectors.AutoUpdateRestartButton);
await restartButton.waitForDisplayed();

// We could click the restart button to apply the update and restart the
// app, but restarting the app confuses webdriverio or at least our test
// helpers. So we're going to just restart the app manually.
await browser.pause(1000);
} else {
// When auto-update is not supported the toast contains a link to
// download
const linkElement = browser.$(Selectors.AutoUpdateDownloadLink);
await linkElement.waitForDisplayed();
expect(await linkElement.getAttribute('href')).to.equal(
'https://www.mongodb.com/try/download/compass?utm_source=compass&utm_medium=product'
);
}
} finally {
await browser.screenshot(screenshotPathName('auto-update-from'));
await cleanup(compass);

if (process.platform === 'darwin' && process.env.HOME) {
console.log('copying ShipIt dir if it exits');
const shipitDir = path.resolve(
process.env.HOME,
'Library',
'Caches',
'com.mongodb.compass.dev.ShipIt'
);

if (fs.existsSync(shipitDir)) {
console.log(`copying ${shipitDir}`);
fs.cpSync(shipitDir, `${LOG_PATH}/ShipIt`, { recursive: true });
} else {
console.log(`${shipitDir} does not exist`);
}
}
}

if (process.env.AUTO_UPDATE_UPDATABLE === 'true') {
console.log('starting compass a second time');
// run the app again and check that the version changed
const compass = await init('auto-update from restart', {
firstRun: false,
});
const { browser } = compass;
try {
await browser.$(Selectors.AutoUpdateToast).waitForDisplayed();
await browser
.$(Selectors.AutoUpdateReleaseNotesLink)
.waitForDisplayed();
} finally {
await browser.screenshot(
screenshotPathName('auto-update-from-restart')
);
await cleanup(compass);
}
}
});
});
2 changes: 2 additions & 0 deletions packages/compass-smoke-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
"@mongodb-js/eslint-config-compass": "^1.2.3",
"@mongodb-js/prettier-config-compass": "^1.1.3",
"@mongodb-js/tsconfig-compass": "^1.1.3",
"cross-spawn": "^7.0.5",
"depcheck": "^1.4.1",
"eslint": "^7.25.0",
"hadron-build": "^25.6.3",
"lodash": "^4.17.21",
"prettier": "^2.7.1",
"tree-kill": "^1.2.2",
"typescript": "^5.0.4",
"yargs": "^17.7.2"
}
Expand Down
94 changes: 90 additions & 4 deletions packages/compass-smoke-tests/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';

//import crossSpawn from 'cross-spawn';
//import kill from 'tree-kill';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { pick } from 'lodash';
Expand All @@ -21,6 +23,11 @@ import { installMacDMG } from './installers/mac-dmg';
import { installMacZIP } from './installers/mac-zip';
import { installWindowsZIP } from './installers/windows-zip';

// hardcode to yesterday's nightly
process.env.DEV_VERSION_IDENTIFIER = '25.1.22-dev.10011';
process.env.EVERGREEN_BUCKET_KEY_PREFIX =
'10gen-compass-main/e231969720181ae6e978f0ce3799b954d99ed9a2_7797';

const SUPPORTED_PLATFORMS = ['win32', 'darwin', 'linux'] as const;
const SUPPORTED_ARCHS = ['x64', 'arm64'] as const;

Expand Down Expand Up @@ -179,7 +186,9 @@ async function run() {
])
);

const { kind, filepath, appName } = await getTestSubject(context);
const { kind, filepath, appName, autoUpdatable } = await getTestSubject(
context
);
const install = getInstaller(kind);

try {
Expand All @@ -190,7 +199,25 @@ async function run() {
});

try {
runTest({ appName, appPath });
//const server = startAutoUpdateServer({
// allowDowngrades: true,
// port: 8080,
//});
try {
runTest({
appName,
appPath,
autoUpdatable,
testName: 'AUTO_UPDATE_FROM',
});
} finally {
//if (server.pid) {
// console.log('Stopping auto-update server');
// kill(server.pid, 'SIGINT');
//} else {
// console.log('cannnot stop auto-update server because no pid');
//}
}
} finally {
await uninstall();
}
Expand All @@ -200,12 +227,62 @@ async function run() {
}
}

/*
type AutoUpdateServerOptions = {
port: number;
allowDowngrades?: boolean;
};

function startAutoUpdateServer({
port,
allowDowngrades,
}: AutoUpdateServerOptions) {
const env: Record<string, string> = {
...process.env,
PORT: port.toString(),
};
if (allowDowngrades) {
env.UPDATE_CHECKER_ALLOW_DOWNGRADES = 'true';
}

// a git repo that is not published to npm that evergreen clones for us in CI
// next to the Compass code
const cwd = path.join(
__dirname,
'..',
'..',
'..',
'..',
'compass-mongodb-com'
);

if (!fs.existsSync(cwd)) {
throw new Error(`compass-mongodb-com does not exist: ${cwd}`);
}

console.log('Starting auto-update server', cwd);
return crossSpawn.spawn('npm', ['run', 'start'], {
env,
cwd,
stdio: 'inherit',
shell: true,
});
}
*/

type RunTestOptions = {
appName: string;
appPath: string;
autoUpdatable?: boolean;
testName: string;
};

function runTest({ appName, appPath }: RunTestOptions) {
function runTest({
appName,
appPath,
autoUpdatable,
testName,
}: RunTestOptions) {
execute(
'npm',
[
Expand All @@ -215,13 +292,22 @@ function runTest({ appName, appPath }: RunTestOptions) {
'--workspace',
'compass-e2e-tests',
'--',
'--test-filter=time-to-first-query',
'--test-filter=auto-update',
],
{
// We need to use a shell to get environment variables setup correctly
shell: true,
env: {
...process.env,
//HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE: 'http://localhost:8080',

// this is the usual one, just setting
// HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE so the app will set up the
// auto-update code even though it is running in CI
HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE: 'https://compass.mongodb.com',

AUTO_UPDATE_UPDATABLE: (!!autoUpdatable).toString(),
TEST_NAME: testName,
COMPASS_APP_NAME: appName,
COMPASS_APP_PATH: appPath,
},
Expand Down
4 changes: 4 additions & 0 deletions packages/compass-smoke-tests/src/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export function execute(
args: string[],
options?: SpawnOptions
) {
// print the command so that when it outputs to stdout we can see where it
// comes from
console.log(command, args);

const { status, signal } = spawnSync(command, args, {
stdio: 'inherit',
...options,
Expand Down
Loading
Loading