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

Fix flaky test around search cancellation #193008

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
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 @@ -127,19 +127,25 @@ export default function ruleTests({ getService }: FtrProviderContext) {
events.filter((event) => event?.event?.action === 'execute');
expect(events[0]?.event?.outcome).to.eql('failure');
expect(events[0]?.kibana?.alerting?.status).to.eql('error');
expect(events[0]?.error?.message).to.eql(
'Search has been aborted due to cancelled execution'
);
// Timeouts will encounter one of the following two messages
const expectedMessages = [
'Request timed out',
'Search has been aborted due to cancelled execution',
];
expect(expectedMessages.includes(events[0]?.error?.message || '')).to.be(true);

// rule execution status should be in error with reason timeout
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('error');
expect(rule.execution_status.error.message).to.eql(
`test.cancellableRule:${ruleId}: execution cancelled due to timeout - exceeded rule type timeout of 3s`
);
expect(
[
'Request timed out',
`test.cancellableRule:${ruleId}: execution cancelled due to timeout - exceeded rule type timeout of 3s`,
].includes(rule.execution_status.error.message)
).to.eql(true);
expect(rule.execution_status.error.reason).to.eql('timeout');
});

Expand Down Expand Up @@ -183,9 +189,12 @@ export default function ruleTests({ getService }: FtrProviderContext) {
);
expect(status).to.eql(200);
expect(rule.execution_status.status).to.eql('error');
expect(rule.execution_status.error.message).to.eql(
`test.cancellableRule:${ruleId}: execution cancelled due to timeout - exceeded rule type timeout of 3s`
);
expect(
[
'Request timed out',
`test.cancellableRule:${ruleId}: execution cancelled due to timeout - exceeded rule type timeout of 3s`,
].includes(rule.execution_status.error.message)
).to.eql(true);
expect(rule.execution_status.error.reason).to.eql('timeout');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ export default function ruleTests({ getService }: FtrProviderContext) {
expect(errorStatuses.length).to.be.greaterThan(0);
const lastErrorStatus = errorStatuses.pop();
expect(lastErrorStatus?.status).to.eql('error');
expect(lastErrorStatus?.error.message).to.eql(
`test.patternLongRunning.cancelAlertsOnRuleTimeout:${ruleId}: execution cancelled due to timeout - exceeded rule type timeout of 3s`
);
expect(
[
'Request timed out',
`test.patternLongRunning.cancelAlertsOnRuleTimeout:${ruleId}: execution cancelled due to timeout - exceeded rule type timeout of 3s`,
].includes(lastErrorStatus?.error.message || '')
).to.eql(true);
expect(lastErrorStatus?.error.reason).to.eql('timeout');
});

Expand Down