From a08b64be5acc9c600ce49de81227f23209e8f828 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Fri, 23 Aug 2024 15:06:01 +0200 Subject: [PATCH] Test that federated metrics are retrieved Issue: ZENKO-4876 --- tests/ctst/features/pra.feature | 3 ++- tests/ctst/steps/pra.ts | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/tests/ctst/features/pra.feature b/tests/ctst/features/pra.feature index f0aede1e32..0199b137b2 100644 --- a/tests/ctst/features/pra.feature +++ b/tests/ctst/features/pra.feature @@ -18,7 +18,8 @@ Feature: PRA operations Given a DR installed Then the DR source should be in phase "Running" And the DR sink should be in phase "Running" - Then the kafka DR volume exists + And the kafka DR volume exists + And prometheus should scrap federated metrics from DR sink # Check that objects are transitioned in the DR site Given access keys for the replicated account diff --git a/tests/ctst/steps/pra.ts b/tests/ctst/steps/pra.ts index f8cc5a1725..5fe0739a06 100644 --- a/tests/ctst/steps/pra.ts +++ b/tests/ctst/steps/pra.ts @@ -15,6 +15,7 @@ import { } from 'steps/utils/utils'; import { CacheHelper, Constants, Identity, IdentityEnum, SuperAdmin, Utils } from 'cli-testing'; import { safeJsonParse } from 'common/utils'; +import { PrometheusDriver } from 'prometheus-query'; import assert from 'assert'; import { EntityType } from 'world/Zenko'; @@ -328,8 +329,25 @@ Then('the kafka DR volume exists', { timeout: volumeTimeout + 2000 }, async func assert(volumeParsed.result!['volume phase'] === 'Bound'); }); +Then('prometheus should scrap federated metrics from DR sink', { timeout: 70000 }, async function (this: Zenko) { + const prom = new PrometheusDriver({ + endpoint: `http://${this.parameters.PrometheusService}:9090`, + baseURL: '/api/v1', + }); + + for (;;) { + const t = Date.now(); + const metrics = await prom.series('{drSinkInstance="end2end-pra-sink"}', t - 60 * 1000, t); + if (metrics.length > 0) { + break; + } + + await Utils.sleep(1000); + } +}); + const failoverTimeout = 360000; -When ('I request the failover state for the DR', { timeout: failoverTimeout + 2000 }, async function (this: Zenko) { +When('I request the failover state for the DR', { timeout: failoverTimeout + 2000 }, async function (this: Zenko) { await this.zenkoDrCtl?.failover({ sinkZenkoDrNamespace: 'default', sinkZenkoDrInstance: 'end2end-pra-sink', @@ -339,7 +357,7 @@ When ('I request the failover state for the DR', { timeout: failoverTimeout + 20 }); const failbackTimeout = 360000; -When ('I resume operations for the DR', { timeout: failbackTimeout + 2000 }, async function (this: Zenko) { +When('I resume operations for the DR', { timeout: failbackTimeout + 2000 }, async function (this: Zenko) { await this.zenkoDrCtl?.failback({ sinkZenkoDrNamespace: 'default', sinkZenkoDrInstance: 'end2end-pra-sink',