Skip to content

Commit

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

Resolves #193072

## Summary

Removes the skip on flaky monitoring tests

(cherry picked from commit cd5ff16)
  • Loading branch information
doakalexi committed Sep 23, 2024
1 parent a82e698 commit c419f7b
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 c419f7b

Please sign in to comment.