Skip to content

Commit

Permalink
Fixing test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
doakalexi committed Jan 31, 2024
1 parent 468f94d commit 134fae2
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,7 @@ describe('Alerts Service', () => {
revision: 0,
spaceId: 'default',
tags: ['rule-', '-tags'],
alertDelay: 0,
},
kibanaVersion: '8.8.0',
});
Expand Down Expand Up @@ -1731,6 +1732,7 @@ describe('Alerts Service', () => {
revision: 0,
spaceId: 'default',
tags: ['rule-', '-tags'],
alertDelay: 0,
},
kibanaVersion: '8.8.0',
});
Expand Down Expand Up @@ -1901,6 +1903,7 @@ describe('Alerts Service', () => {
revision: 0,
spaceId: 'default',
tags: ['rule-', '-tags'],
alertDelay: 0,
},
kibanaVersion: '8.8.0',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ interface AlertOpts {
state?: AlertInstanceState;
flapping: boolean;
maintenanceWindowIds?: string[];
alertCreationDelay?: boolean;
}

interface ActionOpts {
Expand Down Expand Up @@ -269,6 +270,7 @@ export function createAlertRecord(context: RuleContextOpts, alert: AlertOpts) {
flapping: alert.flapping,
maintenanceWindowIds: alert.maintenanceWindowIds,
ruleRevision: context.ruleRevision,
alertCreationDelay: alert.alertCreationDelay,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ interface CreateAlertEventLogRecordParams {
};
maintenanceWindowIds?: string[];
ruleRevision?: number;
alertCreationDelay?: boolean;
}

export function createAlertEventLogRecordObject(params: CreateAlertEventLogRecordParams): Event {
Expand All @@ -64,6 +65,7 @@ export function createAlertEventLogRecordObject(params: CreateAlertEventLogRecor
alertSummary,
maintenanceWindowIds,
ruleRevision,
alertCreationDelay,
} = params;
const alerting =
params.instanceId || group || alertSummary
Expand Down Expand Up @@ -98,6 +100,7 @@ export function createAlertEventLogRecordObject(params: CreateAlertEventLogRecor
...(flapping !== undefined ? { flapping } : {}),
...(maintenanceWindowIds ? { maintenance_window_ids: maintenanceWindowIds } : {}),
...(alertUuid ? { uuid: alertUuid } : {}),
...(alertCreationDelay !== undefined ? { alert_creation_delay: alertCreationDelay } : {}),
rule: {
revision: ruleRevision,
rule_type_id: ruleType.id,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/alerting/server/routes/update_rule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ describe('updateRuleRoute', () => {
"uuid": "1234-5678",
},
],
"name": "abc",
"alertDelay": Object {
"active": 10,
},
"name": "abc",
"notifyWhen": "onActionGroupChange",
"params": Object {
"otherField": false,
Expand Down
12 changes: 6 additions & 6 deletions x-pack/plugins/alerting/server/rules_client/tests/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,12 @@ describe('update()', () => {
},
},
],
"createdAt": 2019-02-12T21:01:22.479Z,
"enabled": true,
"id": "1",
"alertDelay": Object {
"active": 5,
},
"createdAt": 2019-02-12T21:01:22.479Z,
"enabled": true,
"id": "1",
"notifyWhen": "onActiveAlert",
"params": Object {
"bar": true,
Expand Down Expand Up @@ -431,6 +431,9 @@ describe('update()', () => {
"uuid": "102",
},
],
"alertDelay": Object {
"active": 10,
},
"alertTypeId": "myType",
"apiKey": null,
"apiKeyCreatedByUser": null,
Expand All @@ -445,9 +448,6 @@ describe('update()', () => {
"versionApiKeyLastmodified": "v7.10.0",
},
"name": "abc",
"alertDelay": Object {
"active": 10,
},
"notifyWhen": "onActiveAlert",
"params": Object {
"bar": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ describe('Task Runner', () => {
ruleType: ruleTypeWithAlerts,
namespace: 'default',
rule: {
alertDelay: 0,
consumer: 'bar',
executionId: '5f6aa57d-3e22-484e-bae8-cbed868f4d28',
id: '1',
Expand Down Expand Up @@ -800,6 +801,7 @@ describe('Task Runner', () => {

expect(alertsClientToUse.processAlerts).toHaveBeenCalledWith({
notifyOnActionGroupChange: false,
alertDelay: 0,
flappingSettings: {
enabled: true,
lookBackWindow: 20,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('getUpdatedFlappingHistory', () => {
flappingHistory: [],
flapping: false,
pendingRecoveredCount: 0,
activeCount: 0,
},
},
trackedAlertsRecovered: {},
Expand Down Expand Up @@ -81,6 +82,7 @@ describe('getUpdatedFlappingHistory', () => {
flappingHistory: [],
flapping: false,
pendingRecoveredCount: 0,
activeCount: 0,
},
},
trackedAlerts: {},
Expand Down Expand Up @@ -115,6 +117,7 @@ describe('getUpdatedFlappingHistory', () => {
flappingHistory: [],
flapping: false,
pendingRecoveredCount: 0,
activeCount: 0,
},
},
trackedAlertsRecovered: {},
Expand Down Expand Up @@ -150,6 +153,7 @@ describe('getUpdatedFlappingHistory', () => {
flappingHistory: [],
flapping: false,
pendingRecoveredCount: 0,
activeCount: 0,
},
},
};
Expand Down Expand Up @@ -184,6 +188,7 @@ describe('getUpdatedFlappingHistory', () => {
flappingHistory: [],
flapping: false,
pendingRecoveredCount: 0,
activeCount: 0,
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ export default function createAlertsAsDataAlertDelayInstallResourcesTest({
before(async () => {
await esTestIndexTool.destroy();
await esTestIndexTool.setup();
await es.deleteByQuery({
index: [alertsAsDataIndex, alwaysFiringAlertsAsDataIndex],
query: { match_all: {} },
conflicts: 'proceed',
});
});
afterEach(() => objectRemover.removeAll());
after(async () => {
Expand Down

0 comments on commit 134fae2

Please sign in to comment.