Skip to content

Commit

Permalink
Adding delay between creating and updating alert to avoid 409 conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ymao1 committed Dec 1, 2020
1 parent d8643f7 commit f87434b
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand Down

0 comments on commit f87434b

Please sign in to comment.