-
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] remove metadata integ test explicit timeouts #125742
[Security Solution] remove metadata integ test explicit timeouts #125742
Conversation
flaky test runner: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/159 |
|
||
describe('test metadata apis', () => { | ||
before(async () => { | ||
await endpointTestResources.setMetadataTransformFrequency('1s'); |
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.
ideally we'd set the united transform to 1s as well but as of 8.0.0, we get 403s when trying to edit the united transform. likely related to fleet permission changes since it utilizes the fleet-agents index.
await Promise.all([ | ||
bulkIndex(getService, AGENTS_INDEX, generateAgentDocs(currentTime, policyId)), | ||
bulkIndex(getService, AGENTS_INDEX, agentDocs), | ||
bulkIndex(getService, METADATA_DATASTREAM, generateMetadataDocs(currentTime)), |
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.
in the future, it'd be nice to use the data generator but since we're testing field filtering in these tests and the generator doesn't support override fields yet (some fields on the generated are read only too), it's not a straight forward replace. will consider for a separate PR.
Pinging @elastic/security-onboarding-and-lifecycle-mgt (Team:Onboarding and Lifecycle Mgt) |
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.
Thanks Joey for making this change. Everytime I see setTimeout()
I always start thinking about how we can use more reliable methods than just arbitruary timeout values, so this change should really make the tests much more reliable and run a little faster.
I left some comments that I would like to hear back on - but as it stands, it also looks good to merge if you like. Do you remember if the prior skipped test were done also on 8.1? You have this tagged only for 8.2, but I'm wondering if it should be backported to 8.1 as well.
body, | ||
rest_total_hits_as_int: true, | ||
}); | ||
await this.waitForIndex(ids, metadataCurrentIndexPattern, body, timeout); |
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.
I'm actually thinking maybe this needs to also be the united index. The goal of htis method (waitForEndpoints()
) is to wait until we are sure data exists to be shown on the Endpoint LIst (or returned on the metadata
api), so I think (correct me if I'm wrong) the United target index is the one that supports that api, right?
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.
yeah, it definitely makes sense to wait for the united index. the issue I ran into here is that depending on the timing of the transform check point, it's possible that the united index doesn't get populated at all. I played around this in the test by only starting the united transform after verifying the metadata_current
index was populated.
waitForEndpoints()
startTransform(UNITED_TRANSFORM)
waitForUnitedEndpoints()
I considered using a future timestamp for the metadata doc(s) + only checking for united index. while it works, it feels less reliable and similar to a timeout. what I think we can do in a follow up is update loadEndpointData
to do:
stop united transform
generate + index docs
wait for metadata_current
start united transform
wait for metadata_united
I'm thinking we can also add an optional generateAndIndexDocs param for custom data so we can handle situations like the integration tests in this PR.
} | ||
: { | ||
query: { | ||
match_all: {}, |
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.
Wondering: in this case, maybe in order to speed the search up, we should limit the result to 1 only? we're just trying to ensure data exists right? (maybe do that change above too on line 197).
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.
that makes sense
// We ignore 404's (index might not exist) | ||
if (error instanceof errors.ResponseError && error.statusCode === 404) { | ||
return false; | ||
async waitForUnitedEndpoints(ids: string[] = [], timeout = this.config.get('timeouts.waitFor')) { |
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.
If my comment above makes sense to you (about actualyl checking the united index rather than the other one), then maybe we don't need this method?
If you do keep it, please add JSDOCs that describe what this method does nad how its different from the one above.
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.
put a long winded response above but I definitely forgot to update the comments. will do that.
@@ -137,13 +139,45 @@ export class EndpointTestResources extends FtrService { | |||
return deleteIndexedHostsAndAlerts(this.esClient as Client, this.kbnClient, indexedData); | |||
} | |||
|
|||
private async waitForIndex( |
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.
Nice. this is a good generic method that can be used to check for data in any index
from: #125127 (comment) I'm wondering if when we call the "setMetadataTransformFrequency()` we actually should apply the new frequency across all of our transforms and not just one. cc/ @kevinlog |
for sure. I left a comment way above so it's a bit buried but in also just wrapped up transform frequency performance testing so we might just end up dropping both frequencies down to 1s. |
a0f069d
to
32a0dc2
Compare
💛 Build succeeded, but was flakyTest Failures
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
…stic#125742) (cherry picked from commit ecefde8)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Summary
Replace explicit timeouts from endpoint metadata integration tests with
waitFor
s as mentioned in #125675 (comment).For maintainers