Skip to content

Commit

Permalink
remove hard coded timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Feb 14, 2020
1 parent 8caa012 commit 8b843d0
Show file tree
Hide file tree
Showing 27 changed files with 220 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ export const schema = Joi.object()
try: Joi.number().default(120000),
waitFor: Joi.number().default(20000),
esRequestTimeout: Joi.number().default(30000),
kibanaStabilize: Joi.number().default(15000),
navigateStatusPageCheck: Joi.number().default(250),

// Many of our tests use the `exists` functions to determine where the user is. For
// example, you'll see a lot of code like:
Expand Down
9 changes: 6 additions & 3 deletions test/functional/page_objects/dashboard_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide
const log = getService('log');
const find = getService('find');
const retry = getService('retry');
const config = getService('config');
const browser = getService('browser');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
Expand Down Expand Up @@ -114,7 +115,7 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide
public async onDashboardLandingPage() {
log.debug(`onDashboardLandingPage`);
return await testSubjects.exists('dashboardLandingPage', {
timeout: 5000,
timeout: config.get('timeouts.waitForExits') * 2,
});
}

Expand Down Expand Up @@ -362,7 +363,9 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide
await listingTable.clickItemLink('dashboard', dashboardName);
await PageObjects.header.waitUntilLoadingHasFinished();
// check Dashboard landing page is not present
await testSubjects.missingOrFail('dashboardLandingPage', { timeout: 10000 });
await testSubjects.missingOrFail('dashboardLandingPage', {
timeout: config.get('timeouts.waitForExits') * 5,
});
});
}

