Skip to content
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

[8.x] [ResponseOps] Flaky test x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group2/monitoring·ts (#193614) #193785

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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