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

[Detections Response] Finish moving remaining legacy FTRs #175837

Merged
merged 40 commits into from
Feb 13, 2024

Conversation

yctercero
Copy link
Contributor

@yctercero yctercero commented Jan 29, 2024

Resolves: #151902

Summary

After this PR, all D&R FTRs are moved to new folder where they can be run in ESS and serverless. Please see below table for a summary of what tests need revisiting by the teams. During the test migration there may have been some tests that failed on serverless, but not ESS. Some we were able to fix and get running on both, others are still marked as brokenInServerless and need triage.

Detection Engine FTRs

Test ESS Serverless Notes
/actions/trial_license_complete_tier/check_privileges.ts
/exceptions/workflows/trial_license_complete_tier/create_rule_exceptions.ts One test in suite is brokenInServerless
/exceptions/workflows/trial_license_complete_tier/role_based_add_edit_comments.ts
/exceptions/workflows/trial_license_complete_tier/role_based_rule_exceptions_workflows.ts One test in suite is brokenInServerless

Rules Management FTRs

Test ESS Serverless Notes
/rule_bulk_actions/trial_license_complete_tier/perform_bulk_action.ts
/rule_creation/trial_license_complete_tier/create_rules_bulk.ts
/rule_creation/trial_license_complete_tier/create_rules.ts Three tests in suite is brokenInServerless
/rule_creation/trial_license_complete_tier/preview_rules.ts Two tests in suite is brokenInServerless
/rule_delete/trial_license_complete_tier/delete_rules_bulk.ts
/rule_import_export/trial_license_complete_tier/export_rules.ts
/rule_import_export/trial_license_complete_tier/import_rules.ts
/rule_patch/basic_license_essentials_tier/patch_rules.ts One test in suite is brokenInServerless
/rule_patch/trial_license_complete_tier/patch_rules_bulk.ts
/rule_patch/trial_license_complete_tier/patch_rules.ts Four tests in suite is brokenInServerless
/rule_read/trial_license_complete_tier/read_rules.ts Two tests in suite is brokenInServerless
/rule_update/basic_license_essentials_tier/update_rules.ts One test in suite is brokenInServerless
/rule_update/trial_license_complete_tier/update_rules_bulk.ts
/rule_update/trial_license_complete_tier/update_rules.ts Four tests in suite is brokenInServerless

Shared D&R FTRs

Test ESS Serverless Notes
/telemetry/trial_license_complete_tier/usage_collector/detection_rules.ts 14 tests in suite is brokenInServerless
/user_roles/trial_license_complete_tier/read_privileges.ts

@yctercero yctercero requested review from a team as code owners January 29, 2024 19:41
@yctercero yctercero self-assigned this Jan 29, 2024
@yctercero yctercero added release_note:skip Skip the PR/issue when compiling release notes Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Rule Management Security Detection Rule Management Team Team:Detection Engine Security Solution Detection Engine Area v8.13.0 labels Jan 29, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detection-rule-management (Team:Detection Rule Management)

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@elasticmachine
Copy link
Contributor

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

@yctercero yctercero requested a review from a team as a code owner January 30, 2024 01:17
@banderror
Copy link
Contributor

banderror commented Jan 31, 2024

Please see below table for a summary of what tests need revisiting by the teams. During the test migration there may have been some tests that failed on serverless, but not ESS. Some we were able to fix and get running on both, others are still marked as brokenInServerless and need triage.

Thank you for compiling this info into a table @yctercero, this will be very helpful in the future! Once the PR is merged, I'll open follow-up tickets for @elastic/security-detection-rule-management to revisit and unskip the tests that were marked as @brokenInServerless.

Copy link
Contributor

@banderror banderror left a comment

Choose a reason for hiding this comment

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

Restructuring tests is a huge undertaking, I really appreciate all the work you've done in this PR, in #175417, and other prior PRs. Thank you so much @yctercero!

The PR LGTM 👍 I left some concerns that I'm ok to address in follow-up PRs myself. Nothing blocking from my side.

I will defer approving it to @maximpn since he was assigned as a reviewer.

Copy link
Contributor

@maximpn maximpn left a comment

Choose a reason for hiding this comment

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

@yctercero thank you for moving FTR tests in the new folder 🙏

I totally agree with Georgii's comment https://github.com/elastic/kibana/pull/175837/files#r1472814985 but I don't we should address all that issues in this PR. It should be focused on moving tests with minimal changes so it doesn't block any other PR requiring changing/adding FTR tests. The issues mentioned should be addressed in follow up PRs.

