@gooddata/fixtures
Advanced tools
Comparing version 1.32.18 to 1.32.19
@@ -45,2 +45,7 @@ // (C) 2022 GoodData Corporation | ||
async function ensureWSCreated(sdkTiger, wsId) { | ||
Logger.logLn(`ensure ws crreated ${wsId}`); | ||
await sdkTiger.entities.getEntityWorkspaces({ id: wsId }); | ||
} | ||
async function createTigerWorkspace(workspaceTitle, token, host, backend, parentWorkspaceId) { | ||
@@ -73,2 +78,7 @@ const sdkTiger = getTigerBackendSdk(token, host, backend); | ||
}); | ||
Logger.logLn(`created workspace ${workspaceResponse.data.data.id}`); | ||
await retryOperation(() => ensureWSCreated(sdkTiger, `${workspaceResponse.data.data.id}`)); | ||
return workspaceResponse.data.data.id; | ||
@@ -104,8 +114,3 @@ } | ||
const sdkTiger = getTigerBackendSdk(token, host, backend); | ||
// STL-302 admit eventual consistency and change tests to retry/wait | ||
retryOperation( | ||
() => sdkTiger.declarativeLayout.putWorkspaceLayout({ workspaceId, declarativeWorkspaceModel }), | ||
10, | ||
1000 | ||
); | ||
await sdkTiger.declarativeLayout.putWorkspaceLayout({ workspaceId, declarativeWorkspaceModel }); | ||
} | ||
@@ -112,0 +117,0 @@ |
{ | ||
"name": "@gooddata/fixtures", | ||
"version": "1.32.18", | ||
"version": "1.32.19", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
20
utils.js
// (C) 2007-2022 GoodData Corporation | ||
const { log } = require('./logger'); | ||
function partial(fn, ...others) { | ||
@@ -15,14 +13,10 @@ return (...args) => { | ||
async function retryOperation(operation, maxRetries, delayMs) { | ||
for (let i = 0; i < maxRetries; i += 1) { | ||
try { | ||
/* eslint-disable no-await-in-loop */ | ||
return await operation(); | ||
} catch (err) { | ||
log(`Attempt ${i} failed, retrying after ${delayMs}ms. \n`); | ||
/* eslint-disable no-await-in-loop */ | ||
await delay(delayMs); | ||
} | ||
function retryOperation(operation, retries = 10, delayms = 1000, err = null) { | ||
if (retries === 0) { | ||
return Promise.reject(err); | ||
} | ||
throw new Error(`Operation failed after ${maxRetries} attempts.`); | ||
return operation().catch((error) => { | ||
delay(delayms); | ||
return retryOperation(operation, (retries - 1), delayms, error); | ||
}); | ||
} | ||
@@ -29,0 +23,0 @@ |
310154871
15098