From cfcbd613dc9ed1203acfc461537d7b252db6f4e4 Mon Sep 17 00:00:00 2001 From: Mike Cote Date: Mon, 27 Mar 2023 13:17:23 -0400 Subject: [PATCH] Fix flakiness --- .../group2/tests/alerting/rbac_legacy.ts | 9 +- .../alerts_legacy/{ => rules}/data.json | 159 ------------------ .../alerts_legacy/{ => rules}/mappings.json | 121 ------------- .../es_archives/alerts_legacy/tasks/data.json | 158 +++++++++++++++++ .../alerts_legacy/tasks/mappings.json | 120 +++++++++++++ 5 files changed, 285 insertions(+), 282 deletions(-) rename x-pack/test/functional/es_archives/alerts_legacy/{ => rules}/data.json (70%) rename x-pack/test/functional/es_archives/alerts_legacy/{ => rules}/mappings.json (95%) create mode 100644 x-pack/test/functional/es_archives/alerts_legacy/tasks/data.json create mode 100644 x-pack/test/functional/es_archives/alerts_legacy/tasks/mappings.json diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/alerting/rbac_legacy.ts b/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/alerting/rbac_legacy.ts index 1bc45581cf3faf..65b03893921047 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/alerting/rbac_legacy.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/alerting/rbac_legacy.ts @@ -62,7 +62,11 @@ export default function alertTests({ getService }: FtrProviderContext) { before(async () => { await esTestIndexTool.destroy(); - await esArchiver.load('x-pack/test/functional/es_archives/alerts_legacy'); + // Not 100% sure why, seems the rules need to be loaded separately to avoid the task + // failing to load the rule during execution and deleting itself. Otherwise + // we have flakiness + await esArchiver.load('x-pack/test/functional/es_archives/alerts_legacy/rules'); + await esArchiver.load('x-pack/test/functional/es_archives/alerts_legacy/tasks'); await esTestIndexTool.setup(); await es.indices.create({ index: authorizationIndex }); await setupSpacesAndUsers(getService); @@ -71,7 +75,8 @@ export default function alertTests({ getService }: FtrProviderContext) { after(async () => { await esTestIndexTool.destroy(); await es.indices.delete({ index: authorizationIndex }); - await esArchiver.unload('x-pack/test/functional/es_archives/alerts_legacy'); + await esArchiver.unload('x-pack/test/functional/es_archives/alerts_legacy/tasks'); + await esArchiver.unload('x-pack/test/functional/es_archives/alerts_legacy/rules'); }); for (const scenario of UserAtSpaceScenarios) { diff --git a/x-pack/test/functional/es_archives/alerts_legacy/data.json b/x-pack/test/functional/es_archives/alerts_legacy/rules/data.json similarity index 70% rename from x-pack/test/functional/es_archives/alerts_legacy/data.json rename to x-pack/test/functional/es_archives/alerts_legacy/rules/data.json index 770e8e7c156177..2c0552acb60542 100644 --- a/x-pack/test/functional/es_archives/alerts_legacy/data.json +++ b/x-pack/test/functional/es_archives/alerts_legacy/rules/data.json @@ -83,37 +83,6 @@ } } -{ - "type": "doc", - "value": { - "id": "task:e9c069d0-eea4-11ea-a285-352ee3aecffa", - "index": ".kibana_task_manager_1", - "source": { - "migrationVersion": { - "task": "7.6.0" - }, - "references": [ - ], - "task": { - "attempts": 0, - "params": "{\"alertId\":\"6ee9630a-a20e-44af-9465-217a3717d2ab\",\"spaceId\":\"space1\"}", - "retryAt": null, - "runAt": "2020-09-04T11:51:05.197Z", - "scheduledAt": "2020-09-04T11:51:05.197Z", - "scope": [ - "alerting" - ], - "startedAt": null, - "state": "{\"previousStartedAt\":null,\"alertTypeState\":{},\"alertInstances\":{}}", - "status": "idle", - "taskType": "alerting:test.always-firing" - }, - "type": "task", - "updated_at": "2020-09-04T11:51:05.197Z" - } - } -} - { "type": "doc", "value": { @@ -176,38 +145,6 @@ } } -{ - "type": "doc", - "value": { - "id": "task:e39a02f0-eea4-11ea-a285-352ee3aecffa", - "index": ".kibana_task_manager_1", - "source": { - "migrationVersion": { - "task": "7.6.0" - }, - "references": [ - ], - "task": { - "attempts": 0, - "ownerId": null, - "params": "{\"alertId\":\"b384be60-ec53-4b26-857e-0253ee55b277\",\"spaceId\":\"space1\"}", - "retryAt": null, - "runAt": "2020-09-04T11:51:04.804Z", - "scheduledAt": "2020-09-04T11:50:54.879Z", - "scope": [ - "alerting" - ], - "startedAt": null, - "state": "{\"previousStartedAt\":null,\"alertTypeState\":{},\"alertInstances\":{}}", - "status": "idle", - "taskType": "alerting:test.always-firing" - }, - "type": "task", - "updated_at": "2020-09-04T11:51:04.273Z" - } - } -} - { "type": "doc", "value": { @@ -270,38 +207,6 @@ } } -{ - "type": "doc", - "value": { - "id": "task:e8885f00-eea4-11ea-a285-352ee3aecffa", - "index": ".kibana_task_manager_1", - "source": { - "migrationVersion": { - "task": "7.6.0" - }, - "references": [ - ], - "task": { - "attempts": 1, - "ownerId": "kibana:5b2de169-2785-441b-ae8c-186a1936b17d", - "params": "{\"alertId\":\"5cc59319-74ee-4edc-8646-a79ea91067cd\",\"spaceId\":\"space1\"}", - "retryAt": "2020-09-04T12:01:05.793Z", - "runAt": "2020-09-04T11:51:03.152Z", - "scheduledAt": "2020-09-04T11:51:03.152Z", - "scope": [ - "alerting" - ], - "startedAt": "2020-09-04T11:51:05.793Z", - "state": "{\"previousStartedAt\":null,\"alertTypeState\":{},\"alertInstances\":{}}", - "status": "running", - "taskType": "alerting:test.always-firing" - }, - "type": "task", - "updated_at": "2020-09-04T11:51:05.794Z" - } - } -} - { "type": "doc", "value": { @@ -364,38 +269,6 @@ } } -{ - "type": "doc", - "value": { - "id": "task:e616c2c0-eea4-11ea-a285-352ee3aecffa", - "index": ".kibana_task_manager_1", - "source": { - "migrationVersion": { - "task": "7.6.0" - }, - "references": [ - ], - "task": { - "attempts": 1, - "ownerId": "kibana:5b2de169-2785-441b-ae8c-186a1936b17d", - "params": "{\"alertId\":\"d41a6abb-b93b-46df-a80a-926221ea847c\",\"spaceId\":\"space1\"}", - "retryAt": "2020-09-04T12:01:05.793Z", - "runAt": "2020-09-04T11:51:04.804Z", - "scheduledAt": "2020-09-04T11:50:59.052Z", - "scope": [ - "alerting" - ], - "startedAt": "2020-09-04T11:51:05.793Z", - "state": "{\"previousStartedAt\":null,\"alertTypeState\":{},\"alertInstances\":{}}", - "status": "idle", - "taskType": "alerting:test.always-firing" - }, - "type": "task", - "updated_at": "2020-09-04T11:51:05.794Z" - } - } -} - { "type": "doc", "value": { @@ -457,35 +330,3 @@ } } } - -{ - "type": "doc", - "value": { - "id": "task:e4df5430-eea4-11ea-a285-352ee3aecffa", - "index": ".kibana_task_manager_1", - "source": { - "migrationVersion": { - "task": "7.6.0" - }, - "references": [ - ], - "task": { - "attempts": 1, - "ownerId": "kibana:5b2de169-2785-441b-ae8c-186a1936b17d", - "params": "{\"alertId\":\"362e362b-a137-4aa2-9434-43e3d0d84a34\",\"spaceId\":\"space1\"}", - "retryAt": "2020-09-04T12:01:05.793Z", - "runAt": "2020-09-04T11:51:04.804Z", - "scheduledAt": "2020-09-04T11:50:57.011Z", - "scope": [ - "alerting" - ], - "startedAt": "2020-09-04T11:51:05.793Z", - "state": "{\"previousStartedAt\":null,\"alertTypeState\":{},\"alertInstances\":{}}", - "status": "running", - "taskType": "alerting:test.always-firing" - }, - "type": "task", - "updated_at": "2020-09-04T11:51:05.794Z" - } - } -} \ No newline at end of file diff --git a/x-pack/test/functional/es_archives/alerts_legacy/mappings.json b/x-pack/test/functional/es_archives/alerts_legacy/rules/mappings.json similarity index 95% rename from x-pack/test/functional/es_archives/alerts_legacy/mappings.json rename to x-pack/test/functional/es_archives/alerts_legacy/rules/mappings.json index 6e40f811e1af4b..23f170737f498f 100644 --- a/x-pack/test/functional/es_archives/alerts_legacy/mappings.json +++ b/x-pack/test/functional/es_archives/alerts_legacy/rules/mappings.json @@ -2520,124 +2520,3 @@ } } } - -{ - "type": "index", - "value": { - "aliases": { - ".kibana_task_manager": { - } - }, - "index": ".kibana_task_manager_1", - "mappings": { - "_meta": { - "migrationMappingPropertyHashes": { - "migrationVersion": "4a1746014a75ade3a714e1db5763276f", - "namespace": "2f4316de49999235636386fe51dc06c1", - "namespaces": "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" - } - } - }, - "namespace": { - "type": "keyword" - }, - "namespaces": { - "type": "keyword" - }, - "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" - } - } - } -} diff --git a/x-pack/test/functional/es_archives/alerts_legacy/tasks/data.json b/x-pack/test/functional/es_archives/alerts_legacy/tasks/data.json new file mode 100644 index 00000000000000..e7c99521ff3602 --- /dev/null +++ b/x-pack/test/functional/es_archives/alerts_legacy/tasks/data.json @@ -0,0 +1,158 @@ +{ + "type": "doc", + "value": { + "id": "task:e9c069d0-eea4-11ea-a285-352ee3aecffa", + "index": ".kibana_task_manager_1", + "source": { + "migrationVersion": { + "task": "7.6.0" + }, + "references": [ + ], + "task": { + "attempts": 0, + "params": "{\"alertId\":\"6ee9630a-a20e-44af-9465-217a3717d2ab\",\"spaceId\":\"space1\"}", + "retryAt": null, + "runAt": "2020-09-04T11:51:05.197Z", + "scheduledAt": "2020-09-04T11:51:05.197Z", + "scope": [ + "alerting" + ], + "startedAt": null, + "state": "{\"previousStartedAt\":null,\"alertTypeState\":{},\"alertInstances\":{}}", + "status": "idle", + "taskType": "alerting:test.always-firing" + }, + "type": "task", + "updated_at": "2020-09-04T11:51:05.197Z" + } + } +} + +{ + "type": "doc", + "value": { + "id": "task:e39a02f0-eea4-11ea-a285-352ee3aecffa", + "index": ".kibana_task_manager_1", + "source": { + "migrationVersion": { + "task": "7.6.0" + }, + "references": [ + ], + "task": { + "attempts": 0, + "ownerId": null, + "params": "{\"alertId\":\"b384be60-ec53-4b26-857e-0253ee55b277\",\"spaceId\":\"space1\"}", + "retryAt": null, + "runAt": "2020-09-04T11:51:04.804Z", + "scheduledAt": "2020-09-04T11:50:54.879Z", + "scope": [ + "alerting" + ], + "startedAt": null, + "state": "{\"previousStartedAt\":null,\"alertTypeState\":{},\"alertInstances\":{}}", + "status": "idle", + "taskType": "alerting:test.always-firing" + }, + "type": "task", + "updated_at": "2020-09-04T11:51:04.273Z" + } + } +} + +{ + "type": "doc", + "value": { + "id": "task:e8885f00-eea4-11ea-a285-352ee3aecffa", + "index": ".kibana_task_manager_1", + "source": { + "migrationVersion": { + "task": "7.6.0" + }, + "references": [ + ], + "task": { + "attempts": 1, + "ownerId": "kibana:5b2de169-2785-441b-ae8c-186a1936b17d", + "params": "{\"alertId\":\"5cc59319-74ee-4edc-8646-a79ea91067cd\",\"spaceId\":\"space1\"}", + "retryAt": "2020-09-04T12:01:05.793Z", + "runAt": "2020-09-04T11:51:03.152Z", + "scheduledAt": "2020-09-04T11:51:03.152Z", + "scope": [ + "alerting" + ], + "startedAt": "2020-09-04T11:51:05.793Z", + "state": "{\"previousStartedAt\":null,\"alertTypeState\":{},\"alertInstances\":{}}", + "status": "running", + "taskType": "alerting:test.always-firing" + }, + "type": "task", + "updated_at": "2020-09-04T11:51:05.794Z" + } + } +} + +{ + "type": "doc", + "value": { + "id": "task:e616c2c0-eea4-11ea-a285-352ee3aecffa", + "index": ".kibana_task_manager_1", + "source": { + "migrationVersion": { + "task": "7.6.0" + }, + "references": [ + ], + "task": { + "attempts": 1, + "ownerId": "kibana:5b2de169-2785-441b-ae8c-186a1936b17d", + "params": "{\"alertId\":\"d41a6abb-b93b-46df-a80a-926221ea847c\",\"spaceId\":\"space1\"}", + "retryAt": "2020-09-04T12:01:05.793Z", + "runAt": "2020-09-04T11:51:04.804Z", + "scheduledAt": "2020-09-04T11:50:59.052Z", + "scope": [ + "alerting" + ], + "startedAt": "2020-09-04T11:51:05.793Z", + "state": "{\"previousStartedAt\":null,\"alertTypeState\":{},\"alertInstances\":{}}", + "status": "idle", + "taskType": "alerting:test.always-firing" + }, + "type": "task", + "updated_at": "2020-09-04T11:51:05.794Z" + } + } +} + +{ + "type": "doc", + "value": { + "id": "task:e4df5430-eea4-11ea-a285-352ee3aecffa", + "index": ".kibana_task_manager_1", + "source": { + "migrationVersion": { + "task": "7.6.0" + }, + "references": [ + ], + "task": { + "attempts": 1, + "ownerId": "kibana:5b2de169-2785-441b-ae8c-186a1936b17d", + "params": "{\"alertId\":\"362e362b-a137-4aa2-9434-43e3d0d84a34\",\"spaceId\":\"space1\"}", + "retryAt": "2020-09-04T12:01:05.793Z", + "runAt": "2020-09-04T11:51:04.804Z", + "scheduledAt": "2020-09-04T11:50:57.011Z", + "scope": [ + "alerting" + ], + "startedAt": "2020-09-04T11:51:05.793Z", + "state": "{\"previousStartedAt\":null,\"alertTypeState\":{},\"alertInstances\":{}}", + "status": "running", + "taskType": "alerting:test.always-firing" + }, + "type": "task", + "updated_at": "2020-09-04T11:51:05.794Z" + } + } +} diff --git a/x-pack/test/functional/es_archives/alerts_legacy/tasks/mappings.json b/x-pack/test/functional/es_archives/alerts_legacy/tasks/mappings.json new file mode 100644 index 00000000000000..d139264b8de932 --- /dev/null +++ b/x-pack/test/functional/es_archives/alerts_legacy/tasks/mappings.json @@ -0,0 +1,120 @@ +{ + "type": "index", + "value": { + "aliases": { + ".kibana_task_manager": { + } + }, + "index": ".kibana_task_manager_1", + "mappings": { + "_meta": { + "migrationMappingPropertyHashes": { + "migrationVersion": "4a1746014a75ade3a714e1db5763276f", + "namespace": "2f4316de49999235636386fe51dc06c1", + "namespaces": "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" + } + } + }, + "namespace": { + "type": "keyword" + }, + "namespaces": { + "type": "keyword" + }, + "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" + } + } + } +}