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

Search Sessions: Improve Flaky Functional Test #89370

Merged
merged 7 commits into from
Feb 2, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { FtrProviderContext } from '../ftr_provider_context';

export function SearchSessionsPageProvider({ getService, getPageObjects }: FtrProviderContext) {
const log = getService('log');
const find = getService('find');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common']);
Expand All @@ -21,7 +22,7 @@ export function SearchSessionsPageProvider({ getService, getPageObjects }: FtrPr
},

async getList() {
const table = await find.byCssSelector('table');
const table = await testSubjects.find('searchSessionsMgmtTable');
const allRows = await table.findAllByTestSubject('searchSessionsRow');

return Promise.all(
Expand All @@ -37,15 +38,18 @@ export function SearchSessionsPageProvider({ getService, getPageObjects }: FtrPr
expires: $.findTestSubject('sessionManagementExpiresCol').text(),
app: $.findTestSubject('sessionManagementAppIcon').attr('data-test-app-id'),
view: async () => {
log.debug('management ui: view the session');
await viewCell.click();
},
reload: async () => {
log.debug('management ui: reload the status');
await actionsCell.click();
await find.clickByCssSelector(
'[data-test-subj="sessionManagementPopoverAction-reload"]'
);
},
cancel: async () => {
log.debug('management ui: cancel the session');
await actionsCell.click();
await find.clickByCssSelector(
'[data-test-subj="sessionManagementPopoverAction-cancel"]'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,27 @@ export function SearchSessionsProvider({ getService }: FtrProviderContext) {
}

public async viewSearchSessions() {
log.debug('viewSearchSessions');
await this.ensurePopoverOpened();
await testSubjects.click('searchSessionIndicatorviewSearchSessionsLink');
}

public async save() {
log.debug('save the search session');
await this.ensurePopoverOpened();
await testSubjects.click('searchSessionIndicatorSaveBtn');
await this.ensurePopoverClosed();
}

public async cancel() {
log.debug('cancel the search session');
await this.ensurePopoverOpened();
await testSubjects.click('searchSessionIndicatorCancelBtn');
await this.ensurePopoverClosed();
}

public async refresh() {
log.debug('refresh the status');
await this.ensurePopoverOpened();
await testSubjects.click('searchSessionIndicatorRefreshBtn');
await this.ensurePopoverClosed();
Expand All @@ -85,15 +89,20 @@ export function SearchSessionsProvider({ getService }: FtrProviderContext) {
}

private async ensurePopoverOpened() {
log.debug('ensurePopoverOpened');
const isAlreadyOpen = await testSubjects.exists(SEARCH_SESSIONS_POPOVER_CONTENT_TEST_SUBJ);
if (isAlreadyOpen) return;
if (isAlreadyOpen) {
log.debug('Popover is already open');
return;
}
return retry.waitFor(`searchSessions popover opened`, async () => {
await testSubjects.click(SEARCH_SESSION_INDICATOR_TEST_SUBJ);
return await testSubjects.exists(SEARCH_SESSIONS_POPOVER_CONTENT_TEST_SUBJ);
});
}

private async ensurePopoverClosed() {
log.debug('ensurePopoverClosed');
const isAlreadyClosed = !(await testSubjects.exists(
SEARCH_SESSIONS_POPOVER_CONTENT_TEST_SUBJ
));
Expand All @@ -110,7 +119,7 @@ export function SearchSessionsProvider({ getService }: FtrProviderContext) {
* Alternatively, a test can navigate to `Management > Search Sessions` and use the UI to delete any created tests.
*/
public async deleteAllSearchSessions() {
log.debug('Deleting created searcg sessions');
log.debug('Deleting created search sessions');
// ignores 409 errs and keeps retrying
await retry.tryForTime(10000, async () => {
const { body } = await supertest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { FtrProviderContext } from '../../../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const retry = getService('retry');
const PageObjects = getPageObjects([
'common',
'header',
Expand All @@ -18,20 +19,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
]);
const searchSessions = getService('searchSessions');
const esArchiver = getService('esArchiver');
const retry = getService('retry');
const log = getService('log');

// FLAKY: https://github.com/elastic/kibana/issues/89069
describe.skip('Search search sessions Management UI', () => {
describe.skip('Search sessions Management UI', () => {
describe('New search sessions', () => {
before(async () => {
await PageObjects.common.navigateToApp('dashboard');
log.debug('wait for dashboard landing page');
retry.tryForTime(10000, async () => {
Copy link
Member Author

@tsullivan tsullivan Jan 26, 2021

Choose a reason for hiding this comment

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

If we are on a loading screen, dashboard.loadSavedDashboard has flaky behavior: it wants to take us to the landing page, so tries to click a breadcrumb. But then the loading screen goes away and we are on the landing page. The landing page doesn't have a breadcrumb to itself, so dashboard.loadSavedDashboard breaks.

Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't navigateToApp('dashboard'); always take us to the landing page? I would think if that navigate method always sets the URL and uses the timestamp hash that it would reliably be on the landing page? I think some dashboard tests did something to avoid the timestamp hash in the URL to preserve state. Maybe that's related.

Copy link
Member Author

Choose a reason for hiding this comment

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

It takes us to the landing page, which could actually be displaying a loading screen. This retry waits until any loading screen is cleared.

testSubjects.existOrFail('dashboardLandingPage');
});
});

after(async () => {
await searchSessions.deleteAllSearchSessions();
});

it('Saves a session and verifies it in the Management app', async () => {
log.debug('loading the "Not Delayed" dashboard');
await PageObjects.dashboard.loadSavedDashboard('Not Delayed');
await PageObjects.dashboard.waitForRenderComplete();
await searchSessions.expectState('completed');
Expand All @@ -47,6 +53,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

// find there is only one item in the table which is the newly saved session
log.debug('find the newly saved session');
const searchSessionList = await PageObjects.searchSessionsManagement.getList();
expect(searchSessionList.length).to.be(1);
expect(searchSessionList[0].expires).not.to.eql('--');
Expand All @@ -63,6 +70,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await searchSessions.expectState('restored');
});

// NOTE: this test depends on the previous one passing
it('Reloads as new session from management', async () => {
await PageObjects.searchSessionsManagement.goTo();

Expand Down