Skip to content

Commit 5e4981f

Browse files
Fixes Failing test: X-Pack Alerting API Integration Tests.x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/telemetry/alerting_and_actions_telemetry·ts - alerting api integration security and spaces enabled - Group 2 Alerting and Actions Telemetry test telemetry should retrieve telemetry data in the expected format (#214868)
Resolves #202564 ## Summary The test is testing for the number of alerts generated assuming the AAD rule runs 3 times (2 alerts per run). It looks like sometimes, the rule only runs twice before the telemetry is collected so this updates the test to verify the number of alerts based on the number of times the rule ran. --------- Co-authored-by: Elastic Machine <[email protected]>
1 parent 9bbfb7e commit 5e4981f

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/telemetry/alerting_and_actions_telemetry.ts

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ export default function createAlertingAndActionsTelemetryTests({ getService }: F
2828
const supertestWithoutAuth = getService('supertestWithoutAuth');
2929
const configService = getService('config');
3030

31-
// Failing: See https://github.com/elastic/kibana/issues/202564
32-
describe.skip('test telemetry', () => {
31+
describe('test telemetry', () => {
3332
const objectRemover = new ObjectRemover(supertest);
3433
const esQueryRuleId: { [key: string]: string } = {};
3534
const simulator = new OpenAISimulator({
@@ -243,28 +242,6 @@ export default function createAlertingAndActionsTelemetryTests({ getService }: F
243242
actions: [],
244243
},
245244
});
246-
// ES query rule
247-
esQueryRuleId[space.id] = await createRule({
248-
space: space.id,
249-
ruleOverwrites: {
250-
rule_type_id: '.es-query',
251-
schedule: { interval: '1h' },
252-
throttle: null,
253-
params: {
254-
size: 100,
255-
timeWindowSize: 5,
256-
timeWindowUnit: 'm',
257-
thresholdComparator: '>',
258-
threshold: [0],
259-
searchType: 'esqlQuery',
260-
esqlQuery: {
261-
esql: 'from .kibana-alerting-test-data | stats c = count(date) | where c < 0',
262-
},
263-
timeField: 'date_epoch_millis',
264-
},
265-
actions: [],
266-
},
267-
});
268245
// MW with both toggles off
269246
await createMaintenanceWindow({ spaceId: space.id });
270247
// MW with 'Repeat' toggle on and 'Filter alerts' toggle on
@@ -301,6 +278,29 @@ export default function createAlertingAndActionsTelemetryTests({ getService }: F
301278
});
302279

303280
rulesWithAAD.push(ruleWithAadId);
281+
282+
// ES query rule
283+
esQueryRuleId[space.id] = await createRule({
284+
space: space.id,
285+
ruleOverwrites: {
286+
rule_type_id: '.es-query',
287+
schedule: { interval: '1h' },
288+
throttle: null,
289+
params: {
290+
size: 100,
291+
timeWindowSize: 5,
292+
timeWindowUnit: 'm',
293+
thresholdComparator: '>',
294+
threshold: [0],
295+
searchType: 'esqlQuery',
296+
esqlQuery: {
297+
esql: 'from .kibana-alerting-test-data | stats c = count(date) | where c < 0',
298+
},
299+
timeField: 'date_epoch_millis',
300+
},
301+
actions: [],
302+
},
303+
});
304304
}
305305
}
306306

@@ -592,8 +592,14 @@ export default function createAlertingAndActionsTelemetryTests({ getService }: F
592592
expect(telemetry.count_mw_with_repeat_toggle_on).to.equal(3);
593593

594594
// AAD alert counts
595-
expect(telemetry.count_alerts_total).to.be(6);
596-
expect(telemetry.count_alerts_by_rule_type['test__always-firing-alert-as-data']).to.be(6);
595+
const numAADexecutions =
596+
telemetry.count_rules_executions_by_type_per_day['test__always-firing-alert-as-data'];
597+
598+
// each rule execution reports 2 active alerts
599+
expect(telemetry.count_alerts_total).to.be(numAADexecutions * 2);
600+
expect(telemetry.count_alerts_by_rule_type['test__always-firing-alert-as-data']).to.be(
601+
numAADexecutions * 2
602+
);
597603
}
598604

599605
it('should retrieve telemetry data in the expected format', async () => {

0 commit comments

Comments
 (0)