Skip to content

Commit 2b0534b

Browse files
committed
fix: address pre-existing bugs surfaced during refactor
- Normalize SESSION env var to strict boolean (string 'false' was truthy) - Preserve positional info in session keys (filter(Boolean) -> map) - Make namespace creation idempotent with --dry-run=client | oc apply - Make oc new-project perses-dev tolerant of existing namespace - Remove unsupported timeout arg from .should() assertion - Fix unreachable NotFound branch in namespace deletion polling - Fix pod-deletion check false-passing on CLI failures Made-with: Cursor
1 parent ac7a451 commit 2b0534b

4 files changed

Lines changed: 28 additions & 14 deletions

File tree

web/cypress/support/commands/auth-commands.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export const operatorAuthUtils = {
120120
Cypress.env('MCP_CONSOLE_IMAGE'),
121121
Cypress.env('CHA_IMAGE'),
122122
];
123-
return [...baseKey, ...envVars.filter(Boolean)];
123+
return [...baseKey, ...envVars.map((v) => v || '')];
124124
},
125125

126126
generateMPSessionKey(MP: { namespace: string; operatorName: string }): string[] {
@@ -134,7 +134,7 @@ export const operatorAuthUtils = {
134134
Cypress.env('SKIP_ALL_INSTALL'),
135135
Cypress.env('MP_IMAGE'),
136136
];
137-
return [...baseKey, ...envVars.filter(Boolean)];
137+
return [...baseKey, ...envVars.map((v) => v || '')];
138138
},
139139

140140
generateKBVSessionKey(KBV: { namespace: string; packageName: string }): string[] {
@@ -148,7 +148,7 @@ export const operatorAuthUtils = {
148148
Cypress.env('SKIP_KBV_INSTALL'),
149149
Cypress.env('KBV_UI_INSTALL'),
150150
];
151-
return [...baseKey, ...envVars.filter(Boolean)];
151+
return [...baseKey, ...envVars.map((v) => v || '')];
152152
},
153153
};
154154

web/cypress/support/commands/coo-install-commands.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const cooInstallUtils = {
2929
`oc --kubeconfig ${Cypress.env('KUBECONFIG_PATH')} apply -f ./cypress/fixtures/coo/coo-imagecontentsourcepolicy.yaml`,
3030
);
3131
cy.exec(
32-
`oc create namespace ${MCP.namespace} --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
32+
`oc create namespace ${MCP.namespace} --kubeconfig ${Cypress.env('KUBECONFIG_PATH')} --dry-run=client -o yaml | oc apply --kubeconfig ${Cypress.env('KUBECONFIG_PATH')} -f -`,
3333
);
3434
cy.exec(
3535
`oc label namespace ${MCP.namespace} openshift.io/cluster-monitoring=true --overwrite=true --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
@@ -45,7 +45,7 @@ export const cooInstallUtils = {
4545
`oc --kubeconfig ${Cypress.env('KUBECONFIG_PATH')} apply -f ./cypress/fixtures/coo/coo-imagecontentsourcepolicy.yaml`,
4646
);
4747
cy.exec(
48-
`oc create namespace ${MCP.namespace} --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
48+
`oc create namespace ${MCP.namespace} --kubeconfig ${Cypress.env('KUBECONFIG_PATH')} --dry-run=client -o yaml | oc apply --kubeconfig ${Cypress.env('KUBECONFIG_PATH')} -f -`,
4949
);
5050
cy.exec(
5151
`oc label namespace ${MCP.namespace} openshift.io/cluster-monitoring=true --overwrite=true --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
@@ -122,7 +122,7 @@ export const cooInstallUtils = {
122122
cy.byTestID('name-filter-input').should('be.visible').type('Observability{enter}');
123123
cy.get('[data-test="status-text"]', { timeout: installTimeoutMilliseconds })
124124
.eq(0)
125-
.should('contain.text', 'Succeeded', { timeout: installTimeoutMilliseconds });
125+
.should('contain.text', 'Succeeded');
126126
}
127127
},
128128

@@ -197,6 +197,10 @@ export const cooInstallUtils = {
197197
`oc get ns ${MCP.namespace} --kubeconfig ${Cypress.env('KUBECONFIG_PATH')} -o jsonpath='{.status.phase}'`,
198198
{ failOnNonZeroExit: false },
199199
).then((result) => {
200+
if (result.code !== 0) {
201+
cy.log(`${elapsed}ms - ${MCP.namespace} is successfully deleted.`);
202+
return;
203+
}
200204
const status = result.stdout.trim();
201205

202206
if (status === 'Terminating') {
@@ -211,8 +215,6 @@ export const cooInstallUtils = {
211215
}
212216
});
213217
cy.wait(checkIntervalMs).then(checkStatus);
214-
} else if (status === 'NotFound') {
215-
cy.log(`${elapsed}ms - ${MCP.namespace} is successfully deleted.`);
216218
} else {
217219
cy.log(`${elapsed}ms - ${MCP.namespace} changed to unexpected state: ${status}. Stopping monitoring.`);
218220
}
@@ -244,15 +246,27 @@ export const cooInstallUtils = {
244246
}
245247

246248
cy.exec(
247-
`oc get pods -n ${namespace} --kubeconfig ${kubeconfigPath} -o name 2>&1 | grep -E '${podPatterns}' | wc -l`,
249+
`oc get pods -n ${namespace} --kubeconfig ${kubeconfigPath} -o name`,
248250
{ failOnNonZeroExit: false },
249251
).then((result) => {
250-
const count = parseInt(result.stdout.trim(), 10);
252+
if (result.code !== 0) {
253+
if (result.stderr.includes('not found')) {
254+
cy.log(`All target pods deleted after ${elapsed}ms (namespace gone)`);
255+
} else {
256+
cy.log(`${elapsed}ms - oc get pods failed: ${result.stderr}, retrying...`);
257+
cy.wait(checkIntervalMs).then(checkPods);
258+
}
259+
return;
260+
}
261+
262+
const matchingPods = result.stdout
263+
.split('\n')
264+
.filter((line) => new RegExp(podPatterns).test(line));
251265

252-
if (count === 0 || result.stderr.includes('not found')) {
266+
if (matchingPods.length === 0) {
253267
cy.log(`All target pods deleted after ${elapsed}ms`);
254268
} else {
255-
cy.log(`${elapsed}ms - ${count} pod(s) still exist, retrying...`);
269+
cy.log(`${elapsed}ms - ${matchingPods.length} pod(s) still exist, retrying...`);
256270
cy.wait(checkIntervalMs).then(checkPods);
257271
}
258272
});

web/cypress/support/commands/dashboards-commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const dashboardsUtils = {
1717

1818
setupDashboardsAndPlugins(MCP: { namespace: string }): void {
1919
cy.log('Create perses-dev namespace.');
20-
cy.exec(`oc new-project perses-dev --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
20+
cy.exec(`oc new-project perses-dev --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`, { failOnNonZeroExit: false });
2121

2222
/**
2323
* TODO: When COO1.4.0 is released, points COO_UI_INSTALL to install dashboards on COO1.4.0 folder

web/cypress/support/commands/operator-commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ declare global {
4949
}
5050
}
5151

52-
const useSession = Cypress.env('SESSION');
52+
const useSession = String(Cypress.env('SESSION')).toLowerCase() === 'true';
5353

5454
// ── Helpers used only by the orchestration commands ────────────────
5555

0 commit comments

Comments
 (0)