Skip to content

Commit

Permalink
Use two different data archives
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Mar 23, 2023
1 parent 77fd8f7 commit b0b3d68
Show file tree
Hide file tree
Showing 8 changed files with 721 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import expect from '@kbn/expect';
import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../../common/lib';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';

const LOADED_RULE_ID = '74f3e6d7-b7bb-477d-ac28-92ee22728e6e';
const LOADED_RULE_ID = 'c6b2c560-0685-42f6-b488-472594cfe915';

// eslint-disable-next-line import/no-default-export
export default function createRunSoonTests({ getService }: FtrProviderContext) {
Expand All @@ -22,17 +22,15 @@ export default function createRunSoonTests({ getService }: FtrProviderContext) {
const objectRemover = new ObjectRemover(supertest);

before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/rules_scheduled_task_id/rules');
await esArchiver.load('x-pack/test/functional/es_archives/rules_scheduled_task_id/tasks');
await esArchiver.load('x-pack/test/functional/es_archives/rules_run_soon');
});

afterEach(async () => {
await objectRemover.removeAll();
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/rules_scheduled_task_id/tasks');
await esArchiver.unload('x-pack/test/functional/es_archives/rules_scheduled_task_id/rules');
await esArchiver.unload('x-pack/test/functional/es_archives/rules_run_soon');
});

it('should successfully run rule where scheduled task id is different than rule id', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ export default function createScheduledTaskIdTests({ getService }: FtrProviderCo
}

before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/rules_scheduled_task_id/rules');
await esArchiver.load('x-pack/test/functional/es_archives/rules_scheduled_task_id/tasks');
await esArchiver.load('x-pack/test/functional/es_archives/rules_scheduled_task_id');
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/rules_scheduled_task_id/tasks');
await esArchiver.unload('x-pack/test/functional/es_archives/rules_scheduled_task_id/rules');
await esArchiver.unload('x-pack/test/functional/es_archives/rules_scheduled_task_id');
});

