-
Notifications
You must be signed in to change notification settings - Fork 245
chore(e2e): test auto-update from COMPASS-8536 #6608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
747d2da
f2dc6cf
ded47b9
252707a
7ea61b9
d84a6c0
083425f
0f06e74
77dc547
805fcf4
8f0e730
a8b393f
0159641
1f32bcc
eb7ede3
fa27628
9134850
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to make it easy to copy/paste these into your local shell when working on the smoketests. Otherwise you have to transform the string manually every time. |
||
| 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" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,14 +8,20 @@ export function execute( | |
| ): Promise<void> { | ||
| return new Promise((resolve, reject) => { | ||
| console.log(command, ...args); | ||
|
|
||
| const p = spawn(command, args, { | ||
| stdio: 'inherit', | ||
| ...options, | ||
| }); | ||
|
|
||
| p.on('error', (err: any) => { | ||
| reject(err); | ||
| }); | ||
|
|
||
| p.on('close', (code: number | null, signal: NodeJS.Signals | null) => { | ||
| process.off('exit', killChild); | ||
| process.off('SIGINT', interruptChild); | ||
|
|
||
| if (code !== null) { | ||
| if (code === 0) { | ||
| resolve(); | ||
|
|
@@ -41,5 +47,11 @@ export function execute( | |
| } | ||
| } | ||
| }); | ||
|
|
||
| // Exit child process if main process exits | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copied from https://github.com/kraenhansen/bufout which we should probably just use. |
||
| const killChild = () => p.kill(); | ||
| const interruptChild = () => p.kill('SIGINT'); | ||
| process.once('exit', killChild); | ||
| process.once('SIGINT', interruptChild); | ||
| }); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { execute } from '../installers/helpers'; | ||
| import type { Package } from '../installers/types'; | ||
|
|
||
| // TODO: move this since we'll use the same for testing TO | ||
| function testInstalledApp( | ||
| pkg: Package, | ||
| appPath: string, | ||
| env: Record<string, string> | ||
| ): Promise<void> { | ||
| return execute( | ||
| 'npm', | ||
| [ | ||
| 'run', | ||
| '--unsafe-perm', | ||
| 'test-packaged', | ||
| '--workspace', | ||
| 'compass-e2e-tests', | ||
| '--', | ||
| '--test-filter=auto-update', | ||
| ], | ||
| { | ||
| env: { | ||
| ...process.env, | ||
| HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE: 'http://localhost:8080', | ||
| AUTO_UPDATE_UPDATABLE: pkg.updatable.toString(), | ||
| COMPASS_APP_NAME: pkg.appName, | ||
| COMPASS_APP_PATH: appPath, | ||
| ...env, | ||
| }, | ||
| } | ||
| ); | ||
| } | ||
|
|
||
| export async function testAutoUpdateFrom(pkg: Package) { | ||
| // install the app | ||
| console.log(`installing ${pkg.packageFilepath}`); | ||
| const { appPath, uninstall } = await pkg.installer({ | ||
| appName: pkg.appName, | ||
| filepath: pkg.packageFilepath, | ||
| }); | ||
|
|
||
| console.log(appPath); | ||
|
|
||
| try { | ||
| await testInstalledApp(pkg, appPath, { | ||
| AUTO_UPDATE_FROM: 'true', | ||
| }); | ||
| } finally { | ||
| // remove the app | ||
| await uninstall(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { expect } from 'chai'; | ||
| import { | ||
| init, | ||
| cleanup, | ||
| Selectors, | ||
| screenshotPathName, | ||
| } from '../helpers/compass'; | ||
|
|
||
| describe('Auto-update', function () { | ||
| it('auto-update from', async function () { | ||
| if (!process.env.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 | ||
| 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. | ||
| } 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' | ||
| ); | ||
| } | ||
| } finally { | ||
| await browser.screenshot(screenshotPathName('auto-update-from')); | ||
| await cleanup(compass); | ||
| } | ||
|
|
||
| if (process.env.AUTO_UPDATE_UPDATABLE === 'true') { | ||
| // 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); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| it('auto-update to', function () { | ||
| if (!process.env.AUTO_UPDATE_TO) { | ||
| // 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(); | ||
| } | ||
|
|
||
| // TODO | ||
| }); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plan is to run two of these: One that will downgrade the newly packaged compass to the most recent release like this, the other will upgrade from the most recent release to this newly packaged one. This newly packaged version isn't released yet, so we'll have to make some changes to compass-mongodb-com to be able to tell it about the new package. See https://jira.mongodb.org/browse/COMPASS-8761