Skip to content

Commit

Permalink
Merge branch 'improvement/ZENKO-4941' into tmp/octopus/w/2.7/improvem…
Browse files Browse the repository at this point in the history
…ent/ZENKO-4941
  • Loading branch information
bert-e committed Dec 2, 2024
2 parents d8c5e6d + ad4ed08 commit d7f2779
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions tests/ctst/world/Zenko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AccessKey } from '@aws-sdk/client-iam';
import { Credentials } from '@aws-sdk/client-sts';
import { aws4Interceptor } from 'aws4-axios';
import qs from 'qs';
import lockFile from 'proper-lockfile';
import Werelogs from 'werelogs';
import {
CacheHelper,
Expand Down Expand Up @@ -635,22 +636,29 @@ export default class Zenko extends World<ZenkoWorldParameters> {
Identity.useIdentity(IdentityEnum.ADMIN, site.adminIdentityName);

let account = null;
CacheHelper.logger.debug('Creating account', {
accountName,
adminIdentityName: site.adminIdentityName,
credentials: Identity.getCurrentCredentials(),
});
// Create the account if already exist will not throw any error
let releaseLock: (() => Promise<void>) | null = null;
try {
await SuperAdmin.createAccount({ accountName });
/* eslint-disable */
} catch (err: any) {
CacheHelper.logger.debug('Error while creating account', {
accountName,
err,
releaseLock = await lockFile.lock('/tmp/account-init.lock', {
stale: Constants.DEFAULT_TIMEOUT / 2,
retries: {
retries: 5,
factor: 3,
minTimeout: 1000,
maxTimeout: 5000,
}
});
if (!err.EntityAlreadyExists && err.code !== 'EntityAlreadyExists') {
throw err;

try {
await SuperAdmin.createAccount({ accountName });
/* eslint-disable */
} catch (err: any) {
if (!err.EntityAlreadyExists && err.code !== 'EntityAlreadyExists') {
throw err;
}
}
} finally {
if (releaseLock) {
await releaseLock();
}
}
/* eslint-enable */
Expand Down

0 comments on commit d7f2779

Please sign in to comment.