Skip to content
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

[Upgrade Assistant] Fixes to Upgrade Assistant Tests and Page Objects To Stop CI Failures #89942

Merged
merged 5 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
43 changes: 28 additions & 15 deletions x-pack/test/functional/apps/upgrade_assistant/upgrade_assistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function upgradeAssistantFunctionalTests({
Expand All @@ -14,6 +15,7 @@ export default function upgradeAssistantFunctionalTests({
const PageObjects = getPageObjects(['upgradeAssistant', 'common']);
const security = getService('security');
const log = getService('log');
const retry = getService('retry');

describe('Upgrade Checkup', function () {
this.tags('includeFirefox');
Expand All @@ -24,41 +26,52 @@ export default function upgradeAssistantFunctionalTests({
});

after(async () => {
await PageObjects.upgradeAssistant.expectTelemetryHasFinish();
await PageObjects.upgradeAssistant.waitForTelemetryHidden();
await esArchiver.unload('empty_kibana');
await security.testUser.restoreDefaults();
});

it('allows user to navigate to upgrade checkup', async () => {
await PageObjects.upgradeAssistant.navigateToPage();
await PageObjects.upgradeAssistant.expectUpgradeAssistant();
});

it('allows user to toggle deprecation logging', async () => {
await PageObjects.upgradeAssistant.navigateToPage();
log.debug('expect initial state to be ON');
await PageObjects.upgradeAssistant.expectDeprecationLoggingLabel('On');
log.debug('Now toggle to off');
await PageObjects.upgradeAssistant.toggleDeprecationLogging();
await PageObjects.common.sleep(2000);
log.debug('expect state to be OFF after toggle');
await PageObjects.upgradeAssistant.expectDeprecationLoggingLabel('Off');
await PageObjects.upgradeAssistant.toggleDeprecationLogging();
await PageObjects.common.sleep(2000);
log.debug('expect state to be ON after toggle');
await PageObjects.upgradeAssistant.expectDeprecationLoggingLabel('On');
expect(await PageObjects.upgradeAssistant.deprecationLoggingEnabledLabel()).to.be('On');
expect(await PageObjects.upgradeAssistant.isDeprecationLoggingEnabled()).to.be(true);

await retry.try(async () => {
log.debug('Now toggle to off');
await PageObjects.upgradeAssistant.toggleDeprecationLogging();

log.debug('expect state to be OFF after toggle');
expect(await PageObjects.upgradeAssistant.isDeprecationLoggingEnabled()).to.be(false);
expect(await PageObjects.upgradeAssistant.deprecationLoggingEnabledLabel()).to.be('Off');
});

log.debug('Now toggle back on.');
await retry.try(async () => {
await PageObjects.upgradeAssistant.toggleDeprecationLogging();
log.debug('expect state to be ON after toggle');
expect(await PageObjects.upgradeAssistant.isDeprecationLoggingEnabled()).to.be(true);
expect(await PageObjects.upgradeAssistant.deprecationLoggingEnabledLabel()).to.be('On');
});
});

it('allows user to open cluster tab', async () => {
await PageObjects.upgradeAssistant.navigateToPage();
await PageObjects.upgradeAssistant.clickTab('cluster');
await PageObjects.upgradeAssistant.expectIssueSummary('You have no cluster issues.');
expect(await PageObjects.upgradeAssistant.issueSummaryText()).to.be(
'You have no cluster issues.'
);
});

it('allows user to open indices tab', async () => {
await PageObjects.upgradeAssistant.navigateToPage();
await PageObjects.upgradeAssistant.clickTab('indices');
await PageObjects.upgradeAssistant.expectIssueSummary('You have no index issues.');
expect(await PageObjects.upgradeAssistant.issueSummaryText()).to.be(
'You have no index issues.'
);
});
});
}
65 changes: 30 additions & 35 deletions x-pack/test/functional/page_objects/upgrade_assistant_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../ftr_provider_context';

export function UpgradeAssistantPageProvider({ getPageObjects, getService }: FtrProviderContext) {
Expand All @@ -24,34 +23,32 @@ export function UpgradeAssistantPageProvider({ getPageObjects, getService }: Ftr
return await retry.try(async () => {
await common.navigateToApp('settings');
await testSubjects.click('upgrade_assistant');
retry.waitFor('url to contain /upgrade_assistant', async () => {
const url = await browser.getCurrentUrl();
return url.includes('/upgrade_assistant');
});
});
}

async expectUpgradeAssistant() {
return await retry.try(async () => {
log.debug(`expectUpgradeAssistant()`);
expect(await testSubjects.exists('upgradeAssistantRoot')).to.equal(true);
const url = await browser.getCurrentUrl();
expect(url).to.contain(`/upgrade_assistant`);
});
async toggleDeprecationLogging() {
log.debug('toggleDeprecationLogging()');
await testSubjects.click('upgradeAssistantDeprecationToggle');
}

async toggleDeprecationLogging() {
return await retry.try(async () => {
log.debug('toggleDeprecationLogging()');
await testSubjects.click('upgradeAssistantDeprecationToggle');
});
async isDeprecationLoggingEnabled() {
const isDeprecationEnabled = await testSubjects.getAttribute(
'upgradeAssistantDeprecationToggle',
'aria-checked'
);
log.debug(`Deprecation enabled == ${isDeprecationEnabled}`);
return isDeprecationEnabled === 'true';
}

async expectDeprecationLoggingLabel(labelText: string) {
return await retry.try(async () => {
log.debug('expectDeprecationLoggingLabel()');
const label = await find.byCssSelector(
'[data-test-subj="upgradeAssistantDeprecationToggle"] ~ span'
);
const value = await label.getVisibleText();
expect(value).to.equal(labelText);
});
async deprecationLoggingEnabledLabel() {
const loggingEnabledLabel = await find.byCssSelector(
'[data-test-subj="upgradeAssistantDeprecationToggle"] ~ span'
);
return await loggingEnabledLabel.getVisibleText();
}

async clickTab(tabId: string) {
Expand All @@ -61,22 +58,20 @@ export function UpgradeAssistantPageProvider({ getPageObjects, getService }: Ftr
});
}

async expectIssueSummary(summary: string) {
return await retry.try(async () => {
log.debug('expectIssueSummary()');
const summaryElText = await testSubjects.getVisibleText('upgradeAssistantIssueSummary');
expect(summaryElText).to.eql(summary);
async waitForTelemetryHidden() {
const self = this;
retry.waitFor('Telemetry to disappear.', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing failures like https://kibana-ci.elastic.co/job/elastic+kibana+pipeline-pull-request/104171/execution/node/796/log/

What seems to happen is that tests pass and complete, so the test runner kills the kibana process. However webdriver is still stuck in this waitFor and so exits with a non-zero code.

I suspect we need to insert an await here await retry.waitFor('... so that we don't end the test and kill Kibana before webdriver is done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return (await self.isTelemetryExists()) === false;
});
}

async expectTelemetryHasFinish() {
return await retry.try(async () => {
log.debug('expectTelemetryHasFinish');
const isTelemetryFinished = !(await testSubjects.exists(
'upgradeAssistantTelemetryRunning'
));
expect(isTelemetryFinished).to.equal(true);
});
async issueSummaryText() {
log.debug('expectIssueSummary()');
return await testSubjects.getVisibleText('upgradeAssistantIssueSummary');
}

async isTelemetryExists() {
return await testSubjects.exists('upgradeAssistantTelemetryRunning');
}
}

Expand Down