I see you made some little changes by using updateUsername() and similar. It doesn't look to be necessary (correct me if I'm wrong here) for this PR. Ideally we need to get rid of removeServerGeneratedProperties(), updateUsername(), getSimpleRuleOutputWithoutRuleId() and etc in favor of Jest expect with partial matching like expect().toMatchObject() and objectContaining to focus on the changes the test does. It's a huge amount of work so it looks logical do this refactoring only when a test touched (updated/fixed) or a new test added.

As I don't see any critical changes required I approve this PR.

@yctercero yctercero requested a review from a team as a code owner February 8, 2024 18:32
@yctercero yctercero requested a review from rylnd February 8, 2024 18:32
@yctercero
Copy link
Contributor Author

@elasticmachine merge upstream

@yctercero
Copy link
Contributor Author

@elasticmachine merge upstream

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 had a few recommendations for cleaning up some of the cruft introduced by the expansion of these FTRs into the serverless era, but they were mostly just resurrecting @banderror's previous insights 😅 .

Kudos on finding and calling out the test duplication as well; that's easily overlooked. However, since these PRs are not introducing the duplication (rather, they're just not fixing it), I would agree that it can be fixed down the line.

Thanks for the helpful PR description and comment responses; this one was a lot so those are very much appreciated :)

export default ({ getService }: FtrProviderContext): void => {
const esArchiver = getService('esArchiver');
const supertest = getService('supertest');
const log = getService('log');
const es = getService('es');

describe('create_rules_bulk', () => {
// TODO: add a new service for loading archiver files similar to "getService('es')"
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with georgii that we probably don't need to keep adding this comment, but I appreciate the commitment!

@@ -51,7 +55,9 @@ export default ({ getService }: FtrProviderContext): void => {
.expect(200);

const bodyToCompare = removeServerGeneratedProperties(body[0]);
expect(bodyToCompare).to.eql(getSimpleRuleOutput());
const expectedRule = updateUsername(getSimpleRuleOutput(), ELASTICSEARCH_USERNAME);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seeing all these updateUsernames added here doesn't feel great; I'll reiterate @banderror's previous comment pointing out that we now modify both the actual value and the expected value, which does seem a little silly.

I really like expect.objectContaining as referenced, but it can definitely get a little verbose and hard to read; maybe we could hide some of that verbosity in a declarative matcher? It's not obvious how one would go about adding a matcher to kbn-expect, but we could certainly just write a function that compares the appropriate fields and ignores the rest:

assertRuleEquality({ actual: body[0], expected: getSimpleRuleOutput() })

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll look to create some follow up issues to track these suggestions!

@yctercero
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

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

cc @yctercero

@yctercero yctercero merged commit f4f71d1 into elastic:main Feb 13, 2024
34 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Feb 13, 2024
CoenWarmer pushed a commit to CoenWarmer/kibana that referenced this pull request Feb 15, 2024
…5837)

**Resolves: elastic#151902

## Summary

After this PR, all D&R FTRs are moved to new folder where they can be
run in ESS and serverless. Please see below table for a summary of what
tests need revisiting by the teams. During the test migration there may
have been some tests that failed on serverless, but not ESS. Some we
were able to fix and get running on both, others are still marked as
`brokenInServerless` and need triage.
CoenWarmer pushed a commit to CoenWarmer/kibana that referenced this pull request Feb 15, 2024
…5837)

**Resolves: elastic#151902

## Summary

After this PR, all D&R FTRs are moved to new folder where they can be
run in ESS and serverless. Please see below table for a summary of what
tests need revisiting by the teams. During the test migration there may
have been some tests that failed on serverless, but not ESS. Some we
were able to fix and get running on both, others are still marked as
`brokenInServerless` and need triage.
fkanout pushed a commit to fkanout/kibana that referenced this pull request Mar 4, 2024
…5837)

**Resolves: elastic#151902

## Summary

After this PR, all D&R FTRs are moved to new folder where they can be
run in ESS and serverless. Please see below table for a summary of what
tests need revisiting by the teams. During the test migration there may
have been some tests that failed on serverless, but not ESS. Some we
were able to fix and get running on both, others are still marked as
`brokenInServerless` and need triage.
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 Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Security Solution] Restructure API integration tests into meaningful groups that run in parallel on CI
9 participants