-
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
Changes from 1 commit
61a2f04
bf3d743
f0610be
99f1599
05805c9
9bb3eff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -23,23 +23,24 @@ export default function ApiTest({ getService }: FtrProviderContext) { | |||||
const logger = getService('log'); | ||||||
|
||||||
const synthtraceEsClient = getService('synthtraceEsClient'); | ||||||
// FLAKY https://github.com/elastic/kibana/issues/160298 | ||||||
registry.when.skip( | ||||||
registry.when( | ||||||
'fetching service anomalies with a trial license', | ||||||
{ config: 'trial', archives: [] }, | ||||||
() => { | ||||||
const start = '2021-01-01T00:00:00.000Z'; | ||||||
const end = '2021-01-08T00:15:00.000Z'; | ||||||
const start = Date.now() - 1000 * 60 * 60 * 24 * 2; // day ago | ||||||
const end = Date.now(); | ||||||
|
||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
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. Updated here bf3d743 |
||||||
|
||||||
const NORMAL_DURATION = 100; | ||||||
const NORMAL_RATE = 1; | ||||||
|
||||||
let ruleId: string; | ||||||
|
||||||
before(async () => { | ||||||
await cleanup(); | ||||||
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. 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 commentThe 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 commentThe 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. |
||||||
|
||||||
const serviceA = apm | ||||||
.service({ name: 'a', environment: 'production', agentName: 'java' }) | ||||||
.instance('a'); | ||||||
|
@@ -65,26 +66,25 @@ export default function ApiTest({ getService }: FtrProviderContext) { | |||||
}); | ||||||
|
||||||
await synthtraceEsClient.index(events); | ||||||
|
||||||
await createAndRunApmMlJobs({ es, ml, environments: ['production'] }); | ||||||
}); | ||||||
|
||||||
after(async () => { | ||||||
await cleanup(); | ||||||
}); | ||||||
|
||||||
async function cleanup() { | ||||||
try { | ||||||
await synthtraceEsClient.clean(); | ||||||
await deleteRuleById({ supertest, ruleId }); | ||||||
await ml.cleanMlIndices(); | ||||||
} catch (e) { | ||||||
logger.info('Could not delete rule by id', e); | ||||||
} | ||||||
}); | ||||||
} | ||||||
|
||||||
describe('with ml jobs', () => { | ||||||
before(async () => { | ||||||
await createAndRunApmMlJobs({ es, ml, environments: ['production'] }); | ||||||
}); | ||||||
|
||||||
after(async () => { | ||||||
await ml.cleanMlIndices(); | ||||||
}); | ||||||
|
||||||
it('checks if alert is active', async () => { | ||||||
const createdRule = await createApmRule({ | ||||||
supertest, | ||||||
|
@@ -97,7 +97,6 @@ export default function ApiTest({ getService }: FtrProviderContext) { | |||||
}, | ||||||
ruleTypeId: ApmRuleType.Anomaly, | ||||||
}); | ||||||
|
||||||
ruleId = createdRule.id; | ||||||
if (!ruleId) { | ||||||
expect(ruleId).to.not.eql(undefined); | ||||||
|
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
withsubtract()
andadd()
is easier to read.kibana/x-pack/test/apm_api_integration/tests/mobile/mobile_detailed_statistics_by_field.spec.ts
Line 47 in be85fef
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