Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution][Detection Engine] Getting rid off before hook if is not loading an archive #178876

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

MadameSheema
Copy link
Member

@MadameSheema MadameSheema commented Mar 18, 2024

Summary

Addresses: #175021

Before the introduced changes on this PR, we had test dependency at manage_lists_cy.ts. Now that the dependency does not exist anymore, we had to update the assertions.

Update:
Flaky test suite runner passed successfully

@MadameSheema
Copy link
Member Author

/ci

@MadameSheema
Copy link
Member Author

/ci

@MadameSheema MadameSheema self-assigned this Mar 18, 2024
@MadameSheema MadameSheema added release_note:skip Skip the PR/issue when compiling release notes Team:Detection Engine Security Solution Detection Engine Area v8.14.0 labels Mar 18, 2024
@MadameSheema MadameSheema marked this pull request as ready for review March 18, 2024 17:56
@MadameSheema MadameSheema requested a review from a team as a code owner March 18, 2024 17:56
@MadameSheema MadameSheema requested a review from rylnd March 18, 2024 17:56
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detection-engine (Team:Detection Engine)

@MadameSheema
Copy link
Member Author

/ci

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @MadameSheema

@MadameSheema MadameSheema enabled auto-merge (squash) March 19, 2024 10:48
Copy link
Contributor

@yctercero yctercero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - we chatted about these changes previously.

@MadameSheema MadameSheema merged commit e0829c0 into elastic:main Mar 19, 2024
37 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Mar 19, 2024
Copy link
Contributor

@rylnd rylnd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was already merged, but I wanted to comment on the fact that none of these tests seem to leave the environment in a clean state. IMO that's a critical piece to making this suite stable.

});

after(() => {
cy.task('esArchiverUnload', { archiveName: 'exceptions' });
});

beforeEach(() => {
deleteDataView(DATAVIEW);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like DATAVIEW will still exist after the last test is run. Should there be an additional afterEach with a deleteDataView(DATAVIEW)?

before(() => {
beforeEach(() => {
deleteAlertsAndRules();
deleteExceptionLists();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing the same pattern as above here: after the last test, any rules and exception lists created will still be present for the next test. There should probably also be an afterEach added with these commands.

Trying to set up a pristine state in the beforeEach is a good, defensive practice, but cleaning up your own test's data is much more important. I suspect that's been the cause of some flakiness in our suite.

deleteRuntimeField('security-solution-default', alertRunTimeField);
deleteRuntimeField('security-solution-default', timelineRuntimeField);
});

beforeEach(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, no afterEach for cleanup :(

@@ -16,7 +16,7 @@ import { login } from '../../../../tasks/login';
const dataViews = ['auditbeat-*,fakebeat-*', 'auditbeat-*,*beat*,siem-read*,.kibana*,fakebeat-*'];

describe('Sourcerer permissions', { tags: ['@ess', '@brokenInServerless'] }, () => {
before(() => {
beforeEach(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢

@MadameSheema
Copy link
Member Author

I know this was already merged, but I wanted to comment on the fact that none of these tests seem to leave the environment in a clean state. IMO that's a critical piece to making this suite stable.

Hey Ryland!! The above changes have been introduced in order to make sure the Cypress retriability works as expected. It is true that the test will not leave a clean environment but, the execution of it will create the clean environment. That was done like that so in case of failure when you are developing or debugging, the state persists and you can check what really happened checking the environment.

If you feel more comfortable with the afterEach, I've no problem about moving the beforeEach changes to an afterEach. Please, let me know.

@rylnd
Copy link
Contributor

rylnd commented Mar 21, 2024

That was done like that so in case of failure when you are developing or debugging, the state persists and you can check what really happened checking the environment.

The more typical solution for persisting state when debugging/developing is to simply comment out the "cleanup" steps (be they in after, afterEach, end of test, etc).

Leaving state for the next test (do our suites run in a fixed order, or randomly?) is just asking for trouble, in my experience. I'm not saying that it's the cause of any of our current flakiness, but it's certainly not making things any easier, and I don't think it should be the default approach.

However, these are certainly not the only tests to follow this pattern, so we should create a broader issue for this, discuss, and decide if/how to address. cc @marshallmain @yctercero

@yctercero
Copy link
Contributor

However, these are certainly not the only tests to follow this pattern, so we should create a broader issue for this, discuss, and decide if/how to address. cc @marshallmain @yctercero

@rylnd would you mind creating the issue for us to discuss? It would be great to track it and I agree that it is worth discussing and addressing. We do have a large amount of flake tickets open right now, and it is worth examining if addressing this issue could help.

@MadameSheema MadameSheema deleted the detection-engine-before-hook branch June 28, 2024 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Detection Engine Security Solution Detection Engine Area v8.14.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants