Skip to content

[release-4.19] Tests: Replace all console-image flags with the PR image#1869

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:release-4.19from
openshift-cherrypick-robot:cherry-pick-1868-to-release-4.19
Apr 24, 2026
Merged

[release-4.19] Tests: Replace all console-image flags with the PR image#1869
openshift-merge-bot[bot] merged 1 commit intoopenshift:release-4.19from
openshift-cherrypick-robot:cherry-pick-1868-to-release-4.19

Conversation

@openshift-cherrypick-robot
Copy link
Copy Markdown

@openshift-cherrypick-robot openshift-cherrypick-robot commented Apr 24, 2026

This is an automated cherry-pick of #1868

/assign kyoto

Summary by CodeRabbit

  • Tests
    • Improved the Lightspeed operator test to handle configuration flag detection more flexibly, ensuring proper patching of environment-specific values.

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
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

📝 Walkthrough

Walkthrough

A Cypress test file is updated to make the --console-image flag detection more flexible when patching the Lightspeed operator CSV. The rewritten argument now matches the flag without requiring an = symbol and replaces any existing suffix with the proper environment variable assignment.

Changes

Cohort / File(s) Summary
Test Argument Parsing
tests/tests/lightspeed-install.cy.ts
Updated container args rewriting logic to detect --console-image flag more flexibly, matching with or without =, and consistently rewrite with ${Cypress.env('CONSOLE_IMAGE')}.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A flag now bends without the =,
More flexible our test arrays,
The console-image finds its way,
With Cypress magic, all's at ease,
Small tweaks, big wins—hooray! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: updating tests to replace console-image flags with the PR image, which aligns with the commit message and file changes in the Cypress test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot requested a review from kyoto April 24, 2026 06:40
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9abbc4f and 44407e6.

📒 Files selected for processing (1)
  • tests/tests/lightspeed-install.cy.ts

Comment on lines +176 to +177
arg.startsWith('--console-image')
? arg.replace(/=.*/, `=${Cypress.env('CONSOLE_IMAGE')}`)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Suggested change
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.

@kyoto
Copy link
Copy Markdown
Member

kyoto commented Apr 24, 2026

/approve
/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 24, 2026
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Apr 24, 2026

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 24, 2026
@openshift-merge-bot openshift-merge-bot Bot merged commit 7c47d2e into openshift:release-4.19 Apr 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants