From f615fcc240db7122d6bbfd5adc6c7bc6c4399ca8 Mon Sep 17 00:00:00 2001 From: KillianG Date: Fri, 30 Aug 2024 12:08:39 +0200 Subject: [PATCH] Use cache for pra install count Issue: ZENKO-4775 --- tests/ctst/steps/pra.ts | 12 ++++++++---- tests/ctst/world/Zenko.ts | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/ctst/steps/pra.ts b/tests/ctst/steps/pra.ts index a9e663fc4c..8a9cf8d096 100644 --- a/tests/ctst/steps/pra.ts +++ b/tests/ctst/steps/pra.ts @@ -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'; @@ -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, }); @@ -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; }); diff --git a/tests/ctst/world/Zenko.ts b/tests/ctst/world/Zenko.ts index ddbe4cb5f7..c0ac4fd56e 100644 --- a/tests/ctst/world/Zenko.ts +++ b/tests/ctst/world/Zenko.ts @@ -115,8 +115,7 @@ export default class Zenko extends World { static readonly PRIMARY_SITE_NAME = 'admin'; static readonly SECONDARY_SITE_NAME = 'dradmin'; - - public praInstallCount = 0; + static readonly PRA_INSTALL_COUNT_KEY = 'praInstallCount'; /** * @constructor @@ -144,6 +143,9 @@ export default class Zenko extends World { ...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,