-
Notifications
You must be signed in to change notification settings - Fork 453
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
Jamf Pro: fix flaky system tests #12689
Jamf Pro: fix flaky system tests #12689
Conversation
Pinging @elastic/security-service-integrations (Team:Security-Service Integrations) |
🚀 Benchmarks reportTo see the full report comment with |
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.
Does this mean that if a user sets the page size to unity, they will have a problem?
@efd6 I think so, unless the API returns a last empty response which I think is not probable. |
I think in that case we need to document the limitation or fix it. |
Looking at the PR that changed the logic, I think the fix here would be going back to the previous condition
as the bug that Chris mentioned was fixed in the logic of populating What do you think about it? Otherwise, I can just add the limitation to the |
I'd be OK with that provided it was checked against a real endpoint. |
@efd6, I have tested both ways of defining In that case, due to the API design, it gets stuck in an infinite loop asking for the first event on the list. That's because the filter I'll leave things as they are and document that limitation. |
Can we add a check for the last-used diff --git a/packages/jamf_pro/data_stream/inventory/agent/stream/cel.yml.hbs b/packages/jamf_pro/data_stream/inventory/agent/stream/cel.yml.hbs
index b6f2131ed4..e0da25d578 100644
--- a/packages/jamf_pro/data_stream/inventory/agent/stream/cel.yml.hbs
+++ b/packages/jamf_pro/data_stream/inventory/agent/stream/cel.yml.hbs
@@ -62,9 +62,9 @@ program: |-
?"event.original": state.?preserve_original_event.orValue(false) ? optional.of(e.encode_json()) : optional.none(),
}
),
- "want_more": size(body.results) >= state.page_size,
"cursor": state.?cursor.orValue({}).with(
{
+ ?"prev_last_report_date": state.?cursor.last_report_date,
?"last_report_date": (size(body.results) > 0) ?
optional.of(
body.results[size(body.results) - 1].general.reportDate.as(d,
@@ -76,7 +76,9 @@ program: |-
}
),
}
- )
+ ).as(state, state.with({
+ "want_more": size(body.results) >= state.page_size && (state.?cursor.prev_last_report_date != state.?cursor.last_report_date)
+ }))
)
)
state: (untested) |
Good point, added at bb83c61. It has been tested against the real API, even though we still have the limitation of |
💚 Build Succeeded
History
|
|
@@ -22,7 +22,7 @@ streams: | |||
required: false | |||
title: Inventory request page size | |||
show_user: false | |||
description: Set page size for computers-inventory API Call. Must not exceed 1000. | |||
description: Set page size for computers-inventory API Call. Its value must be within the range of 2 to 1000. |
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.
Is this change still required?
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 think so, the difference between before and after the last commit when page_size = 1
is that before, want_more
was true
when size(body.results) >= state.page_size
(one result was returned, and one is expected), so it was constantly asking for more data in the same interval. Now, even though want_more
is false because of the new condition state.?cursor.prev_last_report_date != state.?cursor.last_report_date
, in the next interval the filter last_report_date
is the same and will return the same event every time.
I checked that behaviour with page_size = 1
and the latest changes with the API.
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.
OK, so the fix we have is just for the cpu overuse. It would be nice to fix the whole issue, but this will do for now.
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.
Do we still need to change the tests?
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.
Same reason as for the page size limitation.
Package jamf_pro - 0.2.4 containing this change is available at https://epr.elastic.co/package/jamf_pro/0.2.4/ |
Proposed commit message
After this pagination fix, the condition to ask for more data is
size(body.results) >= state.page_size
(more context of this change here). This condition was always met in the system tests withpage_size == 1
so the test keeps constantly requesting more data.page_size
minimum value.max_executions
.prev_last_report_date
to compare with currentlast_report_date
and avoid repeated API requests when last report filter is the same as the previous request.Checklist
changelog.yml
file.Related issues