Skip to content

Commit

Permalink
[EDR Workflows] Unskip and fix flaky endpoint exceptions FTR (#197457)
Browse files Browse the repository at this point in the history
## 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
#140427

Improvements:
- the part that was failing is wrapped inside the `retryOnStale` helper:
602f229
**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 (#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:
ec8c5cf and
e5245ad
- and as an extra, wait for page load:
7cd867f

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 <[email protected]>
  • Loading branch information
gergoabraham and elasticmachine authored Oct 24, 2024
1 parent 7a8d813 commit f151e2c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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<void>;

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');

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit f151e2c

Please sign in to comment.