Skip to content

Commit 3a61f16

Browse files
authored
[Lens] Fix slow tests (#244754)
## Summary Speeding up some Function tests by: - removing announcements like tour/etc - reducing the timeout used to verify and activate the new Lens layer as tabs `x-pack/platform/test/functional/apps/lens/group4/config.ts` Ran in 40m 31s from the current 48.8 minutes `x-pack/platform/test/functional/apps/lens/group7/config.ts` Ran in 47m 40s from the current 94.4 minutes fix #244773
1 parent 7d18f7b commit 3a61f16

File tree

9 files changed

+60
-72
lines changed

9 files changed

+60
-72
lines changed

x-pack/platform/test/functional/apps/lens/group4/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext
5858
await kibanaServer.uiSettings.update({
5959
defaultIndex: indexPatternString,
6060
'dateFormat:tz': 'UTC',
61+
hideAnnouncements: true,
6162
});
6263
await kibanaServer.importExport.load(fixtureDirs.lensBasic);
6364
await kibanaServer.importExport.load(fixtureDirs.lensDefault);

x-pack/platform/test/functional/apps/lens/group4/tsdb.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
5757
'dateFormat:tz': 'UTC',
5858
defaultIndex: '0ae0bc7a-e4ca-405c-ab67-f2b5913f2a51',
5959
'timepicker:timeDefaults': `{ "from": "${fromTime}", "to": "${toTime}" }`,
60+
hideAnnouncements: true,
6061
});
6162
});
6263

@@ -92,6 +93,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
9293
describe('for regular metric', () => {
9394
it('defaults to median for non-rolled up metric', async () => {
9495
await common.navigateToApp('lens');
96+
await lens.switchDataPanelIndexPattern(tsdbDataView);
9597
await lens.waitForField('bytes_gauge');
9698
await lens.dragFieldToWorkspace('bytes_gauge', 'xyVisChart');
9799
expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql(
@@ -198,22 +200,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
198200
keepOpen: true,
199201
});
200202

201-
// now check if the provided function has no incompatibility tooltip
202203
for (const supportedOp of supportedOperations) {
204+
// now check if the provided function has no incompatibility tooltip
203205
expect(
204206
testSubjects.exists(`lns-indexPatternDimension-${supportedOp.name} incompatible`, {
205207
timeout: 500,
206208
})
207209
).to.eql(supportedOp[fieldType]);
208-
}
209-
210-
for (const supportedOp of supportedOperations) {
211210
// try to change to the provided function and check all is ok
212211
await lens.selectOperation(supportedOp.name);
213212

214213
expect(
215214
await find.existsByCssSelector(
216-
'[data-test-subj="indexPattern-field-selection-row"] .euiFormErrorText'
215+
'[data-test-subj="indexPattern-field-selection-row"] .euiFormErrorText',
216+
500
217217
)
218218
).to.be(false);
219219

@@ -240,8 +240,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
240240
keepOpen: true,
241241
});
242242

243-
// now check if the provided function has the incompatibility tooltip
244243
for (const unsupportedOp of unsupportedOperatons) {
244+
// now check if the provided function has the incompatibility tooltip
245245
expect(
246246
testSubjects.exists(
247247
`lns-indexPatternDimension-${unsupportedOp.name} incompatible`,
@@ -250,14 +250,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
250250
}
251251
)
252252
).to.eql(!unsupportedOp[fieldType]);
253-
}
254-
255-
for (const unsupportedOp of unsupportedOperatons) {
256253
// try to change to the provided function and check if it's in an incompatibility state
257254
await lens.selectOperation(unsupportedOp.name, true);
258255

259256
const fieldSelectErrorEl = await find.byCssSelector(
260-
'[data-test-subj="indexPattern-field-selection-row"] .euiFormErrorText'
257+
'[data-test-subj="indexPattern-field-selection-row"] .euiFormErrorText',
258+
500
261259
);
262260

263261
expect(await fieldSelectErrorEl.getVisibleText()).to.be(

x-pack/platform/test/functional/apps/lens/group7/esql.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
2929

3030
const defaultSettings = {
3131
defaultIndex: 'logstash-*',
32+
hideAnnouncements: true,
3233
};
3334

3435
describe('lens ES|QL tests', () => {

x-pack/platform/test/functional/apps/lens/group7/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext
1717
const config = getService('config');
1818
let remoteEsArchiver;
1919

20-
describe('lens app - group 4', () => {
20+
describe('lens app - group 7', () => {
2121
const esArchive = 'x-pack/platform/test/fixtures/es_archives/logstash_functional';
2222
const localIndexPatternString = 'logstash-*';
2323
const remoteIndexPatternString = 'ftr-remote:logstash-*';
@@ -58,6 +58,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext
5858
await kibanaServer.uiSettings.update({
5959
defaultIndex: indexPatternString,
6060
'dateFormat:tz': 'UTC',
61+
hideAnnouncements: true,
6162
});
6263
await kibanaServer.importExport.load(fixtureDirs.lensBasic);
6364
await kibanaServer.importExport.load(fixtureDirs.lensDefault);
@@ -71,8 +72,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext
7172
await kibanaServer.savedObjects.cleanStandardList();
7273
});
7374

74-
// total run time ~30m
75-
loadTestFile(require.resolve('./logsdb')); // 30m
75+
loadTestFile(require.resolve('./logsdb')); // 43m
7676
loadTestFile(require.resolve('./esql'));
7777
});
7878
};

x-pack/platform/test/functional/apps/lens/group7/logsdb.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
6161
'dateFormat:tz': 'UTC',
6262
defaultIndex: '0ae0bc7a-e4ca-405c-ab67-f2b5913f2a51',
6363
'timepicker:timeDefaults': `{ "from": "${fromTime}", "to": "${toTime}" }`,
64+
hideAnnouncements: true,
6465
});
6566
});
6667

