Skip to content

Commit

Permalink
Use cache for pra install count
Browse files Browse the repository at this point in the history
Issue: ZENKO-4775
  • Loading branch information
KillianG authored and francoisferrand committed Sep 26, 2024
1 parent ba15a55 commit f615fcc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions tests/ctst/steps/pra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
restoreObject,
verifyObjectLocation,
} from 'steps/utils/utils';
import { Constants, Identity, IdentityEnum, S3, SuperAdmin, Utils } from 'cli-testing';
import { CacheHelper, Constants, Identity, IdentityEnum, S3, SuperAdmin, Utils } from 'cli-testing';
import { safeJsonParse } from 'common/utils';
import { PrometheusDriver } from 'prometheus-query';
import assert from 'assert';
Expand Down Expand Up @@ -73,7 +73,7 @@ async function installPRA(world: Zenko, sinkS3Endpoint = 'http://s3.zenko.local'
// prometheusHostname: 'prom.dr.zenko.local', // could be any name, cert will be auto-generated
prometheusExternalIpsDiscovery: true,
prometheusDisableTls: true,
forceRotateServiceCredentials: world.praInstallCount > 0,
forceRotateServiceCredentials: (CacheHelper.savedAcrossTests[Zenko.PRA_INSTALL_COUNT_KEY] as number) > 0,
...kafkaExternalIpOption,
timeout,
});
Expand Down Expand Up @@ -174,8 +174,12 @@ Given('a DR installed', { timeout: installTimeout + 2000 }, async function (this
accessKey: Buffer.from(credentials.accessKeyId).toString('base64'),
secretAccessKey: Buffer.from(credentials.secretAccessKey).toString('base64'),
});
await installPRA(this, undefined, `${installTimeout.toString()}ms`);
this.praInstallCount += 1;

// Timeout is set to 1 second less than the cucumber
// timeout to see the command timeout instead of the step timeout

await installPRA(this, undefined, `${(installTimeout - 1000).toString()}ms`);
(CacheHelper.savedAcrossTests[Zenko.PRA_INSTALL_COUNT_KEY] as number) += 1;
return;
});

Expand Down
6 changes: 4 additions & 2 deletions tests/ctst/world/Zenko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ export default class Zenko extends World<ZenkoWorldParameters> {

static readonly PRIMARY_SITE_NAME = 'admin';
static readonly SECONDARY_SITE_NAME = 'dradmin';

public praInstallCount = 0;
static readonly PRA_INSTALL_COUNT_KEY = 'praInstallCount';

/**
* @constructor
Expand Down Expand Up @@ -144,6 +143,9 @@ export default class Zenko extends World<ZenkoWorldParameters> {
...this.parameters,
});

CacheHelper.savedAcrossTests[Zenko.PRA_INSTALL_COUNT_KEY] = 0;


if (this.parameters.AccountName && !Identity.hasIdentity(IdentityEnum.ACCOUNT, this.parameters.AccountName)) {
Identity.addIdentity(IdentityEnum.ACCOUNT, this.parameters.AccountName, {
accessKeyId: this.parameters.AccountAccessKey,
Expand Down

0 comments on commit f615fcc

Please sign in to comment.