Expand Down Expand Up @@ -497,7 +500,7 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide
for (const name of vizList) {
const isPresent = await testSubjects.exists(
`embeddablePanelHeading-${name.replace(/\s+/g, '')}`,
{ timeout: 10000 }
{ timeout: config.get('timeouts.waitForExits') * 5 }
);
checkList.push({ name, isPresent });
}
Expand Down
4 changes: 3 additions & 1 deletion test/functional/page_objects/header_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ export function HeaderPageProvider({ getService, getPageObjects }) {

async isGlobalLoadingIndicatorVisible() {
log.debug('isGlobalLoadingIndicatorVisible');
return await testSubjects.exists('globalLoadingIndicator', { timeout: 1500 });
return await testSubjects.exists('globalLoadingIndicator', {
timeout: config.get('timeouts.waitForExits') * 0.6,
});
}

async awaitGlobalLoadingIndicatorHidden() {
Expand Down
3 changes: 2 additions & 1 deletion test/functional/page_objects/home_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { FtrProviderContext } from '../ftr_provider_context';
export function HomePageProvider({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const retry = getService('retry');
const config = getService('config');
const find = getService('find');
const PageObjects = getPageObjects(['common']);
let isOss = true;
Expand Down Expand Up @@ -83,7 +84,7 @@ export function HomePageProvider({ getService, getPageObjects }: FtrProviderCont
await retry.try(async () => {
await testSubjects.click('loadSavedObjects');
const successMsgExists = await testSubjects.exists('loadSavedObjects_success', {
timeout: 5000,
timeout: config.get('timeouts.waitForExits') * 2,
});
if (!successMsgExists) {
throw new Error('Failed to load saved objects');
Expand Down
29 changes: 22 additions & 7 deletions test/functional/page_objects/settings_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { FtrProviderContext } from '../ftr_provider_context';
export function SettingsPageProvider({ getService, getPageObjects }: FtrProviderContext) {
const log = getService('log');
const retry = getService('retry');
const config = getService('config');
const browser = getService('browser');
const find = getService('find');
const flyout = getService('flyout');
Expand Down Expand Up @@ -298,12 +299,16 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider
}

async getIndexPatternList() {
await testSubjects.existOrFail('indexPatternTable', { timeout: 5000 });
await testSubjects.existOrFail('indexPatternTable', {
timeout: config.get('timeouts.waitForExits') * 2,
});
return await find.allByCssSelector('[data-test-subj="indexPatternTable"] .euiTable a');
}

async isIndexPatternListEmpty() {
await testSubjects.existOrFail('indexPatternTable', { timeout: 5000 });
await testSubjects.existOrFail('indexPatternTable', {
timeout: config.get('timeouts.waitForExits') * 2,
});
const indexPatternList = await this.getIndexPatternList();
return indexPatternList.length === 0;
}
Expand Down Expand Up @@ -629,23 +634,33 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider
}

async checkImportSucceeded() {
await testSubjects.existOrFail('importSavedObjectsSuccess', { timeout: 20000 });
await testSubjects.existOrFail('importSavedObjectsSuccess', {
timeout: config.get('timeouts.waitForExits') * 10,
});
}

async checkNoneImported() {
await testSubjects.existOrFail('importSavedObjectsSuccessNoneImported', { timeout: 20000 });
await testSubjects.existOrFail('importSavedObjectsSuccessNoneImported', {
timeout: config.get('timeouts.waitForExits') * 10,
});
}

async checkImportConflictsWarning() {
await testSubjects.existOrFail('importSavedObjectsConflictsWarning', { timeout: 20000 });
await testSubjects.existOrFail('importSavedObjectsConflictsWarning', {
timeout: config.get('timeouts.waitForExits') * 10,
});
}

async checkImportLegacyWarning() {
await testSubjects.existOrFail('importSavedObjectsLegacyWarning', { timeout: 20000 });
await testSubjects.existOrFail('importSavedObjectsLegacyWarning', {
timeout: config.get('timeouts.waitForExits') * 10,
});
}

async checkImportFailedWarning() {
await testSubjects.existOrFail('importSavedObjectsFailedWarning', { timeout: 20000 });
await testSubjects.existOrFail('importSavedObjectsFailedWarning', {
timeout: config.get('timeouts.waitForExits') * 10,
});
}

async clickImportDone() {
Expand Down
5 changes: 4 additions & 1 deletion test/functional/page_objects/time_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function TimePickerPageProvider({ getService, getPageObjects }) {
const log = getService('log');
const retry = getService('retry');
const find = getService('find');
const config = getService('config');
const browser = getService('browser');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['header', 'common']);
Expand Down Expand Up @@ -157,7 +158,9 @@ export function TimePickerPageProvider({ getService, getPageObjects }) {

async showStartEndTimes() {
// This first await makes sure the superDatePicker has loaded before we check for the ShowDatesButton
await testSubjects.exists('superDatePickerToggleQuickMenuButton', { timeout: 20000 });
await testSubjects.exists('superDatePickerToggleQuickMenuButton', {
timeout: config.get('timeouts.waitForExits') * 10,
});
const isShowDatesButton = await testSubjects.exists('superDatePickerShowDatesButton');
if (isShowDatesButton) {
await testSubjects.click('superDatePickerShowDatesButton');
Expand Down
13 changes: 10 additions & 3 deletions test/functional/page_objects/visual_builder_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro
const find = getService('find');
const log = getService('log');
const retry = getService('retry');
const config = getService('config');
const testSubjects = getService('testSubjects');
const comboBox = getService('comboBox');
const PageObjects = getPageObjects(['common', 'header', 'visualize', 'timePicker', 'visChart']);
Expand Down Expand Up @@ -54,7 +55,9 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro
}

public async checkTabIsLoaded(testSubj: string, name: string) {
const isPresent = await testSubjects.exists(testSubj, { timeout: 10000 });
const isPresent = await testSubjects.exists(testSubj, {
timeout: config.get('timeouts.waitForExits') * 5,
});
if (!isPresent) {
throw new Error(`TSVB ${name} tab is not loaded`);
}
Expand Down Expand Up @@ -503,7 +506,9 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro

public async checkColorPickerPopUpIsPresent(): Promise<void> {
log.debug(`Check color picker popup is present`);
await testSubjects.existOrFail('tvbColorPickerPopUp', { timeout: 5000 });
await testSubjects.existOrFail('tvbColorPickerPopUp', {
timeout: config.get('timeouts.waitForExits') * 2,
});
}

public async changePanelPreview(nth: number = 0): Promise<void> {
Expand All @@ -515,7 +520,9 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro

public async checkPreviewIsDisabled(): Promise<void> {
log.debug(`Check no data message is present`);
await testSubjects.existOrFail('noTSVBDataMessage', { timeout: 5000 });
await testSubjects.existOrFail('noTSVBDataMessage', {
timeout: config.get('timeouts.waitForExits') * 2,
});
}

public async cloneSeries(nth: number = 0): Promise<void> {
Expand Down
5 changes: 4 additions & 1 deletion test/functional/page_objects/visualize_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { VisualizeConstants } from '../../../src/legacy/core_plugins/kibana/publ

export function VisualizePageProvider({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const config = getService('config');
const retry = getService('retry');
const find = getService('find');
const log = getService('log');
Expand Down Expand Up @@ -216,7 +217,9 @@ export function VisualizePageProvider({ getService, getPageObjects }: FtrProvide
public async ensureSavePanelOpen() {
log.debug('ensureSavePanelOpen');
await header.waitUntilLoadingHasFinished();
const isOpen = await testSubjects.exists('savedObjectSaveModal', { timeout: 5000 });
const isOpen = await testSubjects.exists('savedObjectSaveModal', {
timeout: config.get('timeouts.waitForExits') * 2,
});
if (!isOpen) {
await testSubjects.click('visualizeSaveButton');
}
Expand Down
12 changes: 10 additions & 2 deletions test/functional/services/flyout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { FtrProviderContext } from '../ftr_provider_context';

export function FlyoutProvider({ getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const config = getService('config');
const find = getService('find');
const log = getService('log');
const retry = getService('retry');
Expand All @@ -33,12 +34,19 @@ export function FlyoutProvider({ getService }: FtrProviderContext) {
await closeBtn.click();
await retry.waitFor(
'flyout closed',
async () => !(await testSubjects.exists(dataTestSubj, { timeout: 1000 }))
async () =>
!(await testSubjects.exists(dataTestSubj, {
timeout: config.get('timeouts.waitForExits') * 0.4,
}))
);
}

public async ensureClosed(dataTestSubj: string): Promise<void> {
if (await testSubjects.exists(dataTestSubj, { timeout: 1000 })) {
if (
await testSubjects.exists(dataTestSubj, {
timeout: config.get('timeouts.waitForExits') * 0.4,
})
) {
await this.close(dataTestSubj);
}
}
Expand Down
4 changes: 3 additions & 1 deletion test/plugin_functional/test_suites/core_plugins/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ declare global {
export default function({ getService, getPageObjects }: PluginFunctionalProviderContext) {
const PageObjects = getPageObjects(['common']);
const appsMenu = getService('appsMenu');
const config = getService('config');
const browser = getService('browser');
const find = getService('find');
const testSubjects = getService('testSubjects');
Expand All @@ -62,7 +63,8 @@ export default function({ getService, getPageObjects }: PluginFunctionalProvider
return JSON.parse(document.querySelector('kbn-injected-metadata')!.getAttribute('data')!)
.legacyMetadata.uiSettings.user;
});
const exists = (selector: string) => testSubjects.exists(selector, { timeout: 5000 });
const exists = (selector: string) =>
testSubjects.exists(selector, { timeout: config.get('timeouts.waitForExits') * 2 });
const findLoadingMessage = () => testSubjects.find('kbnLoadingMessage', 5000);
const getRenderingSession = () =>
browser.execute(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
const appsMenu = getService('appsMenu');
const testSubjects = getService('testSubjects');
const globalNav = getService('globalNav');
const config = getService('config');

describe('security feature controls', () => {
before(async () => {
Expand Down Expand Up @@ -184,7 +185,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
shouldLoginIfPrompted: false,
});
await testSubjects.existOrFail('managementHome', {
timeout: 10000,
timeout: config.get('timeouts.waitForExits') * 5,
});
});
});
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({ getPageObjects, getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const security = getService('security');
const config = getService('config');
const PageObjects = getPageObjects(['common', 'error', 'security']);
const testSubjects = getService('testSubjects');
const appsMenu = getService('appsMenu');
Expand Down Expand Up @@ -66,7 +67,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
it('can navigate to APM app', async () => {
await PageObjects.common.navigateToApp('apm');
await testSubjects.existOrFail('apmMainContainer', {
timeout: 10000,
timeout: config.get('timeouts.waitForExits') * 5,
});
});

Expand Down Expand Up @@ -115,7 +116,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
it('can navigate to APM app', async () => {
await PageObjects.common.navigateToApp('apm');
await testSubjects.existOrFail('apmMainContainer', {
timeout: 10000,
timeout: config.get('timeouts.waitForExits') * 5,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';

export default function({ getPageObjects, getService }: FtrProviderContext) {
const spacesService = getService('spaces');
const config = getService('config');
const PageObjects = getPageObjects(['common', 'error', 'timePicker', 'security', 'settings']);
const testSubjects = getService('testSubjects');
const appsMenu = getService('appsMenu');
Expand Down Expand Up @@ -38,7 +39,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
it('can navigate to Uptime app', async () => {
await PageObjects.common.navigateToApp('apm');
await testSubjects.existOrFail('apmMainContainer', {
timeout: 10000,
timeout: config.get('timeouts.waitForExits') * 5,
});
});
});
Expand Down
Loading

0 comments on commit 8b843d0

Please sign in to comment.