Skip to content

Commit

Permalink
Fix flaky RBAC Legacy test due to archive containing tasks and rules …
Browse files Browse the repository at this point in the history
…together (#153803)

Resolves #153800
Resolves #142704
Resolves #153801
Resolves #142947
Resolves #140867

Similar to
#152841 (comment),
the rule and tasks archives don't seem to play nicely when combined. The
flakiness goes away when loading the rules then the tasks in sequence.
Otherwise, the tasks sometimes run before it can find the rule, causing
the task to delete itself.

I took a look at why the task would run an not be able to find the rule.
My best guess after looking at a failing flaky test is that the task
manager migration completes before the .kibana. And while .kibana
migrates, the task runs and fails to load the task because the .kibana
index is in an interim state.

Flaky test runner:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2045

---------

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
mikecote and kibanamachine authored Mar 29, 2023
1 parent ec58ba6 commit e13f1c5
Show file tree
Hide file tree
Showing 5 changed files with 286 additions and 287 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ export default function alertTests({ getService }: FtrProviderContext) {
),
};

// Failing: See https://github.com/elastic/kibana/issues/140867
// Failing: See https://github.com/elastic/kibana/issues/142704
// Failing: See https://github.com/elastic/kibana/issues/153801
// Failing: See https://github.com/elastic/kibana/issues/153800
describe.skip('alerts', () => {
describe('alerts', () => {
const authorizationIndex = '.kibana-test-authorization';
const objectRemover = new ObjectRemover(supertest);

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);
Expand All @@ -75,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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
Loading

0 comments on commit e13f1c5

Please sign in to comment.