-
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
Improve task manager functional tests in preperation for mget task claimer being the default #196399
Improve task manager functional tests in preperation for mget task claimer being the default #196399
Changes from 1 commit
ff57457
078a3c6
d0a492e
0ca7458
aa13ec6
7e9a539
64e5871
6955117
bcb0da7
a2b5f30
49eb9e0
0fcf1ae
e2988a2
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { omit } from 'lodash'; | ||
import type { Client } from '@elastic/elasticsearch'; | ||
import { DeleteByQueryRequest } from '@elastic/elasticsearch/lib/api/types'; | ||
|
||
|
@@ -61,6 +62,9 @@ export class ESTestIndexTool { | |
group: { | ||
type: 'keyword', | ||
}, | ||
'@timestamp': { | ||
type: 'date', | ||
}, | ||
host: { | ||
properties: { | ||
hostname: { | ||
|
@@ -109,6 +113,7 @@ export class ESTestIndexTool { | |
async search(source: string, reference?: string) { | ||
const body = reference | ||
? { | ||
sort: [{ '@timestamp': 'asc' }], | ||
query: { | ||
bool: { | ||
must: [ | ||
|
@@ -127,6 +132,7 @@ export class ESTestIndexTool { | |
}, | ||
} | ||
: { | ||
sort: [{ '@timestamp': 'asc' }], | ||
query: { | ||
term: { | ||
source, | ||
|
@@ -138,7 +144,16 @@ export class ESTestIndexTool { | |
size: 1000, | ||
body, | ||
}; | ||
return await this.es.search(params, { meta: true }); | ||
const result = await this.es.search(params, { meta: true }); | ||
result.body.hits.hits = result.body.hits.hits.map((hit) => { | ||
return { | ||
...hit, | ||
// Easier to remove @timestamp than to have all the downstream code ignore it | ||
// in their assertions | ||
_source: omit(hit._source as Record<string, unknown>, '@timestamp'), | ||
}; | ||
}); | ||
return result; | ||
Comment on lines
+147
to
+156
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. In a rare case, we receive the document we expect 2nd in the list instead of first. Having a sort on timestamp will make sure it's consistent. |
||
} | ||
|
||
async getAll(size: number = 10) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,7 +125,7 @@ export default function apiKeyBackfillTests({ getService }: FtrProviderContext) | |
} | ||
|
||
it('should wait to invalidate API key until backfill for rule is complete', async () => { | ||
const start = moment().utc().startOf('day').subtract(7, 'days').toISOString(); | ||
const start = moment().utc().startOf('day').subtract(13, 'days').toISOString(); | ||
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. Backfill jobs sometimes ran too fast, adding more back days will compensate for this so we still have the backfill running while doing assertions on the API keys to remove. |
||
const end = moment().utc().startOf('day').subtract(4, 'day').toISOString(); | ||
const spaceId = SuperuserAtSpace1.space.id; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,11 +110,13 @@ export default function ruleTests({ getService }: FtrProviderContext) { | |
}); | ||
}); | ||
|
||
const { status, body: rule } = await supertest.get( | ||
`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule/${ruleId}` | ||
); | ||
expect(status).to.eql(200); | ||
expect(rule.execution_status.status).to.eql('active'); | ||
await retry.try(async () => { | ||
const { status, body: rule } = await supertest.get( | ||
`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule/${ruleId}` | ||
); | ||
expect(status).to.eql(200); | ||
expect(rule.execution_status.status).to.eql('active'); | ||
}); | ||
Comment on lines
+113
to
+119
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. Sometimes the event log documents are persisted before the rule finishes running and update its own status, causing this code to expect |
||
}); | ||
|
||
it('still logs alert docs when rule exceeds timeout when cancelAlertsOnRuleTimeout is false on rule type', async () => { | ||
|
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 test to ensure
removedTypes
get marked asunrecognized
, this should fix it.