Skip to content

Commit

Permalink
[8.x] [ResponseOps] Flaky test x-pack/test/alerting_api_integration/s…
Browse files Browse the repository at this point in the history
…paces_only/tests/alerting/group2/monitoring·ts (#193614) (#193785)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ResponseOps] Flaky test
x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group2/monitoring·ts
(#193614)](#193614)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Alexi
Doak","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-23T19:09:40Z","message":"[ResponseOps]
Flaky test
x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group2/monitoring·ts
(#193614)\n\nResolves
https://github.com/elastic/kibana/issues/193072\r\n\r\n##
Summary\r\n\r\nRemoves the skip on flaky monitoring
tests","sha":"cd5ff16dfdbc5ff46199f4ce5785bf52da22fa8a","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","v9.0.0","backport:prev-minor","v8.16.0"],"title":"[ResponseOps]
Flaky test
x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group2/monitoring·ts","number":193614,"url":"https://github.com/elastic/kibana/pull/193614","mergeCommit":{"message":"[ResponseOps]
Flaky test
x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group2/monitoring·ts
(#193614)\n\nResolves
https://github.com/elastic/kibana/issues/193072\r\n\r\n##
Summary\r\n\r\nRemoves the skip on flaky monitoring
tests","sha":"cd5ff16dfdbc5ff46199f4ce5785bf52da22fa8a"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193614","number":193614,"mergeCommit":{"message":"[ResponseOps]
Flaky test
x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group2/monitoring·ts
(#193614)\n\nResolves
https://github.com/elastic/kibana/issues/193072\r\n\r\n##
Summary\r\n\r\nRemoves the skip on flaky monitoring
tests","sha":"cd5ff16dfdbc5ff46199f4ce5785bf52da22fa8a"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Alexi Doak <[email protected]>
  • Loading branch information
kibanamachine and doakalexi authored Sep 23, 2024
1 parent a82e698 commit 9b4398a
Showing 1 changed file with 34 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,28 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context';
// eslint-disable-next-line import/no-default-export
export default function monitoringAlertTests({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const retry = getService('retry');

// Failing: See https://github.com/elastic/kibana/issues/193072
describe.skip('monitoring', () => {
describe('monitoring', () => {
const objectRemover = new ObjectRemover(supertest);

const run = async (id: string) => {
await retry.try(async () => {
// Sometimes the rule may already be running, which returns a 200. Try until it isn't
const response = await supertest
.post(`${getUrlPrefix(Spaces.space1.id)}/internal/alerting/rule/${id}/_run_soon`)
.set('kbn-xsrf', 'foo');
expect(response.status).to.eql(204);
});
};

after(async () => await objectRemover.removeAll());

it('should return an accurate history for a single success', async () => {
const createResponse = await supertest
.post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`)
.set('kbn-xsrf', 'foo')
.send(getTestRuleData({ schedule: { interval: '3s' } }));
.send(getTestRuleData({ schedule: { interval: '1h' } }));
expect(createResponse.status).to.eql(200);
objectRemover.add(Spaces.space1.id, createResponse.body.id, 'rule', 'alerting');

Expand All @@ -45,15 +55,21 @@ export default function monitoringAlertTests({ getService }: FtrProviderContext)
const createResponse = await supertest
.post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`)
.set('kbn-xsrf', 'foo')
.send(getTestRuleData({ schedule: { interval: '3s' } }));
.send(getTestRuleData({ schedule: { interval: '1h' } }));
expect(createResponse.status).to.eql(200);
objectRemover.add(Spaces.space1.id, createResponse.body.id, 'rule', 'alerting');

const ruleId = createResponse.body.id;
objectRemover.add(Spaces.space1.id, ruleId, 'rule', 'alerting');

for (let i = 1; i < 3; i++) {
await waitForExecutionCount(i, ruleId);
await run(ruleId);
}
// Allow at least three executions
await waitForExecutionCount(3, createResponse.body.id);
await waitForExecutionCount(3, ruleId);

const getResponse = await supertest.get(
`${getUrlPrefix(Spaces.space1.id)}/internal/alerting/rule/${createResponse.body.id}`
`${getUrlPrefix(Spaces.space1.id)}/internal/alerting/rule/${ruleId}`
);
expect(getResponse.status).to.eql(200);

Expand All @@ -72,20 +88,26 @@ export default function monitoringAlertTests({ getService }: FtrProviderContext)
.send(
getTestRuleData({
rule_type_id: 'test.patternSuccessOrFailure',
schedule: { interval: '3s' },
schedule: { interval: '1h' },
params: {
pattern,
},
})
);
expect(createResponse.status).to.eql(200);
objectRemover.add(Spaces.space1.id, createResponse.body.id, 'rule', 'alerting');

// Allow at least three executions
await waitForExecutionCount(5, createResponse.body.id);
const ruleId = createResponse.body.id;
objectRemover.add(Spaces.space1.id, ruleId, 'rule', 'alerting');

for (let i = 1; i < 5; i++) {
await waitForExecutionCount(i, ruleId);
await run(ruleId);
}
// Allow at least five executions
await waitForExecutionCount(5, ruleId);

const getResponse = await supertest.get(
`${getUrlPrefix(Spaces.space1.id)}/internal/alerting/rule/${createResponse.body.id}`
`${getUrlPrefix(Spaces.space1.id)}/internal/alerting/rule/${ruleId}`
);
expect(getResponse.status).to.eql(200);

Expand Down

0 comments on commit 9b4398a

Please sign in to comment.