From 0592c154260bff88fa370289afb9ad4537b51b52 Mon Sep 17 00:00:00 2001 From: Achyut Jhunjhunwala Date: Mon, 3 Feb 2025 10:46:41 +0100 Subject: [PATCH] [Dataset Quality] Fix flaky tests discover navigation (#208909) ## Summary Closes https://github.com/elastic/kibana/issues/206734 - The PR adds a retry logic while getting the Datasource Selector text on the Discover page. - Also renames the tests as they were missed when migration of links from Log Explorer to Discover were done ### Why do we need retry logic We navigate using locators. **Without retry** - The link generated has a hash and thus the check for `dataSelectorId` fails ``` https://achyut-mki-test-runner-e64297.kb.eu-west-1.aws.qa.elastic.cloud/app/r?l=DISCOVER_APP_LOCATOR&v=9.0.0&lz=N4IgLglgtgpgSgQwHYHMYgFygGYCcD2UmIS%2BA7gLQBMALABYgA04%2BxpZIAvs7jHjAGc6ASSRgYuAG4IANplAAHBAFcB6DGFzKYzaTO2YAbAAZTx7iAAmCMAgBqEGGWGXiM%2FCgEUESgMZ0YADoEX19BLwAqJisbe0cyAGUFGF95EAhXDBB3T28%2FAODQ8Ioo5kgwGXVsjy8fEIKQsIFI6MhYADFHGUsAOQRYYgABNsFbKAUuZgBHbVwATzSZZBRlBDRiAGtZhent4gB9CBRSXksMAAIoi198fSgkAUwAbQBdZmwIGXFcR4wn0FgtjSECQlhgAA83DU8vUgo1ilddhIFlgQFAbP59go6LgEGo0tZbPsBJoYP1Akh%2BoI%2FFUFARLMpfJB8EguJxOG90mIJHpiCowKxmAJ8LgwM8niBhtBRv0JswwQJUi8XpwgA%3D%3D%3D ``` **With retry** - This link then redirects to as Discover Locator resolves it to ``` https://achyut-mki-test-runner-e64297.kb.eu-west-1.aws.qa.elastic.cloud/app/discover#/?_g=(filters:!(),refreshInterval:(pause:!t,value:60000),time:(from:now-24h,to:now))&_a=(columns:!(),dataSource:(dataViewId:%27logs-apache.access-*%27,type:dataView),filters:!((meta:(index:%27logs-apache.access-*%27),query:(match_phrase:(data_stream.namespace:production)))),interval:auto,query:(language:kuery,query:%27_ignored:%20*%27),sort:!(!(%27@timestamp%27,desc))) ``` **Tested on MKI before and after the fix to confirm the issue is evidently reproducible and with the fix goes away** (cherry picked from commit 91ce0ba9e8e4da5c13b55613fcda2de22a4ef98c) --- .../dataset_quality_details.ts | 8 +++--- .../dataset_quality_details.ts | 27 +++++++++++-------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/x-pack/test/functional/apps/dataset_quality/dataset_quality_details.ts b/x-pack/test/functional/apps/dataset_quality/dataset_quality_details.ts index 043e116f33e8a..c1d60d59d3029 100644 --- a/x-pack/test/functional/apps/dataset_quality/dataset_quality_details.ts +++ b/x-pack/test/functional/apps/dataset_quality/dataset_quality_details.ts @@ -318,22 +318,22 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid }); describe('navigation', () => { - it('should go to log explorer page when the open in log explorer button is clicked', async () => { + it('should go to discover page when the open in discover button is clicked', async () => { await PageObjects.datasetQuality.navigateToDetails({ dataStream: regularDataStreamName, }); - const logExplorerButton = + const discoverButton = await PageObjects.datasetQuality.getDatasetQualityDetailsHeaderButton(); - await logExplorerButton.click(); + await discoverButton.click(); // Confirm dataset selector text in observability logs explorer const datasetSelectorText = await PageObjects.discover.getCurrentDataViewId(); originalExpect(datasetSelectorText).toMatch(regularDatasetName); }); - it('should go log explorer for degraded docs when the button next to breakdown selector is clicked', async () => { + it('should go discover for degraded docs when the button next to breakdown selector is clicked', async () => { await PageObjects.datasetQuality.navigateToDetails({ dataStream: apacheAccessDataStreamName, }); diff --git a/x-pack/test_serverless/functional/test_suites/observability/dataset_quality/dataset_quality_details.ts b/x-pack/test_serverless/functional/test_suites/observability/dataset_quality/dataset_quality_details.ts index 8904ffbfe958a..4d6a6e19a772a 100644 --- a/x-pack/test_serverless/functional/test_suites/observability/dataset_quality/dataset_quality_details.ts +++ b/x-pack/test_serverless/functional/test_suites/observability/dataset_quality/dataset_quality_details.ts @@ -60,7 +60,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Dataset quality details', function () { // see details: https://github.com/elastic/kibana/issues/206734 - this.tags(['failsOnMKI']); + before(async () => { // Install Apache Integration and ingest logs for it await PageObjects.observabilityLogsExplorer.installPackage(apachePkg); @@ -326,22 +326,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); describe('navigation', () => { - it('should go to log explorer page when the open in log explorer button is clicked', async () => { + it('should go to discover page when the open in discover button is clicked', async () => { await PageObjects.datasetQuality.navigateToDetails({ dataStream: regularDataStreamName, }); - const logExplorerButton = + const discoverButton = await PageObjects.datasetQuality.getDatasetQualityDetailsHeaderButton(); - await logExplorerButton.click(); + await discoverButton.click(); + + // Confirm dataset selector text in discover + await retry.tryForTime(5000, async () => { + const datasetSelectorText = await PageObjects.discover.getCurrentDataViewId(); - // Confirm dataset selector text in observability logs explorer - const datasetSelectorText = await PageObjects.discover.getCurrentDataViewId(); - originalExpect(datasetSelectorText).toMatch(regularDatasetName); + originalExpect(datasetSelectorText).toMatch(regularDatasetName); + }); }); - it('should go log explorer for degraded docs when the button next to breakdown selector is clicked', async () => { + it('should go discover for degraded docs when the button next to breakdown selector is clicked', async () => { await PageObjects.datasetQuality.navigateToDetails({ dataStream: apacheAccessDataStreamName, }); @@ -350,9 +353,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { PageObjects.datasetQuality.testSubjectSelectors.datasetQualityDetailsLinkToDiscover ); - // Confirm dataset selector text in observability logs explorer - const datasetSelectorText = await PageObjects.discover.getCurrentDataViewId(); - originalExpect(datasetSelectorText).toMatch(apacheAccessDatasetName); + // Confirm dataset selector text in discover + await retry.tryForTime(5000, async () => { + const datasetSelectorText = await PageObjects.discover.getCurrentDataViewId(); + originalExpect(datasetSelectorText).toMatch(apacheAccessDatasetName); + }); }); });