Skip to content

Commit

Permalink
fix(#9257): fix upgrade order (#9259)
Browse files Browse the repository at this point in the history
Establishes strict test order.
Extracts master upgrade out of main test because we want to run other test assertions over current branch, not master.
Adds mocha bail so we fail fast if upgrade fails.

#9257
  • Loading branch information
dianabarsan authored Jul 12, 2024
1 parent 74b4314 commit 1e9efb7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 21 deletions.
38 changes: 38 additions & 0 deletions tests/e2e/upgrade/upgrade-master.wdio-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const loginPage = require('@page-objects/default/login/login.wdio.page');
const upgradePage = require('@page-objects/upgrade/upgrade.wdio.page');
const commonPage = require('@page-objects/default/common/common.wdio.page');
const aboutPage = require('@page-objects/default/about/about.wdio.page');
const constants = require('@constants');

const upgradeVersion = async () => {
await upgradePage.goToUpgradePage();
await upgradePage.expandPreReleasesAccordion();

await (await upgradePage.getInstallButton('master')).click();
await (await upgradePage.upgradeModalConfirm()).click();

await (await upgradePage.cancelUpgradeButton()).waitForDisplayed();
await (await upgradePage.deploymentInProgress()).waitForDisplayed();
await (await upgradePage.deploymentInProgress()).waitForDisplayed({ reverse: true, timeout: 100000 });

await (await upgradePage.deploymentComplete()).waitForDisplayed();
};


describe('Performing an upgrade from current branch to master', () => {
it('should upgrade from current version to master', async () => {
await loginPage.cookieLogin({
username: constants.USERNAME,
password: constants.PASSWORD,
createUser: false
});

await upgradeVersion('master');

expect(await upgradePage.getBuild()).to.include('alpha');
await commonPage.goToAboutPage();
await commonPage.waitForPageLoaded();
await (await aboutPage.aboutCard()).waitForDisplayed();
expect(await aboutPage.getVersion()).to.include('master');
});
});
19 changes: 0 additions & 19 deletions tests/e2e/upgrade/upgrade.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,25 +147,6 @@ describe('Performing an upgrade', () => {
const expected = TAG || `${utils.escapeBranchName(BRANCH)} (`;
expect(await aboutPage.getVersion()).to.include(expected);
await commonPage.logout();

// https://github.com/medic/cht-core/issues/9117
// install 'master' branch to make sure a new version can be installed from the build version

await loginPage.cookieLogin({
username: constants.USERNAME,
password: constants.PASSWORD,
createUser: false
});

await upgradeVersion('master');

expect(await upgradePage.getBuild()).to.include('alpha');
await commonPage.goToAboutPage();
await commonPage.waitForPageLoaded();
await (await aboutPage.aboutCard()).waitForDisplayed();
expect(await aboutPage.getVersion()).to.include('master');

await commonPage.logout();
});

it('should display upgrade page even without upgrade logs', async () => {
Expand Down
15 changes: 13 additions & 2 deletions tests/e2e/upgrade/wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ const rpn = require('request-promise-native');
const utils = require('@utils');
const wdioBaseConfig = require('../../wdio.conf');

const { MARKET_URL_READ, STAGING_SERVER, HAPROXY_PORT, BASE_VERSION } = process.env;
const {
MARKET_URL_READ='https://staging.dev.medicmobile.org',
STAGING_SERVER='_couch/builds_4',
HAPROXY_PORT,
BASE_VERSION='latest'
} = process.env;
const CHT_COMPOSE_PROJECT_NAME = 'cht-upgrade';

const UPGRADE_SERVICE_DOCKER_COMPOSE_FOLDER = utils.makeTempDir('upgrade-service-');
Expand Down Expand Up @@ -123,8 +128,13 @@ const servicesStartTimeout = () => {
// Override specific properties from wdio base config
const upgradeConfig = Object.assign(wdioBaseConfig.config, {
specs:
// order is important, because we want to upgrade from an older version to current version. validate the upgrade
// and then upgrade to master
[
'*.wdio-spec.js',
'upgrade.wdio-spec.js',
'admin-user.wdio-spec.js',
'webapp.wdio-spec.js',
'upgrade-master.wdio-spec.js',
],
exclude: [],

Expand All @@ -140,6 +150,7 @@ const upgradeConfig = Object.assign(wdioBaseConfig.config, {
mochaOpts: {
ui: 'bdd',
timeout: TEST_TIMEOUT,
bail: true
},
});

Expand Down

0 comments on commit 1e9efb7

Please sign in to comment.