Skip to content

Commit

Permalink
Fixing flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ymao1 committed Nov 11, 2024
1 parent e03e59b commit 2b71dbb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,9 @@ function getPatternFiringAutoRecoverFalseRuleType() {
} else if (scheduleByPattern === 'timeout') {
// delay longer than the timeout
await new Promise((r) => setTimeout(r, 12000));
} else if (scheduleByPattern === 'run_long') {
// delay so rule runs a little longer
await new Promise((r) => setTimeout(r, 4000));
} else {
services.alertFactory.create(instanceId).scheduleActions('default', scheduleByPattern);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export default function findBackfillTests({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const supertestWithoutAuth = getService('supertestWithoutAuth');

// Failing: See https://github.com/elastic/kibana/issues/196226
describe.skip('find backfill', () => {
describe('find backfill', () => {
let backfillIds: Array<{ id: string; spaceId: string }> = [];
const objectRemover = new ObjectRemover(supertest);
const start1 = moment().utc().startOf('day').subtract(14, 'days').toISOString();
Expand Down Expand Up @@ -279,15 +278,12 @@ export default function findBackfillTests({ getService }: FtrProviderContext) {
.auth(apiOptions.username, apiOptions.password);

// find backfill with end time that is after one backfill ends
const findEnd = moment(end2).utc().add(1, 'hour').toISOString();
const findWithEndOneRuleResponse = await supertestWithoutAuth
.post(
`${getUrlPrefix(
apiOptions.spaceId
)}/internal/alerting/rules/backfill/_find?end=${moment()
.utc()
.startOf('day')
.subtract(9, 'days')
.toISOString()}`
)}/internal/alerting/rules/backfill/_find?end=${findEnd}`
)
.set('kbn-xsrf', 'foo')
.auth(apiOptions.username, apiOptions.password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function scheduleBackfillTests({ getService }: FtrProviderContext
rule_type_id: 'test.patternFiringAutoRecoverFalse',
params: {
pattern: {
instance: [true, false, true],
instance: ['run_long', 'run_long', 'run_long'],
},
},
schedule: { interval: '12h' },
Expand All @@ -85,7 +85,7 @@ export default function scheduleBackfillTests({ getService }: FtrProviderContext
expect(result.rule.tags).to.eql(['foo']);
expect(result.rule.params).to.eql({
pattern: {
instance: [true, false, true],
instance: ['run_long', 'run_long', 'run_long'],
},
});
expect(result.rule.enabled).to.eql(true);
Expand All @@ -103,7 +103,7 @@ export default function scheduleBackfillTests({ getService }: FtrProviderContext
expect(result.rule.tags).to.eql(['foo']);
expect(result.rule.params).to.eql({
pattern: {
instance: [true, false, true],
instance: ['run_long', 'run_long', 'run_long'],
},
});
expect(result.rule.enabled).to.eql(true);
Expand Down

0 comments on commit 2b71dbb

Please sign in to comment.