@@ -116,22 +117,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
116117
keepOpen: true,
117118
});
118119

119-
// now check that operations won't show the incompatibility tooltip
120120
for (const operation of allOperations) {
121+
// now check that operations won't show the incompatibility tooltip
121122
expect(
122123
testSubjects.exists(`lns-indexPatternDimension-${operation} incompatible`, {
123124
timeout: 500,
124125
})
125126
).to.eql(false);
126-
}
127-
128-
for (const operation of allOperations) {
129127
// try to change to the provided function and check all is ok
130128
await lens.selectOperation(operation);
131129

132130
expect(
133131
await find.existsByCssSelector(
134-
'[data-test-subj="indexPattern-field-selection-row"] .euiFormErrorText'
132+
'[data-test-subj="indexPattern-field-selection-row"] .euiFormErrorText',
133+
500
135134
)
136135
).to.be(false);
137136
}
@@ -225,8 +224,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
225224

226225
runTestsForEachScenario(streamConvertedToLogsDBIndex, 'logsdb', (indexes) => {
227226
it(`should visualize a date histogram chart`, async () => {
228-
await lens.ensureLayerTabIsActive();
229-
230227
await lens.configureDimension({
231228
dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension',
232229
operation: 'date_histogram',
@@ -253,8 +250,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
253250
});
254251

255252
it(`should visualize a date histogram chart using a different date field`, async () => {
256-
await lens.ensureLayerTabIsActive();
257-
258253
await lens.configureDimension({
259254
dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension',
260255
operation: 'date_histogram',
@@ -281,8 +276,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
281276
});
282277

283278
it('should visualize an annotation layer from a logsDB stream', async () => {
284-
await lens.ensureLayerTabIsActive();
285-
286279
await lens.configureDimension({
287280
dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension',
288281
operation: 'date_histogram',
@@ -320,8 +313,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
320313
});
321314

322315
it('should visualize an annotation layer from a logsDB stream using another time field', async () => {
323-
await lens.ensureLayerTabIsActive();
324-
325316
await lens.configureDimension({
326317
dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension',
327318
operation: 'date_histogram',
@@ -429,8 +420,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
429420

430421
runTestsForEachScenario(logsdbConvertedToStream, 'logsdb', (indexes) => {
431422
it(`should visualize a date histogram chart`, async () => {
432-
await lens.ensureLayerTabIsActive();
433-
434423
await lens.configureDimension({
435424
dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension',
436425
operation: 'date_histogram',
@@ -457,8 +446,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
457446
});
458447

459448
it(`should visualize a date histogram chart using a different date field`, async () => {
460-
await lens.ensureLayerTabIsActive();
461-
462449
await lens.configureDimension({
463450
dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension',
464451
operation: 'date_histogram',
@@ -485,8 +472,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
485472
});
486473

487474
it('should visualize an annotation layer from a logsDB stream', async () => {
488-
await lens.ensureLayerTabIsActive();
489-
490475
await lens.configureDimension({
491476
dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension',
492477
operation: 'date_histogram',
@@ -524,8 +509,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
524509
});
525510

526511
it('should visualize an annotation layer from a logsDB stream using another time field', async () => {
527-
await lens.ensureLayerTabIsActive();
528-
529512
await lens.configureDimension({
530513
dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension',
531514
operation: 'date_histogram',

x-pack/platform/test/functional/apps/lens/tsdb_logsdb_helpers.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,12 @@ export function setupScenarioRunner(
451451
);
452452
});
453453

454+
beforeEach(async () => {
455+
await lens.switchDataPanelIndexPattern(dataViewName);
456+
await lens.removeLayer();
457+
await lens.ensureLayerTabIsActive();
458+
});
459+
454460
after(async () => {
455461
for (const { index, create, mode: indexMode } of indexes) {
456462
if (create) {
@@ -468,12 +474,6 @@ export function setupScenarioRunner(
468474
}
469475
});
470476

471-
beforeEach(async () => {
472-
await lens.switchDataPanelIndexPattern(dataViewName);
473-
await lens.removeLayer();
474-
await lens.ensureLayerTabIsActive();
475-
});
476-
477477
testingFn(indexes);
478478
});
479479
}

x-pack/platform/test/functional/page_objects/lens_page.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,16 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
195195
disableEmptyRows?: boolean;
196196
}) {
197197
await retry.try(async () => {
198-
if (!(await testSubjects.exists('lns-indexPattern-dimensionContainerClose'))) {
198+
if (
199+
!(await testSubjects.exists('lns-indexPattern-dimensionContainerClose', {
200+
timeout: 1000,
201+
}))
202+
) {
199203
await testSubjects.click(opts.dimension);
200204
}
201-
await testSubjects.existOrFail('lns-indexPattern-dimensionContainerClose');
205+
await testSubjects.existOrFail('lns-indexPattern-dimensionContainerClose', {
206+
timeout: 1000,
207+
});
202208
});
203209

204210
if (opts.operation === 'formula') {
@@ -579,7 +585,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
579585
async openDimensionEditor(dimension: string, layerIndex = 0, dimensionIndex = 0) {
580586
await retry.try(async () => {
581587
const dimensionEditor = (
582-
await testSubjects.findAll(`lns-layerPanel-${layerIndex} > ${dimension}`)
588+
await testSubjects.findAll(`lns-layerPanel-${layerIndex} > ${dimension}`, 1000)
583589
)[dimensionIndex];
584590
await dimensionEditor.click();
585591
});
@@ -591,7 +597,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
591597
async performLayerAction(testSubject: string, layerIndex = 0) {
592598
await retry.try(async () => {
593599
// Hover over the tab to make the layer actions button visible
594-
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]');
600+
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]', 1000);
595601
if (tabs[layerIndex]) {
596602
await tabs[layerIndex].moveMouseTo();
597603
}
@@ -1120,12 +1126,13 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
11201126
seriesType = 'bar'
11211127
) {
11221128
await testSubjects.click('lnsLayerAddButton');
1123-
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]');
1129+
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]', 1000);
11241130
const layerCount = tabs.length;
11251131

11261132
await retry.waitFor('check for layer type support', async () => {
11271133
const fasterChecks = await Promise.all([
1128-
(await find.allByCssSelector(`[data-test-subj^="lns-layerPanel-"]`)).length > layerCount,
1134+
(await find.allByCssSelector(`[data-test-subj^="lns-layerPanel-"]`, 1000)).length >
1135+
layerCount,
11291136
testSubjects.exists(`lnsLayerAddButton-${layerType}`),
11301137
]);
11311138
return fasterChecks.filter(Boolean).length > 0;
@@ -1152,7 +1159,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
11521159
async duplicateLayer(index: number = 0) {
11531160
await retry.try(async () => {
11541161
// Hover over the tab to make the layer actions button visible
1155-
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]');
1162+
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]', 1000);
11561163
if (tabs[index]) {
11571164
await tabs[index].moveMouseTo();
11581165
}
@@ -1419,7 +1426,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
14191426

14201427
async openLayerContextMenu(index: number = 0) {
14211428
// Hover over the tab to make the layer actions button visible
1422-
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]');
1429+
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]', 1000);
14231430
if (tabs[index]) {
14241431
await tabs[index].moveMouseTo();
14251432
}
@@ -1675,7 +1682,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
16751682
async removeLayer(index: number = 0) {
16761683
await retry.try(async () => {
16771684
// Hover over the tab to make the layer actions button visible
1678-
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]');
1685+
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]', 1000);
16791686
if (tabs[index]) {
16801687
await tabs[index].moveMouseTo();
16811688
}
@@ -1691,25 +1698,25 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
16911698
},
16921699

16931700
async ensureLayerTabIsActive(index: number = 0) {
1694-
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]');
1701+
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]', 1000);
16951702
if (tabs[index]) {
16961703
await tabs[index].click(); // Click to make it active
16971704
// Wait for the layer panel to render
16981705
await retry.waitFor('layer panel to be visible', async () => {
1699-
return await testSubjects.exists(`lns-layerPanel-${index}`);
1706+
return await testSubjects.exists(`lns-layerPanel-${index}`, { timeout: 1000 });
17001707
});
17011708
}
17021709
},
17031710

17041711
async ensureLayerTabWithNameIsActive(name: string) {
1705-
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]');
1712+
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]', 1000);
17061713
for (let i = 0; i < tabs.length; i++) {
17071714
const tabText = await tabs[i].getVisibleText();
17081715
if (tabText === name) {
17091716
await tabs[i].click(); // Click to make it active
17101717
// Wait for the layer panel to render
17111718
await retry.waitFor('layer panel to be visible', async () => {
1712-
return await testSubjects.exists(`lns-layerPanel-${i}`);
1719+
return await testSubjects.exists(`lns-layerPanel-${i}`, { timeout: 1000 });
17131720
});
17141721
return;
17151722
}
@@ -1719,10 +1726,10 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
17191726

17201727
async assertLayerCount(expectedCount: number) {
17211728
// Inside the tab content there should be one panel
1722-
const layerPanels = await find.allByCssSelector('[data-test-subj^="lns-layerPanel-"]');
1729+
const layerPanels = await find.allByCssSelector('[data-test-subj^="lns-layerPanel-"]', 1000);
17231730
expect(layerPanels.length).to.eql(1);
17241731

1725-
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]');
1732+
const tabs = await find.allByCssSelector('[data-test-subj^="unifiedTabs_tab_"]', 1000);
17261733

17271734
// tabs will hidden if there's just one layer
17281735
if (expectedCount <= 1) {

0 commit comments

Comments
 (0)