From 0788aa657fa66aa485a66a651a2d945124042737 Mon Sep 17 00:00:00 2001 From: Thomas Flament Date: Thu, 12 Mar 2026 16:57:39 +0100 Subject: [PATCH 1/3] Add CI check for unused Cucumber step definitions Add a check-unused-steps.sh script that runs cucumber-js in dry-run mode with usage reporting to detect unused step definitions. Wire it as an npm script and add it to the lint-and-build-ctst CI job. Issue: ZENKO-5215 --- .github/workflows/end2end.yaml | 3 +++ tests/ctst/check-unused-steps.sh | 16 ++++++++++++++++ tests/ctst/package.json | 3 ++- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 tests/ctst/check-unused-steps.sh diff --git a/.github/workflows/end2end.yaml b/.github/workflows/end2end.yaml index 5900f3ad2d..9696ce214f 100644 --- a/.github/workflows/end2end.yaml +++ b/.github/workflows/end2end.yaml @@ -404,6 +404,9 @@ jobs: - name: Lint ctst tests working-directory: tests/ctst run: yarn lint + - name: Check for unused step definitions + working-directory: tests/ctst + run: yarn unused-steps - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 - name: Login to Registry diff --git a/tests/ctst/check-unused-steps.sh b/tests/ctst/check-unused-steps.sh new file mode 100755 index 0000000000..53b7cdbb90 --- /dev/null +++ b/tests/ctst/check-unused-steps.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -eu + +# Detect unused Cucumber step definitions by running a dry-run +# and checking for UNUSED entries in the usage report. +# Exit code: 0 if none found, 1 if unused steps exist. + +unused=$(cucumber-js --config cucumber.config.cjs --dry-run --format usage --parallel 1 2>&1 | grep UNUSED || true) + +if [ -n "$unused" ]; then + echo "Unused step definitions found:" + echo "$unused" + exit 1 +else + echo "No unused step definitions." +fi diff --git a/tests/ctst/package.json b/tests/ctst/package.json index 302dd188c9..22cbc312fc 100644 --- a/tests/ctst/package.json +++ b/tests/ctst/package.json @@ -37,7 +37,8 @@ }, "scripts": { "build": "tsc --build tsconfig.json", - "lint": "eslint ." + "lint": "eslint .", + "unused-steps": "bash check-unused-steps.sh" }, "resolutions": { "@azure/core-client": "1.10.1" From f9b4da835d425fa21e13eb85742f90df5fec26f3 Mon Sep 17 00:00:00 2001 From: Thomas Flament Date: Thu, 12 Mar 2026 16:57:46 +0100 Subject: [PATCH 2/3] Remove unused Cucumber step definitions Delete 4 step definitions flagged as UNUSED by the dry-run check: - Given('an account', ...) in common/common.ts - Given('{int} mpu objects ...') in common/common.ts - Then('i can get the {string} location details', ...) in azureArchive.ts - Given('a DR failing to be installed', ...) in pra.ts Issue: ZENKO-5215 --- tests/ctst/common/common.ts | 6 ------ tests/ctst/steps/azureArchive.ts | 11 ----------- tests/ctst/steps/pra.ts | 11 ----------- 3 files changed, 28 deletions(-) diff --git a/tests/ctst/common/common.ts b/tests/ctst/common/common.ts index 7bf8345081..f12828fcae 100644 --- a/tests/ctst/common/common.ts +++ b/tests/ctst/common/common.ts @@ -202,12 +202,6 @@ Given('{int} objects {string} of size {int} bytes with user metadata {string}', assert.ifError(result?.stderr || result?.err); }); -Given('{int} mpu objects {string} of size {int} bytes with user metadata {string}', - async function (this: Zenko, numberObjects: number, objectName: string, sizeBytes: number, userMD: string) { - const result = await addMultipleObjects.call(this, numberObjects, objectName, sizeBytes, userMD); - assert.ifError(result?.stderr || result?.err); - }); - Given('a tag on object {string} with key {string} and value {string}', async function (this: Zenko, objectName: string, tagKey: string, tagValue: string) { this.resetCommand(); diff --git a/tests/ctst/steps/azureArchive.ts b/tests/ctst/steps/azureArchive.ts index 2afe603643..187390e0cc 100644 --- a/tests/ctst/steps/azureArchive.ts +++ b/tests/ctst/steps/azureArchive.ts @@ -482,14 +482,3 @@ When('i change azure archive location {string} container target', { timeout: 15 await waitForZenkoToStabilize(this, true); await waitForDataServicesToStabilize(this); }); - -Then('i can get the {string} location details', async function (this: Zenko, locationName: string) { - const result = await this.managementAPIRequest('GET', `/config/overlay/view/${this.parameters.InstanceID}`); - if ('err' in result) { - assert.ifError(result.err); - } - if ('data' in result) { - const { locations } = result.data as { locations: Record }; - assert(locations[locationName]); - } -}); diff --git a/tests/ctst/steps/pra.ts b/tests/ctst/steps/pra.ts index 4542658ce0..50636d5018 100644 --- a/tests/ctst/steps/pra.ts +++ b/tests/ctst/steps/pra.ts @@ -182,17 +182,6 @@ Given('a DR installed', { timeout: installTimeout + 2000 }, async function (this return; }); -Given('a DR failing to be installed', { timeout: 130000 }, async function (this: Zenko) { - Identity.useIdentity(IdentityEnum.ACCOUNT, Zenko.sites['source'].accountName); - const credentials = Identity.getCurrentCredentials(); - await createSecret(this, 'drctl-s3-creds', { - accessKey: Buffer.from(credentials.accessKeyId).toString('base64'), - secretAccessKey: Buffer.from(credentials.secretAccessKey).toString('base64'), - }); - await installPRA(this, 'http://s3.dr.zenko.local'); - return; -}); - Then('the DR sink should be in phase {string}', { timeout: 360000 }, async function (this: Zenko, state: string) { let targetPhase; switch (state) { From df41dca636198ba703714fd0e445c4fcdf9c1121 Mon Sep 17 00:00:00 2001 From: Thomas Flament Date: Fri, 13 Mar 2026 10:19:54 +0100 Subject: [PATCH 3/3] Inline unused-steps check and drop --parallel 1 Remove the check-unused-steps.sh script and inline the command directly into the npm script. Drop --parallel 1 to use the config default parallelism. Issue: ZENKO-5215 --- tests/ctst/check-unused-steps.sh | 16 ---------------- tests/ctst/package.json | 2 +- 2 files changed, 1 insertion(+), 17 deletions(-) delete mode 100755 tests/ctst/check-unused-steps.sh diff --git a/tests/ctst/check-unused-steps.sh b/tests/ctst/check-unused-steps.sh deleted file mode 100755 index 53b7cdbb90..0000000000 --- a/tests/ctst/check-unused-steps.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -eu - -# Detect unused Cucumber step definitions by running a dry-run -# and checking for UNUSED entries in the usage report. -# Exit code: 0 if none found, 1 if unused steps exist. - -unused=$(cucumber-js --config cucumber.config.cjs --dry-run --format usage --parallel 1 2>&1 | grep UNUSED || true) - -if [ -n "$unused" ]; then - echo "Unused step definitions found:" - echo "$unused" - exit 1 -else - echo "No unused step definitions." -fi diff --git a/tests/ctst/package.json b/tests/ctst/package.json index 22cbc312fc..c934e05912 100644 --- a/tests/ctst/package.json +++ b/tests/ctst/package.json @@ -38,7 +38,7 @@ "scripts": { "build": "tsc --build tsconfig.json", "lint": "eslint .", - "unused-steps": "bash check-unused-steps.sh" + "unused-steps": "! cucumber-js --config cucumber.config.cjs --dry-run --format usage 2>&1 | grep UNUSED" }, "resolutions": { "@azure/core-client": "1.10.1"