-
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
[ObsUX] Fix timestamp for anomaly alert test #169255
[ObsUX] Fix timestamp for anomaly alert test #169255
Conversation
Pinging @elastic/apm-ui (Team:APM) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
const start = Date.now() - 1000 * 60 * 60 * 24 * 2; // day ago | ||
const end = Date.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.
nit: moment
with subtract()
and add()
is easier to read.
kibana/x-pack/test/apm_api_integration/tests/mobile/mobile_detailed_statistics_by_field.spec.ts
Line 47 in be85fef
start: moment(end).subtract(7, 'minutes').toISOString(), |
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.
Changed here bf3d743
const spikeStart = new Date('2021-01-07T23:15:00.000Z').getTime(); | ||
const spikeEnd = new Date('2021-01-08T00:15:00.000Z').getTime(); | ||
const spikeStart = new Date(Date.now() - 1000 * 60 * 15).getTime(); // 15 minutes ago | ||
const spikeEnd = new Date(Date.now()).getTime(); |
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.
const spikeEnd = new Date(Date.now()).getTime(); | |
const spikeEnd = Date.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.
Updated here bf3d743
29c268f
to
9c1b116
Compare
9c1b116
to
bf3d743
Compare
const start = moment().subtract(1, 'days').toISOString(); | ||
const end = moment().toISOString(); |
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.
Shouldn't this also be timestamps? Then you don't have to convert them 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.
Good point
const NORMAL_DURATION = 100; | ||
const NORMAL_RATE = 1; |
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.
Inline these. Having them extracted makes the code harder to read.
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.
just some nits
773d7f5
to
99f1599
Compare
|
||
let ruleId: string; | ||
|
||
before(async () => { | ||
await cleanup(); |
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 needed since you're running the cleanup on line 72 ?https://github.com/elastic/kibana/pull/169255/files#diff-12f5dc28099b892098fa1f396eeb9618adbef84c776e77559c5634dbe0f49da2R72?
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 want to clean before and after the test
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.
During development it's much easier if cleanup happens before running the test. On CI it is better to have cleanup after to avoid contamination between tests. I don't have strong opinions whether we need to cleanup both before and after though. Perhaps you can comment out the cleanup in the before step. It's still easy to enable for debug purposes.
94a8adc
to
05805c9
Compare
getAddRuleFlyout: jest | ||
.fn() | ||
.mockReturnValue(<div data-test-subj="add-rule-flyout">Add Rule Flyout</div>), | ||
getAddRuleFlyout: jest.fn().mockReturnValue( |
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.
@elastic/actionable-observability
I'm not sure how this end up in my PR, and is actually creating a conflict
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.
Fixed merging with main
6137417
to
9bb3eff
Compare
@@ -174,7 +174,6 @@ export function registerAnomalyRuleType({ | |||
range: { | |||
timestamp: { | |||
gte: dateStart, | |||
format: 'epoch_millis', |
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.
Are you sure about this change? Don't we pass an epoch timestamp anymore?
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 checked the other endpoints, and we don't pass it anywhere else, also dateStart
is typed as string, I had a conversation about it on slack
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]
History
To update your PR or re-run it, just comment with: |
Closes #160769
What was done
The anomaly alert test was failing with timeout because was not generating alerts, the data and spikes were added to far away in time, so when the job is created doesn't take into account data that far in the past
We fixed the timerange of the data generated and the spikes.
BEFORE:
AFTER:
Flaky test runner: