[release-4.19] Tests: Replace all console-image flags with the PR image#1869
Conversation
When running tests in CI, replace all console images with the image for the PR being tested. This ensures the PR image is always used regardless of the OCP version being used. Made-with: Cursor
📝 WalkthroughWalkthroughA Cypress test file is updated to make the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/tests/lightspeed-install.cy.ts`:
- Around line 176-177: The arg transformation only replaces when the arg
contains '=' so it misses the separate form "--console-image <value>"; update
the logic in the args mapping (the block using
arg.startsWith('--console-image')) to also handle when arg === '--console-image'
by emitting a single joined form "--console-image=<env-value>" using
Cypress.env('CONSOLE_IMAGE') and ensuring the next token (the original value) is
not left as a separate arg (i.e., skip or remove it in the mapped output).
Target the mapping code that references the local variable arg and replace it
with this two-case handling so both "--console-image=<val>" and "--console-image
<val>" are normalized to the enforced PR image.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: eb568ad4-d266-4b60-897d-68004a2df64a
📒 Files selected for processing (1)
tests/tests/lightspeed-install.cy.ts
| arg.startsWith('--console-image') | ||
| ? arg.replace(/=.*/, `=${Cypress.env('CONSOLE_IMAGE')}`) |
There was a problem hiding this comment.
Handle split --console-image args explicitly
At Line 177, replacement only works when the arg already contains =. If CSV args are --console-image <value>, this leaves the old value untouched, so the PR image is not reliably enforced.
Suggested fix
- const args =
- csv.spec.install.spec.deployments[0].spec.template.spec.containers[0].args.map(
- (arg) =>
- arg.startsWith('--console-image')
- ? arg.replace(/=.*/, `=${Cypress.env('CONSOLE_IMAGE')}`)
- : arg,
- );
+ const consoleImage = Cypress.env('CONSOLE_IMAGE');
+ const originalArgs =
+ csv.spec.install.spec.deployments[0].spec.template.spec.containers[0].args;
+ const args: string[] = [];
+ for (let i = 0; i < originalArgs.length; i += 1) {
+ const arg = originalArgs[i];
+ if (arg === '--console-image') {
+ args.push(`--console-image=${consoleImage}`);
+ if (i + 1 < originalArgs.length && !originalArgs[i + 1].startsWith('--')) i += 1;
+ continue;
+ }
+ if (arg.startsWith('--console-image=')) {
+ args.push(`--console-image=${consoleImage}`);
+ continue;
+ }
+ args.push(arg);
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| arg.startsWith('--console-image') | |
| ? arg.replace(/=.*/, `=${Cypress.env('CONSOLE_IMAGE')}`) | |
| const consoleImage = Cypress.env('CONSOLE_IMAGE'); | |
| const originalArgs = | |
| csv.spec.install.spec.deployments[0].spec.template.spec.containers[0].args; | |
| const args: string[] = []; | |
| for (let i = 0; i < originalArgs.length; i += 1) { | |
| const arg = originalArgs[i]; | |
| if (arg === '--console-image') { | |
| args.push(`--console-image=${consoleImage}`); | |
| if (i + 1 < originalArgs.length && !originalArgs[i + 1].startsWith('--')) i += 1; | |
| continue; | |
| } | |
| if (arg.startsWith('--console-image=')) { | |
| args.push(`--console-image=${consoleImage}`); | |
| continue; | |
| } | |
| args.push(arg); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/tests/lightspeed-install.cy.ts` around lines 176 - 177, The arg
transformation only replaces when the arg contains '=' so it misses the separate
form "--console-image <value>"; update the logic in the args mapping (the block
using arg.startsWith('--console-image')) to also handle when arg ===
'--console-image' by emitting a single joined form "--console-image=<env-value>"
using Cypress.env('CONSOLE_IMAGE') and ensuring the next token (the original
value) is not left as a separate arg (i.e., skip or remove it in the mapped
output). Target the mapping code that references the local variable arg and
replace it with this two-case handling so both "--console-image=<val>" and
"--console-image <val>" are normalized to the enforced PR image.
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kyoto The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
7c47d2e
into
openshift:release-4.19
This is an automated cherry-pick of #1868
/assign kyoto
Summary by CodeRabbit