From f151e2ccaa55cc5e13740f49e88c323c0e1d8f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20=C3=81brah=C3=A1m?= Date: Thu, 24 Oct 2024 16:27:08 +0200 Subject: [PATCH] [EDR Workflows] Unskip and fix flaky endpoint exceptions FTR (#197457) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary closes #173184 closes #173441 closes #196003 This PR tries to improve on the `StaleElementReferenceError` happening in Endpoint Exception tests. This error is thrown if an element has already been removed from the DOM when trying to perform an action on it. For some reference, see https://github.com/elastic/kibana/pull/140427 Improvements: - the part that was failing is wrapped inside the `retryOnStale` helper: 602f2294fddb9bee8b69ebf2fd8382e9f025d59d **note:** actually the test fails have started in December, 2023, but the line where the fail was in the last test runs were added in May, 2024 (https://github.com/elastic/kibana/pull/183471). unfortunately, the log artifacts from 2023 are already removed from Buildkite, so no certainty on what happened back then - another suspicious part was wrapped as well: ec8c5cfd94812c8e5b357e00aac8bfae93ceecf4 and e5245ad010a02527105a56973465a25feb52ec85 - and as an extra, wait for page load: 7cd867fcb9489b24e79066dce750a2381af93d7d flaky 50/50 ✅ but this doesn't mean much, as this issue happens quite rarely ¯\\(◉‿◉)/¯ ### Checklist Delete any items that are not applicable to this PR. - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed --------- Co-authored-by: Elastic Machine --- .../apps/integrations/endpoint_exceptions.ts | 42 ++++++++++--------- .../apps/integrations/index.ts | 2 +- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/x-pack/test/security_solution_endpoint/apps/integrations/endpoint_exceptions.ts b/x-pack/test/security_solution_endpoint/apps/integrations/endpoint_exceptions.ts index 42d28132998bf5..eac635ac958ebf 100644 --- a/x-pack/test/security_solution_endpoint/apps/integrations/endpoint_exceptions.ts +++ b/x-pack/test/security_solution_endpoint/apps/integrations/endpoint_exceptions.ts @@ -22,6 +22,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const endpointTestResources = getService('endpointTestResources'); const endpointArtifactTestResources = getService('endpointArtifactTestResources'); const retry = getService('retry'); + const retryOnStale = getService('retryOnStale'); const esClient = getService('es'); const supertest = getService('supertest'); const find = getService('find'); @@ -30,30 +31,17 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const toasts = getService('toasts'); const MINUTES = 60 * 1000 * 10; - // FLAKY: https://github.com/elastic/kibana/issues/173441 - // Failing: See https://github.com/elastic/kibana/issues/173441 - describe.skip('Endpoint Exceptions', function () { + describe('Endpoint Exceptions', function () { targetTags(this, ['@ess', '@serverless']); - this.timeout(10 * MINUTES); - const clearPrefilledEntries = async () => { - const entriesContainer = await testSubjects.find('exceptionEntriesContainer'); - - let deleteButtons: WebElementWrapper[]; - do { - deleteButtons = await testSubjects.findAllDescendant( - 'builderItemEntryDeleteButton', - entriesContainer - ); - - await deleteButtons[0].click(); - } while (deleteButtons.length > 1); - }; + let clearPrefilledEntries: () => Promise; const openNewEndpointExceptionFlyout = async () => { - await testSubjects.scrollIntoView('timeline-context-menu-button'); - await testSubjects.click('timeline-context-menu-button'); + retryOnStale(async () => { + await testSubjects.scrollIntoView('timeline-context-menu-button'); + await testSubjects.click('timeline-context-menu-button'); + }); await testSubjects.click('add-endpoint-exception-menu-item'); await testSubjects.existOrFail('addExceptionFlyout'); @@ -166,10 +154,25 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }; await deleteEndpointExceptions(); + + clearPrefilledEntries = retryOnStale.wrap(async () => { + const entriesContainer = await testSubjects.find('exceptionEntriesContainer'); + + let deleteButtons: WebElementWrapper[]; + do { + deleteButtons = await testSubjects.findAllDescendant( + 'builderItemEntryDeleteButton', + entriesContainer + ); + + await deleteButtons[0].click(); + } while (deleteButtons.length > 1); + }); }); it('should add `event.module=endpoint` to entry if only wildcard operator is present', async () => { await pageObjects.common.navigateToUrlWithBrowserHistory('security', `/alerts`); + await pageObjects.header.waitUntilLoadingHasFinished(); await pageObjects.timePicker.setCommonlyUsedTime('Last_24 hours'); await openNewEndpointExceptionFlyout(); @@ -215,6 +218,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('should NOT add `event.module=endpoint` to entry if there is another operator', async () => { await pageObjects.common.navigateToUrlWithBrowserHistory('security', `/alerts`); + await pageObjects.header.waitUntilLoadingHasFinished(); await pageObjects.timePicker.setCommonlyUsedTime('Last_24 hours'); await openNewEndpointExceptionFlyout(); diff --git a/x-pack/test/security_solution_endpoint/apps/integrations/index.ts b/x-pack/test/security_solution_endpoint/apps/integrations/index.ts index 7bf73a60499d22..037ee3d60ec3ed 100644 --- a/x-pack/test/security_solution_endpoint/apps/integrations/index.ts +++ b/x-pack/test/security_solution_endpoint/apps/integrations/index.ts @@ -12,7 +12,7 @@ import { FtrProviderContext } from '../../configs/ftr_provider_context'; export default function (providerContext: FtrProviderContext) { const { loadTestFile, getService, getPageObjects } = providerContext; - describe('endpoint', function () { + describe('integrations', function () { const ingestManager = getService('ingestManager'); const log = getService('log'); const endpointTestResources = getService('endpointTestResources');