Skip to content

Commit 08a27b3

Browse files
committed
Add tags for the query so the search is scoped within the test (elastic#236706)
## Summary It fixes elastic#231522 by adding tags to the SLO query and narrowing down the selection to match only the SLO created within the test. That avoids any potential interference with other tests OR the racing conditions (the flakiness is unreproducible locally). (cherry picked from commit 02e7114)
1 parent 71c7e5c commit 08a27b3

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

  • x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/slo

x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/slo/find_slo.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,16 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
5252
});
5353

5454
it('searches SLOs using kqlQuery', async () => {
55-
const createResponse1 = await sloApi.create(DEFAULT_SLO, adminRoleAuthc);
55+
const testTag = `test-${Date.now()}`;
56+
const createResponse1 = await sloApi.create(
57+
Object.assign({}, DEFAULT_SLO, { tags: ['test', testTag] }),
58+
adminRoleAuthc
59+
);
5660
const createResponse2 = await sloApi.create(
57-
Object.assign({}, DEFAULT_SLO, { name: 'something irrelevant foo' }),
61+
Object.assign({}, DEFAULT_SLO, {
62+
name: 'something irrelevant foo',
63+
tags: ['test', testTag],
64+
}),
5865
adminRoleAuthc
5966
);
6067

@@ -65,7 +72,7 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
6572
await retry.tryForTime(180 * 1000, async () => {
6673
let response = await supertestWithoutAuth
6774
.get(`/api/observability/slos`)
68-
.query({ page: 1, perPage: 333 })
75+
.query({ page: 1, perPage: 333, kqlQuery: `slo.tags:"${testTag}"` })
6976
.set(adminRoleAuthc.apiKeyHeader)
7077
.set(internalHeaders)
7178
.send();

0 commit comments

Comments
 (0)