diff --git a/x-pack/test/functional/apps/aiops/log_pattern_analysis.ts b/x-pack/test/functional/apps/aiops/log_pattern_analysis.ts index 2fa19f348dcab..e8f8d690e9334 100644 --- a/x-pack/test/functional/apps/aiops/log_pattern_analysis.ts +++ b/x-pack/test/functional/apps/aiops/log_pattern_analysis.ts @@ -23,8 +23,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); } - // FLAKY: https://github.com/elastic/kibana/issues/172739 - describe.skip('log pattern analysis', async function () { + describe('log pattern analysis', async function () { let tabsCount = 1; afterEach(async () => { @@ -55,8 +54,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await aiops.logPatternAnalysisPage.assertLogPatternAnalysisPageExists(); await aiops.logPatternAnalysisPage.clickUseFullDataButton(totalDocCount); + await aiops.logPatternAnalysisPage.setRandomSamplingOption('aiopsRandomSamplerOptionOff'); await aiops.logPatternAnalysisPage.selectCategoryField(selectedField); await aiops.logPatternAnalysisPage.clickRunButton(); + await aiops.logPatternAnalysisPage.assertTotalCategoriesFound(3); await aiops.logPatternAnalysisPage.assertCategoryTableRows(3); @@ -82,6 +83,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await aiops.logPatternAnalysisPage.assertLogPatternAnalysisPageExists(); await aiops.logPatternAnalysisPage.clickUseFullDataButton(totalDocCount); + await aiops.logPatternAnalysisPage.setRandomSamplingOption('aiopsRandomSamplerOptionOff'); await aiops.logPatternAnalysisPage.selectCategoryField(selectedField); await aiops.logPatternAnalysisPage.clickRunButton(); await aiops.logPatternAnalysisPage.assertTotalCategoriesFound(3); diff --git a/x-pack/test/functional/apps/aiops/log_pattern_analysis_in_discover.ts b/x-pack/test/functional/apps/aiops/log_pattern_analysis_in_discover.ts index 8d089155aa8b6..d341ac4cf1b2a 100644 --- a/x-pack/test/functional/apps/aiops/log_pattern_analysis_in_discover.ts +++ b/x-pack/test/functional/apps/aiops/log_pattern_analysis_in_discover.ts @@ -23,8 +23,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); } - // FLAKY: https://github.com/elastic/kibana/issues/172770 - describe.skip('log pattern analysis', async function () { + describe('log pattern analysis', async function () { let tabsCount = 1; afterEach(async () => { @@ -62,6 +61,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await aiops.logPatternAnalysisPage.assertLogPatternAnalysisFlyoutExists(); await aiops.logPatternAnalysisPage.assertLogPatternAnalysisFlyoutTitle(selectedField); + await aiops.logPatternAnalysisPage.setRandomSamplingOption('aiopsRandomSamplerOptionOff'); + await aiops.logPatternAnalysisPage.assertTotalCategoriesFound(3); await aiops.logPatternAnalysisPage.assertCategoryTableRows(3); @@ -92,6 +93,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await aiops.logPatternAnalysisPage.assertLogPatternAnalysisFlyoutExists(); await aiops.logPatternAnalysisPage.assertLogPatternAnalysisFlyoutTitle(selectedField); + await aiops.logPatternAnalysisPage.setRandomSamplingOption('aiopsRandomSamplerOptionOff'); + await aiops.logPatternAnalysisPage.assertTotalCategoriesFound(3); await aiops.logPatternAnalysisPage.assertCategoryTableRows(3); diff --git a/x-pack/test/functional/services/aiops/log_pattern_analysis_page.ts b/x-pack/test/functional/services/aiops/log_pattern_analysis_page.ts index 661881a288381..9c0ab19ac64c4 100644 --- a/x-pack/test/functional/services/aiops/log_pattern_analysis_page.ts +++ b/x-pack/test/functional/services/aiops/log_pattern_analysis_page.ts @@ -14,6 +14,11 @@ export function LogPatternAnalysisPageProvider({ getService, getPageObject }: Ft const testSubjects = getService('testSubjects'); const comboBox = getService('comboBox'); + type RandomSamplerOption = + | 'aiopsRandomSamplerOptionOnAutomatic' + | 'aiopsRandomSamplerOptionOnManual' + | 'aiopsRandomSamplerOptionOff'; + return { async assertLogPatternAnalysisPageExists() { await retry.tryForTime(30 * 1000, async () => { @@ -60,25 +65,25 @@ export function LogPatternAnalysisPageProvider({ getService, getPageObject }: Ft }); }, - async assertTotalCategoriesFound(expectedCategoryCount: number) { - const expectedText = `${expectedCategoryCount} patterns found`; + async assertTotalCategoriesFound(expectedMinimumCategoryCount: number) { await retry.tryForTime(5000, async () => { const actualText = await testSubjects.getVisibleText('aiopsLogPatternsFoundCount'); - expect(actualText).to.eql( - expectedText, - `Expected patterns found count to be '${expectedText}' (got '${actualText}')` + const actualCount = Number(actualText.split(' ')[0]); + expect(actualCount + 1).to.greaterThan( + expectedMinimumCategoryCount, + `Expected patterns found count to be >= '${expectedMinimumCategoryCount}' (got '${actualCount}')` ); }); }, - async assertCategoryTableRows(expectedCategoryCount: number) { + async assertCategoryTableRows(expectedMinimumCategoryCount: number) { await retry.tryForTime(5000, async () => { const tableListContainer = await testSubjects.find('aiopsLogPatternsTable'); const rows = await tableListContainer.findAllByClassName('euiTableRow'); - expect(rows.length).to.eql( - expectedCategoryCount, - `Expected number of rows in table to be '${expectedCategoryCount}' (got '${rows.length}')` + expect(rows.length + 1).to.greaterThan( + expectedMinimumCategoryCount, + `Expected number of rows in table to be >= '${expectedMinimumCategoryCount}' (got '${rows.length}')` ); }); }, @@ -176,5 +181,23 @@ export function LogPatternAnalysisPageProvider({ getService, getPageObject }: Ft ); }); }, + + async setRandomSamplingOption(option: RandomSamplerOption) { + await retry.tryForTime(20000, async () => { + await testSubjects.existOrFail('aiopsLogPatternAnalysisShowSamplingOptionsButton'); + await testSubjects.clickWhenNotDisabled('aiopsLogPatternAnalysisShowSamplingOptionsButton'); + + await testSubjects.clickWhenNotDisabled('aiopsRandomSamplerOptionsSelect'); + + await testSubjects.existOrFail('aiopsRandomSamplerOptionOff', { timeout: 1000 }); + await testSubjects.existOrFail('aiopsRandomSamplerOptionOnManual', { timeout: 1000 }); + await testSubjects.existOrFail('aiopsRandomSamplerOptionOnAutomatic', { timeout: 1000 }); + + await testSubjects.click(option); + + await testSubjects.clickWhenNotDisabled('aiopsLogPatternAnalysisShowSamplingOptionsButton'); + await testSubjects.missingOrFail('aiopsRandomSamplerOptionsFormRow', { timeout: 1000 }); + }); + }, }; }