it('cannot create rule with same ID as a scheduled task ID used by another rule', async () => {
Expand Down
74 changes: 74 additions & 0 deletions x-pack/test/functional/es_archives/rules_run_soon/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"type": "doc",
"value": {
"id": "alert:c6b2c560-0685-42f6-b488-472594cfe915",
"index": ".kibana_1",
"source": {
"alert": {
"actions": [
],
"alertTypeId": "example.always-firing",
"apiKey": "QIUT8u0/kbOakEHSj50jDpVR90MrqOxanEscboYOoa8PxQvcA5jfHash+fqH3b+KNjJ1LpnBcisGuPkufY9j1e32gKzwGZV5Bfys87imHvygJvIM8uKiFF8bQ8Y4NTaxOJO9fAmZPrFy07ZcQMCAQz+DUTgBFqs=",
"apiKeyOwner": "elastic",
"consumer": "alerts",
"createdAt": "2020-06-17T15:35:38.497Z",
"createdBy": "elastic",
"enabled": true,
"muteAll": false,
"mutedInstanceIds": [
],
"name": "always-firing-alert",
"params": {
},
"schedule": {
"interval": "1m"
},
"scheduledTaskId": "329798f0-b0b0-11ea-9510-fdf248d5f2a4",
"tags": [
],
"throttle": null,
"updatedBy": "elastic"
},
"migrationVersion": {
"alert": "7.16.0"
},
"references": [
],
"type": "alert",
"updated_at": "2020-06-17T15:35:39.839Z"
}
}
}

{
"type": "doc",
"value": {
"id": "task:329798f0-b0b0-11ea-9510-fdf248d5f2a4",
"index": ".kibana_task_manager_1",
"source": {
"migrationVersion": {
"task": "7.16.0"
},
"task": {
"attempts": 0,
"ownerId": null,
"params": "{\"alertId\":\"c6b2c560-0685-42f6-b488-472594cfe915\",\"spaceId\":\"default\"}",
"retryAt": null,
"runAt": "2021-11-05T16:21:52.148Z",
"schedule": {
"interval": "1m"
},
"scheduledAt": "2021-11-05T15:28:42.055Z",
"scope": [
"alerting"
],
"startedAt": null,
"status": "idle",
"taskType": "alerting:example.always-firing"
},
"references": [],
"type": "task",
"updated_at": "2021-11-05T16:21:37.629Z"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,119 @@
}
}
}

{
"type": "index",
"value": {
"aliases": {
".kibana_task_manager": {
}
},
"index": ".kibana_task_manager_1",
"mappings": {
"_meta": {
"migrationMappingPropertyHashes": {
"migrationVersion": "4a1746014a75ade3a714e1db5763276f",
"namespace": "2f4316de49999235636386fe51dc06c1",
"namespaces": "2f4316de49999235636386fe51dc06c1",
"originId": "2f4316de49999235636386fe51dc06c1",
"references": "7997cf5a56cc02bdc9c93361bde732b0",
"task": "235412e52d09e7165fac8a67a43ad6b4",
"type": "2f4316de49999235636386fe51dc06c1",
"updated_at": "00da57df13e94e9d98437d13ace4bfe0"
}
},
"dynamic": "strict",
"properties": {
"migrationVersion": {
"dynamic": "true",
"properties": {
"task": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
}
}
},
"references": {
"properties": {
"id": {
"type": "keyword"
},
"name": {
"type": "keyword"
},
"type": {
"type": "keyword"
}
},
"type": "nested"
},
"task": {
"properties": {
"attempts": {
"type": "integer"
},
"ownerId": {
"type": "keyword"
},
"params": {
"type": "text"
},
"retryAt": {
"type": "date"
},
"runAt": {
"type": "date"
},
"schedule": {
"properties": {
"interval": {
"type": "keyword"
}
}
},
"scheduledAt": {
"type": "date"
},
"scope": {
"type": "keyword"
},
"startedAt": {
"type": "date"
},
"state": {
"type": "text"
},
"status": {
"type": "keyword"
},
"taskType": {
"type": "keyword"
},
"user": {
"type": "keyword"
}
}
},
"type": {
"type": "keyword"
},
"updated_at": {
"type": "date"
}
}
},
"settings": {
"index": {
"auto_expand_replicas": "0-1",
"number_of_replicas": "0",
"number_of_shards": "1"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,39 @@
}
}

{
"type": "doc",
"value": {
"id": "task:329798f0-b0b0-11ea-9510-fdf248d5f2a4",
"index": ".kibana_task_manager_1",
"source": {
"migrationVersion": {
"task": "7.16.0"
},
"task": {
"attempts": 0,
"ownerId": null,
"params": "{\"alertId\":\"74f3e6d7-b7bb-477d-ac28-92ee22728e6e\",\"spaceId\":\"default\"}",
"retryAt": null,
"runAt": "2021-11-05T16:21:52.148Z",
"schedule": {
"interval": "1m"
},
"scheduledAt": "2021-11-05T15:28:42.055Z",
"scope": [
"alerting"
],
"startedAt": null,
"status": "idle",
"taskType": "alerting:example.always-firing"
},
"references": [],
"type": "task",
"updated_at": "2021-11-05T16:21:37.629Z"
}
}
}

{
"type": "doc",
"value": {
Expand Down Expand Up @@ -81,3 +114,36 @@
}
}
}

{
"type": "doc",
"value": {
"id": "task:46be60d4-ae63-48ed-ab6f-f4d9b4defacf",
"index": ".kibana_task_manager_1",
"source": {
"migrationVersion": {
"task": "7.16.0"
},
"task": {
"attempts": 0,
"ownerId": null,
"params": "{\"alertId\":\"46be60d4-ae63-48ed-ab6f-f4d9b4defacf\",\"spaceId\":\"default\"}",
"retryAt": null,
"runAt": "2021-11-05T16:21:52.148Z",
"schedule": {
"interval": "1m"
},
"scheduledAt": "2021-11-05T15:28:42.055Z",
"scope": [
"alerting"
],
"startedAt": null,
"status": "idle",
"taskType": "sampleTaskRemovedType"
},
"references": [],
"type": "task",
"updated_at": "2021-11-05T16:21:37.629Z"
}
}
}
Loading

0 comments on commit b0b3d68

Please sign in to comment.