-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Fix flaky test: x-pack/test/detection_engine_api_integration/security_and_spaces/update_prebuilt_rules_package/update_prebuilt_rules_package·ts - update_prebuilt_rules_package should allow user to install prebuilt rules from scratch, then install new rules and upgrade existing rules from the new package #163241
Merged
jpdjere
merged 8 commits into
elastic:main
from
jpdjere:update-prebuilt-rules-package-flay-test-runner
Aug 11, 2023
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a25be3f
RUn flaky tets runner
jpdjere d7472f8
Add indices refresh after installing and upgrading rules
jpdjere e8395b3
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine ce1cb78
Merge branch 'main' into update-prebuilt-rules-package-flay-test-runner
jpdjere 7ee84f3
Refactor
jpdjere 2d0a116
Merge branch 'main' into update-prebuilt-rules-package-flay-test-runner
jpdjere 4b11128
Fix
jpdjere 4857be9
Merge branch 'main' into update-prebuilt-rules-package-flay-test-runner
jpdjere File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import JSON5 from 'json5'; | |
import expect from 'expect'; | ||
import { PackageSpecManifest } from '@kbn/fleet-plugin/common'; | ||
import { DETECTION_ENGINE_RULES_URL_FIND } from '@kbn/security-solution-plugin/common/constants'; | ||
import { ALL_SAVED_OBJECT_INDICES } from '@kbn/core-saved-objects-server'; | ||
import { FtrProviderContext } from '../../common/ftr_provider_context'; | ||
import { | ||
deleteAllPrebuiltRuleAssets, | ||
|
@@ -133,6 +134,8 @@ export default ({ getService }: FtrProviderContext): void => { | |
// Verify that the _perform endpoint returns the same number of installed rules as the status endpoint | ||
// and the _review endpoint | ||
const installPrebuiltRulesResponse = await installPrebuiltRules(supertest); | ||
await es.indices.refresh({ index: ALL_SAVED_OBJECT_INDICES }); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Installed rules fetching chunk looks to be repeated. It could be a reusable function with
|
||
expect(installPrebuiltRulesResponse.summary.succeeded).toBe( | ||
statusAfterPackageInstallation.stats.num_prebuilt_rules_to_install | ||
); | ||
|
@@ -168,9 +171,10 @@ export default ({ getService }: FtrProviderContext): void => { | |
.type('application/json') | ||
.send({ force: true }) | ||
.expect(200); | ||
|
||
expect(installLatestPackageResponse.body.items.length).toBeGreaterThanOrEqual(0); | ||
|
||
await es.indices.refresh({ index: ALL_SAVED_OBJECT_INDICES }); | ||
|
||
// Verify status after intallation of the latest package | ||
const statusAfterLatestPackageInstallation = await getPrebuiltRulesStatus(supertest); | ||
expect( | ||
|
@@ -198,6 +202,8 @@ export default ({ getService }: FtrProviderContext): void => { | |
const installPrebuiltRulesResponseAfterLatestPackageInstallation = await installPrebuiltRules( | ||
supertest | ||
); | ||
await es.indices.refresh({ index: ALL_SAVED_OBJECT_INDICES }); | ||
|
||
expect(installPrebuiltRulesResponseAfterLatestPackageInstallation.summary.succeeded).toBe( | ||
statusAfterLatestPackageInstallation.stats.num_prebuilt_rules_to_install | ||
); | ||
|
@@ -241,6 +247,8 @@ export default ({ getService }: FtrProviderContext): void => { | |
const upgradePrebuiltRulesResponseAfterLatestPackageInstallation = await upgradePrebuiltRules( | ||
supertest | ||
); | ||
await es.indices.refresh({ index: ALL_SAVED_OBJECT_INDICES }); | ||
|
||
expect(upgradePrebuiltRulesResponseAfterLatestPackageInstallation.summary.succeeded).toEqual( | ||
statusAfterLatestPackageInstallation.stats.num_prebuilt_rules_to_upgrade | ||
); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's quite easy to forget why
es.indices.refresh()
is needed and what part of test it's related to. It'd be nicer to have it right before an HTTP call depending on it so anybody reusing it doesn't have to keep in mindes.indices.refresh()
has to be called before. For examplegetPrebuiltRulesStatus()
should containes.indices.refresh()
inside.