Skip to content

Commit c8f69bb

Browse files
committed
Fix flaky action tests.
1 parent e28a580 commit c8f69bb

4 files changed

Lines changed: 24 additions & 4 deletions

File tree

x-pack/platform/test/api_integration_deployment_agnostic/apis/alerting_v2/bulk_create_alert_action.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import expect from '@kbn/expect';
99
import type { DeploymentAgnosticFtrProviderContext } from '../../ftr_provider_context';
1010
import type { RoleCredentials } from '../../services';
11-
import { createAlertEvent, indexAlertEvents } from './fixtures';
11+
import { createAlertEvent, DISPATCHER_SYSTEM_ACTION_TYPES, indexAlertEvents } from './fixtures';
1212

1313
const BULK_ALERT_ACTION_API_PATH = '/api/alerting/v2/alerts/action/_bulk';
1414
const ALERTING_EVENTS_INDEX = '.rule-events';
@@ -59,7 +59,7 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
5959
index: ALERTING_ACTIONS_INDEX,
6060
query: {
6161
bool: {
62-
must_not: [{ terms: { action_type: ['fire', 'suppress'] } }],
62+
must_not: [{ terms: { action_type: [...DISPATCHER_SYSTEM_ACTION_TYPES] } }],
6363
filter: [{ terms: { rule_id: ruleIds } }],
6464
},
6565
},

x-pack/platform/test/api_integration_deployment_agnostic/apis/alerting_v2/create_alert_action.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import expect from '@kbn/expect';
99
import type { DeploymentAgnosticFtrProviderContext } from '../../ftr_provider_context';
1010
import type { RoleCredentials } from '../../services';
11-
import { createAlertEvent, indexAlertEvents } from './fixtures';
11+
import { createAlertEvent, DISPATCHER_SYSTEM_ACTION_TYPES, indexAlertEvents } from './fixtures';
1212

1313
const ALERT_ACTION_API_PATH = '/api/alerting/v2/alerts';
1414
const ALERTING_EVENTS_INDEX = '.rule-events';
@@ -59,7 +59,7 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
5959
index: ALERTING_ACTIONS_INDEX,
6060
query: {
6161
bool: {
62-
must_not: [{ terms: { action_type: ['fire', 'suppress'] } }],
62+
must_not: [{ terms: { action_type: [...DISPATCHER_SYSTEM_ACTION_TYPES] } }],
6363
filter: [{ terms: { rule_id: ruleIds } }],
6464
},
6565
},
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
/**
9+
* Action types written by the alerting v2 dispatcher (store_actions_step).
10+
* Tests index alert events into `.rule-events`; the scheduled dispatcher task can
11+
* index these alongside user/API actions. Queries that pick "latest" user action
12+
* must exclude these or flakily observe `unmatched` / `notified` instead of e.g. `activate`.
13+
*/
14+
export const DISPATCHER_SYSTEM_ACTION_TYPES = [
15+
'fire',
16+
'suppress',
17+
'unmatched',
18+
'notified',
19+
] as const;

x-pack/platform/test/api_integration_deployment_agnostic/apis/alerting_v2/fixtures/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
*/
77

88
export { createAlertEvent, indexAlertEvents } from './alert_event';
9+
export { DISPATCHER_SYSTEM_ACTION_TYPES } from './dispatcher_action_types';

0 commit comments

Comments
 (0)