-
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
[AO] Add API integration test scenarios to the Threshold rule #162501
[AO] Add API integration test scenarios to the Threshold rule #162501
Conversation
Pinging @elastic/actionable-observability (Team: Actionable Observability) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
💔 Build FailedFailed CI Steps
Test Failures
Metrics [docs]
History
To update your PR or re-run it, just comment with: cc @fkanout |
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.
LGTM, left a few comments ...
}); | ||
|
||
after(async () => { | ||
await supertest.delete(`/api/alerting/rule/${ruleId}`).set('kbn-xsrf', 'foo'); |
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.
We have a utility ObjectRemover
which may simplify some of this sort of stuff - or not! Example usage here.
}); | ||
|
||
it('should be active', async () => { | ||
const executionStatus = await waitForRuleStatus({ |
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.
Kinda up to you, since you own these tests, but we generally treat each test as stand-alone, so that you could change it(...
to it.only(...
when diagnosing tests. I think we'd more generally write a function here to create the rule / connector, and call it from each test, and then delete it (somehow - ObjectRemover or other) in an afterEach()
.
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.
@pmuellr, thank you for the feedback!
I wrote these tests as a file-per-scenario as we are sharing the same tests in serverless and stateful env to maintain them easily (copy/paste 😄) with minimum dependencies until we can share one test suite across ENVs (agnostic 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.
Ya, will be interesting to see how serverless / stateful test sharing will go!
maintain them easily (copy/paste 😄)
Probably more of a risk of these being problematic, in that each test depends on the previous to work. Small number of tests here though, so hard to imagine it going wrong in this file, now. Something to think about if these get more complex.
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.
Overall LGTM 👍🏻
Just added some clarification questions :)
timeSize: 1, | ||
timeUnit: 'm', | ||
customMetrics: [ | ||
{ name: 'A', field: 'system.network.in.bytes', aggType: Aggregators.AVERAGE }, |
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.
For the system.network.in.bytes
and system.network.out.bytes
, do we have hard coded value in the @kbn/infra-forge
, or are they a random number?
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.
Neither, it's incremental.
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.
So it means the reason will be different on each execution, right?
Probably, when we test action variables and check the reason, we need to make this value more predictable.
const esDeleteAllIndices = getService('esDeleteAllIndices'); | ||
const logger = getService('log'); | ||
|
||
describe('Threshold rule - AVG - PCT - FIRED', () => { |
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.
What are the differences between Threshold rule - AVG - PCT - FIRED
and Threshold rule - AVG - US - FIRED
?
Initially, I was thinking about having multiple scenarios to check the reason to make sure they are properly formatted, I am curious to know what other differences we can test.
FYI, I created another ticket for the action variables, then we can also check the reason to ensure the correct formating is used.
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.
What are the differences between Threshold rule - AVG - PCT - FIRED and Threshold rule - AVG - US - FIRED?
Field data type % and microseconds
Initially, I was thinking about having multiple scenarios to check the reason to make sure they are properly formatted, I am curious to know what other differences we can test.
I am not sure If understand what you mean, but please create a ticket with the check you want to do with the scenarios you have in mind.
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.
My question is, what do we test for different field data types related to their type? Can you please point me to the code that is different between these two tests related to their field types?
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.
@maryam-saeidi, I'm fulfilling the 1st scenario you requested in your issue:
Multiple conditions with different types of fields (such as number, string, percent) without grouping (Can we have one condition for every condition type? 😄)
I thought you knew the difference, so you asked to cover it.
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.
Changing the field type will make many areas of code to be tested. I will list some files to answer the question
x-pack/plugins/observability/server/lib/rules/threshold/lib/get_data.ts
x-pack/plugins/observability/server/lib/rules/threshold/lib/metric_query.ts
x-pack/plugins/observability/server/lib/rules/threshold/threshold_executor.ts
x-pack/plugins/observability/server/lib/rules/threshold/lib/create_percentile_aggregation.ts
... and maybe others
As this is an integration test (not a unit test), asking about what lines of code are covered is inadequate and hard to answer.
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 thought you knew the difference, so you asked to cover it.
Yes, the difference was the reason
message that we are not checking at the moment.
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.
As this is an integration test (not a unit test), asking about what lines of code are covered is inadequate and hard to answer.
By the line of code, I meant related to the new tests that you added, not the code behind the scene, something maybe like: the value that is saved in AAD is formatted differently for different field types.
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've added some comments that probably we need to change when we test the action variables and specifically the reason
message, but I think this PR is good to go!
Summary
It fixes #162491