From 09c11131271bec1b794d5a472294e6e125116f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Tue, 24 Jan 2023 15:03:37 +0100 Subject: [PATCH] [FTRs] Execution Context: fix no data flakiness (#149406) Resolves https://github.com/elastic/kibana/issues/112102 --- .../tests/browser.ts | 520 ++++++++++-------- 1 file changed, 283 insertions(+), 237 deletions(-) diff --git a/x-pack/test/functional_execution_context/tests/browser.ts b/x-pack/test/functional_execution_context/tests/browser.ts index 1265fa205f7bc..085fae8ed0d6a 100644 --- a/x-pack/test/functional_execution_context/tests/browser.ts +++ b/x-pack/test/functional_execution_context/tests/browser.ts @@ -10,7 +10,7 @@ import type { FtrProviderContext } from '../ftr_provider_context'; import { assertLogContains, forceSyncLogFile, isExecutionContextLog } from '../test_utils'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'home']); + const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'home', 'timePicker']); const retry = getService('retry'); describe('Browser apps', () => { @@ -33,6 +33,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('discover app', () => { before(async () => { await PageObjects.common.navigateToApp('discover'); + await PageObjects.timePicker.setCommonlyUsedTime('Last_7 days'); await PageObjects.header.waitUntilLoadingHasFinished(); await forceSyncLogFile(); }); @@ -48,56 +49,62 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); } - it('propagates context for Discover', async () => { - await assertLogContains({ - description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', - predicate: (record) => - Boolean(record.http?.request?.id?.includes('kibana:application:discover')), - retry, + describe('propagates context for Discover', () => { + it('propagates to Elasticsearch via "x-opaque-id" header', async () => { + await assertLogContains({ + description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', + predicate: (record) => + Boolean(record.http?.request?.id?.includes('kibana:application:discover')), + retry, + }); }); - await assertLogContains({ - description: 'execution context propagates to Kibana logs (fetch documents)', - predicate: checkExecutionContextEntry({ - type: 'application', - name: 'discover', - url: '/app/discover', - child: { + it('propagates to Kibana logs (fetch documents)', async () => { + await assertLogContains({ + description: 'execution context propagates to Kibana logs (fetch documents)', + predicate: checkExecutionContextEntry({ + type: 'application', name: 'discover', url: '/app/discover', - type: 'application', - page: 'app', - id: 'new', - description: 'fetch documents', - }, - }), - retry, + child: { + name: 'discover', + url: '/app/discover', + type: 'application', + page: 'app', + id: 'new', + description: 'fetch documents', + }, + }), + retry, + }); }); - await assertLogContains({ - description: - 'execution context propagates to Kibana logs (fetch chart data and total hits)', - predicate: checkExecutionContextEntry({ - type: 'application', - name: 'discover', - url: '/app/discover', - child: { + it('propagates to Kibana logs (fetch chart data and total hits)', async () => { + await assertLogContains({ + description: + 'execution context propagates to Kibana logs (fetch chart data and total hits)', + predicate: checkExecutionContextEntry({ + type: 'application', name: 'discover', url: '/app/discover', - type: 'application', - page: 'app', - id: 'new', - description: 'fetch chart data and total hits', child: { - type: 'lens', - name: 'lnsXY', - id: 'unifiedHistogramLensComponent', - description: 'Edit visualization', - url: '/app/lens#/edit_by_value', + name: 'discover', + url: '/app/discover', + type: 'application', + page: 'app', + id: 'new', + description: 'fetch chart data and total hits', + child: { + type: 'lens', + name: 'lnsXY', + id: 'unifiedHistogramLensComponent', + description: 'Edit visualization', + url: '/app/lens#/edit_by_value', + }, }, - }, - }), - retry, + }), + retry, + }); }); }); }); @@ -106,6 +113,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => { await PageObjects.common.navigateToApp('dashboard'); await PageObjects.dashboard.loadSavedDashboard('[Flights] Global Flight Dashboard'); + await PageObjects.timePicker.setCommonlyUsedTime('Last_7 days'); await PageObjects.dashboard.waitForRenderComplete(); await PageObjects.header.waitUntilLoadingHasFinished(); await forceSyncLogFile(); @@ -156,15 +164,175 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } describe('propagates context for Lens visualizations', () => { - it('lnsXY', async () => { + describe('lnsXY', () => { + it('propagates to Elasticsearch via "x-opaque-id" header', async () => { + await assertLogContains({ + description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', + predicate: checkHttpRequestId( + 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;lens:lnsXY:086ac2e9-dd16-4b45-92b8-1e43ff7e3f65' + ), + retry, + }); + }); + + it('propagates to Kibana logs', async () => { + await assertLogContains({ + description: 'execution context propagates to Kibana logs', + predicate: checkExecutionContextEntry({ + type: 'application', + name: 'dashboards', + url: '/app/dashboards', + child: { + name: 'dashboards', + url: '/app/dashboards', + type: 'dashboard', + page: 'app', + id: '7adfa750-4c81-11e8-b3d7-01146121b73d', + description: '[Flights] Global Flight Dashboard', + child: { + type: 'lens', + name: 'lnsXY', + id: '086ac2e9-dd16-4b45-92b8-1e43ff7e3f65', + description: '[Flights] Flight count', + url: '/app/lens#/edit_by_value', + }, + }, + }), + retry, + }); + }); + }); + + describe('lnsMetric', () => { + it('propagates to Elasticsearch via "x-opaque-id" header', async () => { + await assertLogContains({ + description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', + predicate: checkHttpRequestId( + 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;lens:lnsLegacyMetric:b766e3b8-4544-46ed-99e6-9ecc4847e2a2' + ), + retry, + }); + }); + + it('propagates to Kibana logs', async () => { + await assertLogContains({ + description: 'execution context propagates to Kibana logs', + predicate: checkExecutionContextEntry({ + name: 'dashboards', + url: '/app/dashboards', + type: 'application', + child: { + name: 'dashboards', + url: '/app/dashboards', + type: 'dashboard', + page: 'app', + id: '7adfa750-4c81-11e8-b3d7-01146121b73d', + description: '[Flights] Global Flight Dashboard', + child: { + type: 'lens', + name: 'lnsLegacyMetric', + id: 'b766e3b8-4544-46ed-99e6-9ecc4847e2a2', + description: '', + url: '/app/lens#/edit_by_value', + }, + }, + }), + retry, + }); + }); + }); + + describe('lnsDatatable', () => { + it('propagates to Elasticsearch via "x-opaque-id" header', async () => { + await assertLogContains({ + description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', + predicate: checkHttpRequestId( + 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;lens:lnsDatatable:fb86b32f-fb7a-45cf-9511-f366fef51bbd' + ), + retry, + }); + }); + + it('propagates to Kibana logs', async () => { + await assertLogContains({ + description: 'execution context propagates to Kibana logs', + predicate: checkExecutionContextEntry({ + name: 'dashboards', + url: '/app/dashboards', + type: 'application', + child: { + name: 'dashboards', + url: '/app/dashboards', + type: 'dashboard', + page: 'app', + id: '7adfa750-4c81-11e8-b3d7-01146121b73d', + description: '[Flights] Global Flight Dashboard', + child: { + type: 'lens', + name: 'lnsDatatable', + id: 'fb86b32f-fb7a-45cf-9511-f366fef51bbd', + description: 'Cities by delay, cancellation', + url: '/app/lens#/edit_by_value', + }, + }, + }), + retry, + }); + }); + }); + + describe('lnsPie', () => { + it('propagates to Elasticsearch via "x-opaque-id" header', async () => { + await assertLogContains({ + description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', + predicate: checkHttpRequestId( + 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;lens:lnsPie:5d53db36-2d5a-4adc-af7b-cec4c1a294e0' + ), + retry, + }); + }); + + it('propagates to Kibana logs', async () => { + await assertLogContains({ + description: 'execution context propagates to Kibana logs', + predicate: checkExecutionContextEntry({ + name: 'dashboards', + url: '/app/dashboards', + type: 'application', + child: { + name: 'dashboards', + url: '/app/dashboards', + type: 'dashboard', + page: 'app', + id: '7adfa750-4c81-11e8-b3d7-01146121b73d', + description: '[Flights] Global Flight Dashboard', + child: { + type: 'lens', + name: 'lnsPie', + id: '5d53db36-2d5a-4adc-af7b-cec4c1a294e0', + description: '[Flights] Delay Type', + url: '/app/lens#/edit_by_value', + }, + }, + }), + retry, + }); + }); + }); + }); + + describe('propagates context for built-in Discover', () => { + it('propagates to Elasticsearch via "x-opaque-id" header', async () => { await assertLogContains({ description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', predicate: checkHttpRequestId( - 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;lens:lnsXY:086ac2e9-dd16-4b45-92b8-1e43ff7e3f65' + 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;search:discover:571aaf70-4c88-11e8-b3d7-01146121b73d' ), retry, }); + }); + it('propagates to Kibana logs', async () => { await assertLogContains({ description: 'execution context propagates to Kibana logs', predicate: checkExecutionContextEntry({ @@ -172,69 +340,69 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { name: 'dashboards', url: '/app/dashboards', child: { + type: 'dashboard', name: 'dashboards', url: '/app/dashboards', - type: 'dashboard', page: 'app', id: '7adfa750-4c81-11e8-b3d7-01146121b73d', description: '[Flights] Global Flight Dashboard', child: { - type: 'lens', - name: 'lnsXY', - id: '086ac2e9-dd16-4b45-92b8-1e43ff7e3f65', - description: '[Flights] Flight count', - url: '/app/lens#/edit_by_value', + type: 'search', + name: 'discover', + id: '571aaf70-4c88-11e8-b3d7-01146121b73d', + description: '[Flights] Flight Log', + url: '/app/discover#/view/571aaf70-4c88-11e8-b3d7-01146121b73d', }, }, }), retry, }); }); + }); - it('lnsMetric', async () => { + describe('propagates context for TSVB visualizations', () => { + it('propagates to Elasticsearch via "x-opaque-id" header', async () => { await assertLogContains({ description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', - predicate: checkHttpRequestId( - 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;lens:lnsLegacyMetric:b766e3b8-4544-46ed-99e6-9ecc4847e2a2' - ), + predicate: checkHttpRequestId('agg_based:metrics:bcb63b50-4c89-11e8-b3d7-01146121b73d'), retry, }); + }); + it('propagates to Kibana logs', async () => { await assertLogContains({ description: 'execution context propagates to Kibana logs', predicate: checkExecutionContextEntry({ name: 'dashboards', url: '/app/dashboards', type: 'application', + page: 'app', + description: '[Flights] Global Flight Dashboard', child: { - name: 'dashboards', - url: '/app/dashboards', - type: 'dashboard', - page: 'app', - id: '7adfa750-4c81-11e8-b3d7-01146121b73d', - description: '[Flights] Global Flight Dashboard', - child: { - type: 'lens', - name: 'lnsLegacyMetric', - id: 'b766e3b8-4544-46ed-99e6-9ecc4847e2a2', - description: '', - url: '/app/lens#/edit_by_value', - }, + type: 'agg_based', + name: 'metrics', + id: 'bcb63b50-4c89-11e8-b3d7-01146121b73d', + description: '[Flights] Delays & Cancellations', + url: '/app/visualize#/edit/bcb63b50-4c89-11e8-b3d7-01146121b73d', }, }), retry, }); }); + }); - it('lnsDatatable', async () => { + describe('propagates context for Vega visualizations', () => { + it('propagates to Elasticsearch via "x-opaque-id" header', async () => { await assertLogContains({ description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', predicate: checkHttpRequestId( - 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;lens:lnsDatatable:fb86b32f-fb7a-45cf-9511-f366fef51bbd' + 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;agg_based:vega:ed78a660-53a0-11e8-acbd-0be0ad9d822b' ), retry, }); + }); + it('propagates to Kibana logs', async () => { await assertLogContains({ description: 'execution context propagates to Kibana logs', predicate: checkExecutionContextEntry({ @@ -249,26 +417,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { id: '7adfa750-4c81-11e8-b3d7-01146121b73d', description: '[Flights] Global Flight Dashboard', child: { - type: 'lens', - name: 'lnsDatatable', - id: 'fb86b32f-fb7a-45cf-9511-f366fef51bbd', - description: 'Cities by delay, cancellation', - url: '/app/lens#/edit_by_value', + type: 'agg_based', + name: 'vega', + id: 'ed78a660-53a0-11e8-acbd-0be0ad9d822b', + description: '[Flights] Airport Connections (Hover Over Airport)', + url: '/app/visualize#/edit/ed78a660-53a0-11e8-acbd-0be0ad9d822b', }, }, }), retry, }); }); + }); - it('lnsPie', async () => { + describe('propagates context for Tag Cloud visualization', () => { + it('propagates to Elasticsearch via "x-opaque-id" header', async () => { await assertLogContains({ description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', predicate: checkHttpRequestId( - 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;lens:lnsPie:5d53db36-2d5a-4adc-af7b-cec4c1a294e0' + 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;agg_based:tagcloud:293b5a30-4c8f-11e8-b3d7-01146121b73d' ), retry, }); + }); + + it('propagates to Kibana logs', async () => { await assertLogContains({ description: 'execution context propagates to Kibana logs', predicate: checkExecutionContextEntry({ @@ -283,11 +456,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { id: '7adfa750-4c81-11e8-b3d7-01146121b73d', description: '[Flights] Global Flight Dashboard', child: { - type: 'lens', - name: 'lnsPie', - id: '5d53db36-2d5a-4adc-af7b-cec4c1a294e0', - description: '[Flights] Delay Type', - url: '/app/lens#/edit_by_value', + type: 'agg_based', + name: 'tagcloud', + id: '293b5a30-4c8f-11e8-b3d7-01146121b73d', + description: '[Flights] Destination Weather', + url: '/app/visualize#/edit/293b5a30-4c8f-11e8-b3d7-01146121b73d', }, }, }), @@ -296,169 +469,42 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); }); - it('propagates context for built-in Discover', async () => { - await assertLogContains({ - description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', - predicate: checkHttpRequestId( - 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;search:discover:571aaf70-4c88-11e8-b3d7-01146121b73d' - ), - retry, - }); - await assertLogContains({ - description: 'execution context propagates to Kibana logs', - predicate: checkExecutionContextEntry({ - type: 'application', - name: 'dashboards', - url: '/app/dashboards', - child: { - type: 'dashboard', - name: 'dashboards', - url: '/app/dashboards', - page: 'app', - id: '7adfa750-4c81-11e8-b3d7-01146121b73d', - description: '[Flights] Global Flight Dashboard', - child: { - type: 'search', - name: 'discover', - id: '571aaf70-4c88-11e8-b3d7-01146121b73d', - description: '[Flights] Flight Log', - url: '/app/discover#/view/571aaf70-4c88-11e8-b3d7-01146121b73d', - }, - }, - }), - retry, - }); - }); - - it('propagates context for TSVB visualizations', async () => { - await assertLogContains({ - description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', - predicate: checkHttpRequestId('agg_based:metrics:bcb63b50-4c89-11e8-b3d7-01146121b73d'), - retry, - }); - - await assertLogContains({ - description: 'execution context propagates to Kibana logs', - predicate: checkExecutionContextEntry({ - name: 'dashboards', - url: '/app/dashboards', - type: 'application', - page: 'app', - description: '[Flights] Global Flight Dashboard', - child: { - type: 'agg_based', - name: 'metrics', - id: 'bcb63b50-4c89-11e8-b3d7-01146121b73d', - description: '[Flights] Delays & Cancellations', - url: '/app/visualize#/edit/bcb63b50-4c89-11e8-b3d7-01146121b73d', - }, - }), - retry, - }); - }); - - it('propagates context for Vega visualizations', async () => { - await assertLogContains({ - description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', - predicate: checkHttpRequestId( - 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;agg_based:vega:ed78a660-53a0-11e8-acbd-0be0ad9d822b' - ), - retry, - }); - - await assertLogContains({ - description: 'execution context propagates to Kibana logs', - predicate: checkExecutionContextEntry({ - name: 'dashboards', - url: '/app/dashboards', - type: 'application', - child: { - name: 'dashboards', - url: '/app/dashboards', - type: 'dashboard', - page: 'app', - id: '7adfa750-4c81-11e8-b3d7-01146121b73d', - description: '[Flights] Global Flight Dashboard', - child: { - type: 'agg_based', - name: 'vega', - id: 'ed78a660-53a0-11e8-acbd-0be0ad9d822b', - description: '[Flights] Airport Connections (Hover Over Airport)', - url: '/app/visualize#/edit/ed78a660-53a0-11e8-acbd-0be0ad9d822b', - }, - }, - }), - retry, - }); - }); - - it('propagates context for Tag Cloud visualization', async () => { - await assertLogContains({ - description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', - predicate: checkHttpRequestId( - 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;agg_based:tagcloud:293b5a30-4c8f-11e8-b3d7-01146121b73d' - ), - retry, - }); - - await assertLogContains({ - description: 'execution context propagates to Kibana logs', - predicate: checkExecutionContextEntry({ - name: 'dashboards', - url: '/app/dashboards', - type: 'application', - child: { - name: 'dashboards', - url: '/app/dashboards', - type: 'dashboard', - page: 'app', - id: '7adfa750-4c81-11e8-b3d7-01146121b73d', - description: '[Flights] Global Flight Dashboard', - child: { - type: 'agg_based', - name: 'tagcloud', - id: '293b5a30-4c8f-11e8-b3d7-01146121b73d', - description: '[Flights] Destination Weather', - url: '/app/visualize#/edit/293b5a30-4c8f-11e8-b3d7-01146121b73d', - }, - }, - }), - retry, - }); - }); - - it('propagates context for Vertical bar visualization', async () => { - await assertLogContains({ - description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', - predicate: checkHttpRequestId( - 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;agg_based:histogram:9886b410-4c8b-11e8-b3d7-01146121b73d' - ), - retry, + describe('propagates context for Vertical bar visualization', () => { + it('propagates to Elasticsearch via "x-opaque-id" header', async () => { + await assertLogContains({ + description: 'execution context propagates to Elasticsearch via "x-opaque-id" header', + predicate: checkHttpRequestId( + 'dashboard:dashboards:7adfa750-4c81-11e8-b3d7-01146121b73d;agg_based:histogram:9886b410-4c8b-11e8-b3d7-01146121b73d' + ), + retry, + }); }); - await assertLogContains({ - description: 'execution context propagates to Kibana logs', - predicate: checkExecutionContextEntry({ - type: 'application', - name: 'dashboards', - url: '/app/dashboards', - child: { - type: 'dashboard', + it('propagates to Kibana logs', async () => { + await assertLogContains({ + description: 'execution context propagates to Kibana logs', + predicate: checkExecutionContextEntry({ + type: 'application', name: 'dashboards', url: '/app/dashboards', - page: 'app', - id: '7adfa750-4c81-11e8-b3d7-01146121b73d', - description: '[Flights] Global Flight Dashboard', child: { - type: 'agg_based', - name: 'histogram', - id: '9886b410-4c8b-11e8-b3d7-01146121b73d', - description: '[Flights] Delay Buckets', - url: '/app/visualize#/edit/9886b410-4c8b-11e8-b3d7-01146121b73d', + type: 'dashboard', + name: 'dashboards', + url: '/app/dashboards', + page: 'app', + id: '7adfa750-4c81-11e8-b3d7-01146121b73d', + description: '[Flights] Global Flight Dashboard', + child: { + type: 'agg_based', + name: 'histogram', + id: '9886b410-4c8b-11e8-b3d7-01146121b73d', + description: '[Flights] Delay Buckets', + url: '/app/visualize#/edit/9886b410-4c8b-11e8-b3d7-01146121b73d', + }, }, - }, - }), - retry, + }), + retry, + }); }); }); });