From 65ea43daa7430e3bffd60f1563194a035413d765 Mon Sep 17 00:00:00 2001 From: Sanket Dharwadkar Date: Wed, 29 Sep 2021 11:19:36 -0400 Subject: [PATCH] fix: integ test setup flakiness fix (#727) --- main/integration-tests/support/setup.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/main/integration-tests/support/setup.js b/main/integration-tests/support/setup.js index 5581ff4267..bf0faf3b67 100644 --- a/main/integration-tests/support/setup.js +++ b/main/integration-tests/support/setup.js @@ -18,6 +18,7 @@ const _ = require('lodash'); const jwtDecode = require('jwt-decode'); +const { retry } = require('@aws-ee/base-services/lib/helpers/utils'); const Settings = require('./utils/settings'); const { getIdToken } = require('./utils/id-token'); @@ -261,10 +262,17 @@ class Setup { * Use this function to gain access to a setup instance that is initialized and ready to be used. */ async function runSetup() { - const setupInstance = new Setup(); - await setupInstance.init(); + const tryCreateSetup = async () => { + const setupInstance = new Setup(); + await setupInstance.init(); - return setupInstance; + if (!setupInstance) throw Error('Setup instance did not initialize'); + return setupInstance; + }; + + // Retry 3 times using an exponential interval + const setup = await retry(tryCreateSetup, 3); + return setup; } module.exports = { runSetup };