From f87434b7b31dbda13522e5130fe1300b3aac769c Mon Sep 17 00:00:00 2001 From: Ying Mao Date: Tue, 1 Dec 2020 16:13:42 -0500 Subject: [PATCH] Adding delay between creating and updating alert to avoid 409 conflicts --- .../security_and_spaces/tests/alerting/delete.ts | 3 +++ .../security_and_spaces/tests/alerting/disable.ts | 3 +++ .../security_and_spaces/tests/alerting/enable.ts | 3 +++ .../security_and_spaces/tests/alerting/event_log.ts | 3 +++ .../security_and_spaces/tests/alerting/execution_status.ts | 3 +++ .../security_and_spaces/tests/alerting/update.ts | 3 +++ .../security_and_spaces/tests/alerting/update_api_key.ts | 3 +++ .../spaces_only/tests/alerting/execution_status.ts | 3 +++ 8 files changed, 24 insertions(+) diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/delete.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/delete.ts index fc453c8da72e..3dbc29edd749 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/delete.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/delete.ts @@ -301,6 +301,9 @@ export default function createDeleteTests({ getService }: FtrProviderContext) { .send(getTestAlertData()) .expect(200); + // Delay before performing update to avoid 409 errors + await new Promise((resolve) => setTimeout(resolve, 1000)); + await supertest .put( `${getUrlPrefix(space.id)}/api/alerts_fixture/saved_object/alert/${createdAlert.id}` diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/disable.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/disable.ts index 4e4f9053bd24..39edc4e170ad 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/disable.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/disable.ts @@ -287,6 +287,9 @@ export default function createDisableAlertTests({ getService }: FtrProviderConte .expect(200); objectRemover.add(space.id, createdAlert.id, 'alert', 'alerts'); + // Delay before performing update to avoid 409 errors + await new Promise((resolve) => setTimeout(resolve, 1000)); + await supertest .put( `${getUrlPrefix(space.id)}/api/alerts_fixture/saved_object/alert/${createdAlert.id}` diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts index d7f6546bf34a..34ef1a4c960f 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts @@ -304,6 +304,9 @@ export default function createEnableAlertTests({ getService }: FtrProviderContex .expect(200); objectRemover.add(space.id, createdAlert.id, 'alert', 'alerts'); + // Delay before performing update to avoid 409 errors + await new Promise((resolve) => setTimeout(resolve, 1000)); + await supertest .put( `${getUrlPrefix(space.id)}/api/alerts_fixture/saved_object/alert/${createdAlert.id}` diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/event_log.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/event_log.ts index 385d8bfca4a9..49db5c365038 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/event_log.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/event_log.ts @@ -37,6 +37,9 @@ export default function eventLogTests({ getService }: FtrProviderContext) { const alertId = response.body.id; objectRemover.add(spaceId, alertId, 'alert', 'alerts'); + // Delay before performing update to avoid 409 errors + await new Promise((resolve) => setTimeout(resolve, 1000)); + // break AAD await supertest .put(`${getUrlPrefix(spaceId)}/api/alerts_fixture/saved_object/alert/${alertId}`) diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/execution_status.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/execution_status.ts index 4058b7135628..896525de9520 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/execution_status.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/execution_status.ts @@ -37,6 +37,9 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon let executionStatus = await waitForStatus(alertId, new Set(['ok']), 10000); + // Delay before performing update to avoid 409 errors + await new Promise((resolve) => setTimeout(resolve, 1000)); + // break AAD await supertest .put(`${getUrlPrefix(spaceId)}/api/alerts_fixture/saved_object/alert/${alertId}`) diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts index 9c3d2801c088..377b421e390d 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts @@ -429,6 +429,9 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { .expect(200); objectRemover.add(space.id, createdAlert.id, 'alert', 'alerts'); + // Delay before performing update to avoid 409 errors + await new Promise((resolve) => setTimeout(resolve, 1000)); + await supertest .put( `${getUrlPrefix(space.id)}/api/alerts_fixture/saved_object/alert/${createdAlert.id}` diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update_api_key.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update_api_key.ts index 7dea591b895e..7f3a4c32ab53 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update_api_key.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update_api_key.ts @@ -301,6 +301,9 @@ export default function createUpdateApiKeyTests({ getService }: FtrProviderConte .expect(200); objectRemover.add(space.id, createdAlert.id, 'alert', 'alerts'); + // Delay before performing update to avoid 409 errors + await new Promise((resolve) => setTimeout(resolve, 1000)); + await supertest .put( `${getUrlPrefix(space.id)}/api/alerts_fixture/saved_object/alert/${createdAlert.id}` diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/execution_status.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/execution_status.ts index 642173a7c2c6..7fcfef3b1c67 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/execution_status.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/execution_status.ts @@ -196,6 +196,9 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon let executionStatus = await waitForStatus(alertId, new Set(['ok'])); + // Delay before performing update to avoid 409 errors + await new Promise((resolve) => setTimeout(resolve, 1000)); + // break the validation of the params await supertest .put(`${getUrlPrefix(Spaces.space1.id)}/api/alerts_fixture/saved_object/alert/${alertId}`)