Skip to content

add the ability to run one test - #63

Merged
weshayutin merged 1 commit into
medik8s:mainfrom
weshayutin:focus
Aug 4, 2026
Merged

add the ability to run one test#63
weshayutin merged 1 commit into
medik8s:mainfrom
weshayutin:focus

Conversation

@weshayutin

@weshayutin weshayutin commented Aug 3, 2026

Copy link
Copy Markdown

gingko --focus is a nice way to develop one test
at a time or just execute one test at a time.
Using an env var "ECO_TEST_FOCUS"

Parameterize the timeout from a hardcoded 24h
to default 24h and 30m for one test

Summary by CodeRabbit

  • New Features

    • Added support for configuring test timeouts through ECO_TEST_TIMEOUT.
    • Added an optional ECO_TEST_FOCUS setting to run a specific test.
  • Documentation

    • Documented the new test configuration options with usage examples.
    • Updated example output to show the applied timeout and focus settings.

gingko --focus is a nice way to develop one test
at a time or just execute one test at a time.
Using an env var "ECO_TEST_FOCUS"

Parameterize the timeout from a hardcoded 24h
to default 24h and 30m for one test

Signed-off-by: Wesley Hayutin <weshayutin@gmail.com>
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Test runner configuration

Layer / File(s) Summary
Test runner configuration flow
scripts/test-runner.sh
The runner defaults ECO_TEST_TIMEOUT to 24 hours, passes it to Ginkgo, and conditionally adds ECO_TEST_FOCUS as a quoted --focus filter.
Configuration usage documentation
README.md
The README documents both variables and shows focused SNR test execution with a 30-minute timeout.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: ugreener, maximunited

🚥 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: support for running one focused 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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@qodo-2-for-medik8s

Copy link
Copy Markdown

PR Summary by Qodo

Add single-test focus and configurable timeout to ginkgo test runner

✨ Enhancement 📝 Documentation 🕐 10-20 Minutes

Grey Divider

AI Description

• Add ECO_TEST_FOCUS to run a specific ginkgo test by name substring.
• Parameterize ginkgo timeout via ECO_TEST_TIMEOUT (default 24h).
• Document focused test workflow and recommended shorter timeout for iteration.
Diagram

graph TD
  Dev[Developer] --> Make["make run-tests"] --> Runner["scripts/test-runner.sh"] --> Ginkgo["ginkgo CLI"]
  Env["Env vars\n(ECO_TEST_*)"] --> Runner
  Runner --> Tests["./tests/<feature>"]
  README["README.md"] --> Dev

  subgraph Legend
    direction LR
    _human[Human] ~~~ _cmd[Command/Script] ~~~ _cfg[Config] ~~~ _doc[Docs]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Generic pass-through (e.g., ECO_GINKGO_ARGS)
  • ➕ Avoids adding a new env var for each ginkgo flag over time
  • ➕ Lets advanced users pass any supported ginkgo option without script changes
  • ➖ Less discoverable than dedicated variables documented in README
  • ➖ Harder to validate/quote safely in shell compared to targeted options
2. Support focus via positional/CLI args to test-runner.sh
  • ➕ More conventional interface for local development (explicit CLI flags)
  • ➕ Avoids exporting env vars in interactive workflows
  • ➖ Would require designing and maintaining an argument parser/usage output
  • ➖ May conflict with existing pass-through of user args to ginkgo

Recommendation: Keep the PR’s current approach: dedicated ECO_TEST_FOCUS and ECO_TEST_TIMEOUT are consistent with existing ECO_TEST_* configuration patterns (e.g., labels/verbosity) and are easy to document and support in CI. If additional ginkgo knobs are requested frequently in the future, consider adding a single generic ECO_GINKGO_ARGS as an extension rather than proliferating many one-off env vars.

Files changed (2) +32 / -1

Enhancement (1) +7 / -1
test-runner.shAdd focus flag and configurable timeout to ginkgo invocation +7/-1

Add focus flag and configurable timeout to ginkgo invocation

• Introduces 'ECO_TEST_TIMEOUT' (default '24h') and uses it to set ginkgo's '-timeout'. Adds support for 'ECO_TEST_FOCUS', appending '--focus="..."' when provided to run a single test (or matching tests).

scripts/test-runner.sh

Documentation (1) +25 / -0
README.mdDocument 'ECO_TEST_FOCUS' and 'ECO_TEST_TIMEOUT' usage +25/-0

Document 'ECO_TEST_FOCUS' and 'ECO_TEST_TIMEOUT' usage

• Adds documentation for running a single ginkgo test using 'ECO_TEST_FOCUS'. Introduces 'ECO_TEST_TIMEOUT' in the documented env var list and provides examples for shortening timeout when iterating on one test.

README.md

@qodo-2-for-medik8s

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 13 rules

Grey Divider


Action required

1. Env var command injection 🐞 Bug ⛨ Security
Description
scripts/test-runner.sh now interpolates user-controlled ECO_TEST_TIMEOUT (and ECO_TEST_FOCUS) into a
command string that is executed with eval, allowing shell metacharacters in those env vars to
alter execution (up to arbitrary command execution). This also makes focus strings containing quotes
break the generated command line instead of being passed as a literal focus value.
Code

scripts/test-runner.sh[48]

+cmd="${GINKGO} -timeout=${ECO_TEST_TIMEOUT} --keep-going --require-suite --randomize-all -r"
Relevance

●●● Strong

Security hardening against command-string injection/sanitization has been accepted before (e.g.,
validate interpolated paths in PR #41).

PR-#41

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The script sources ECO_TEST_TIMEOUT from the environment, injects it into the ginkgo command string,
and executes that string via eval, which re-parses shell metacharacters. The newly added
ECO_TEST_FOCUS is also embedded in quotes inside the string, so embedded " in the focus value will
terminate the quote and corrupt parsing under eval.

scripts/test-runner.sh[7-71]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`scripts/test-runner.sh` constructs a single string `cmd+=...` that includes user-controlled env vars (`ECO_TEST_TIMEOUT`, `ECO_TEST_FOCUS`) and then executes it via `eval`. This allows shell parsing of untrusted content and breaks if focus contains quotes.

## Issue Context
The PR changed timeout from hardcoded `24h` to `${ECO_TEST_TIMEOUT}` and added `--focus="${ECO_TEST_FOCUS}"`, expanding the attack surface of the existing `eval` pattern.

## Fix Focus Areas
- scripts/test-runner.sh[7-71]

## Implementation guidance
- Replace the string-based command construction with a bash array, e.g.:
 - `cmd=("$GINKGO" "-timeout=$ECO_TEST_TIMEOUT" "--keep-going" "--require-suite" "--randomize-all" "-r")`
 - If `ECO_TEST_LABELS` set: `cmd+=("--label-filter=$ECO_TEST_LABELS")`
 - If `ECO_TEST_FOCUS` set: `cmd+=("--focus=$ECO_TEST_FOCUS")`
 - Append user args safely: `cmd+=("$@")`
 - Append feature dirs safely (ideally as an array too).
- Execute without `eval`: `printf '%q ' "${cmd[@]}"; echo` then `"${cmd[@]}"`.
- (Optional) Validate `ECO_TEST_TIMEOUT` format and fail fast with a clear error if invalid.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

2. README command output mismatch 🐞 Bug ⚙ Maintainability
Description
The new README examples for running with ECO_TEST_FOCUS/ECO_TEST_TIMEOUT show ginkgo commands
without --randomize-all, but the runner script always includes --randomize-all; users copying
the displayed output won’t reproduce actual runner behavior.
Code

README.md[R130-131]

+ginkgo -timeout=24h --keep-going --require-suite -r --focus="should remediate a worker node after kubelet stop" ./tests/snr-operator
+```
Relevance

●●● Strong

Team often updates READMEs to match real behavior; multiple README-alignment suggestions accepted
(PRs #52, #17).

PR-#52
PR-#17

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
README’s new focused-run output lines omit --randomize-all, while the script’s constructed command
includes it unconditionally.

README.md[119-141]
scripts/test-runner.sh[47-66]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
README examples for focused runs show the emitted ginkgo command but omit `--randomize-all`, which the runner script always includes.

## Issue Context
This is introduced by the newly added example blocks under the `ECO_TEST_FOCUS`/`ECO_TEST_TIMEOUT` documentation.

## Fix Focus Areas
- README.md[119-141]

## Implementation guidance
- Update the example command lines to include `--randomize-all`, or explicitly label the command snippets as illustrative and not exact runner output.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Comment thread scripts/test-runner.sh

# Build ginkgo command
cmd="${GINKGO} -timeout=24h --keep-going --require-suite --randomize-all -r"
cmd="${GINKGO} -timeout=${ECO_TEST_TIMEOUT} --keep-going --require-suite --randomize-all -r"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Env var command injection 🐞 Bug ⛨ Security

scripts/test-runner.sh now interpolates user-controlled ECO_TEST_TIMEOUT (and ECO_TEST_FOCUS) into a
command string that is executed with eval, allowing shell metacharacters in those env vars to
alter execution (up to arbitrary command execution). This also makes focus strings containing quotes
break the generated command line instead of being passed as a literal focus value.
Agent Prompt
## Issue description
`scripts/test-runner.sh` constructs a single string `cmd+=...` that includes user-controlled env vars (`ECO_TEST_TIMEOUT`, `ECO_TEST_FOCUS`) and then executes it via `eval`. This allows shell parsing of untrusted content and breaks if focus contains quotes.

## Issue Context
The PR changed timeout from hardcoded `24h` to `${ECO_TEST_TIMEOUT}` and added `--focus="${ECO_TEST_FOCUS}"`, expanding the attack surface of the existing `eval` pattern.

## Fix Focus Areas
- scripts/test-runner.sh[7-71]

## Implementation guidance
- Replace the string-based command construction with a bash array, e.g.:
  - `cmd=("$GINKGO" "-timeout=$ECO_TEST_TIMEOUT" "--keep-going" "--require-suite" "--randomize-all" "-r")`
  - If `ECO_TEST_LABELS` set: `cmd+=("--label-filter=$ECO_TEST_LABELS")`
  - If `ECO_TEST_FOCUS` set: `cmd+=("--focus=$ECO_TEST_FOCUS")`
  - Append user args safely: `cmd+=("$@")`
  - Append feature dirs safely (ideally as an array too).
- Execute without `eval`: `printf '%q ' "${cmd[@]}"; echo` then `"${cmd[@]}"`.
- (Optional) Validate `ECO_TEST_TIMEOUT` format and fail fast with a clear error if invalid.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread README.md
Comment on lines +130 to +131
ginkgo -timeout=24h --keep-going --require-suite -r --focus="should remediate a worker node after kubelet stop" ./tests/snr-operator
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational

2. Readme command output mismatch 🐞 Bug ⚙ Maintainability

The new README examples for running with ECO_TEST_FOCUS/ECO_TEST_TIMEOUT show ginkgo commands
without --randomize-all, but the runner script always includes --randomize-all; users copying
the displayed output won’t reproduce actual runner behavior.
Agent Prompt
## Issue description
README examples for focused runs show the emitted ginkgo command but omit `--randomize-all`, which the runner script always includes.

## Issue Context
This is introduced by the newly added example blocks under the `ECO_TEST_FOCUS`/`ECO_TEST_TIMEOUT` documentation.

## Fix Focus Areas
- README.md[119-141]

## Implementation guidance
- Update the example command lines to include `--randomize-all`, or explicitly label the command snippets as illustrative and not exact runner output.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
scripts/test-runner.sh (1)

48-48: 🔒 Security & Privacy | 🔵 Trivial | 🏗️ Heavy lift

Avoid passing environment values through eval.

ECO_TEST_TIMEOUT and ECO_TEST_FOCUS are inserted into cmd, then Line 70 reparses the string. Quotes added at Line 64 do not escape shell syntax inside the value. A value containing shell metacharacters can execute additional commands. Build cmd as a Bash array and invoke "${cmd[@]}". Convert the existing label, positional-argument, and feature-directory appends as part of the same change.

Verify whether CI can supply these variables from untrusted input.

Also applies to: 61-70

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/test-runner.sh` at line 48, Replace the string-based command
construction and eval-based execution in the test runner with a Bash array,
including Ginkgo options, ECO_TEST_TIMEOUT, ECO_TEST_FOCUS, labels, positional
arguments, and feature directories; invoke it with `"${cmd[@]}"` so variable
contents cannot be reparsed as shell syntax. Check CI configuration for
untrusted values supplied to these environment variables and preserve the
existing argument behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/test-runner.sh`:
- Line 7: Update scripts/test-runner.sh at lines 7-7 to default ECO_TEST_TIMEOUT
to 30m when ECO_TEST_FOCUS is set and 24h otherwise, while preserving any
explicit ECO_TEST_TIMEOUT value. Update README.md lines 100-104 to document both
defaults, and lines 119-141 to show focused runs using the automatic 30m timeout
without a manual override.

---

Nitpick comments:
In `@scripts/test-runner.sh`:
- Line 48: Replace the string-based command construction and eval-based
execution in the test runner with a Bash array, including Ginkgo options,
ECO_TEST_TIMEOUT, ECO_TEST_FOCUS, labels, positional arguments, and feature
directories; invoke it with `"${cmd[@]}"` so variable contents cannot be
reparsed as shell syntax. Check CI configuration for untrusted values supplied
to these environment variables and preserve the existing argument behavior.
🪄 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: Pro Plus

Run ID: d2a0c401-7325-42bf-8979-27a03311d16b

📥 Commits

Reviewing files that changed from the base of the PR and between dc232c8 and 9092883.

📒 Files selected for processing (2)
  • README.md
  • scripts/test-runner.sh

Comment thread scripts/test-runner.sh
GOPATH="${GOPATH:-${HOME}/go}"
PATH=$PATH:$GOPATH/bin
TEST_DIR="./tests"
ECO_TEST_TIMEOUT="${ECO_TEST_TIMEOUT:-24h}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Implement and document the focused-test timeout default.

The runner always selects 24h, so the documentation compensates with a manual 30m override. Select 30m automatically when ECO_TEST_FOCUS is set, then align the documentation with that contract.

  • scripts/test-runner.sh#L7-L7: derive the default from ECO_TEST_FOCUS, while preserving explicit ECO_TEST_TIMEOUT.
  • README.md#L100-L104: document 24h for normal runs and 30m for focused runs.
  • README.md#L119-L141: show the focused command using the automatic 30m timeout.
📍 Affects 2 files
  • scripts/test-runner.sh#L7-L7 (this comment)
  • README.md#L100-L104
  • README.md#L119-L141
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/test-runner.sh` at line 7, Update scripts/test-runner.sh at lines 7-7
to default ECO_TEST_TIMEOUT to 30m when ECO_TEST_FOCUS is set and 24h otherwise,
while preserving any explicit ECO_TEST_TIMEOUT value. Update README.md lines
100-104 to document both defaults, and lines 119-141 to show focused runs using
the automatic 30m timeout without a manual override.

@weshayutin

Copy link
Copy Markdown
Author

I wonder if we can throw more ai at this review.. lolz

@weshayutin

Copy link
Copy Markdown
Author

@ugreener please review

@ugreener ugreener left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

/lgtm

@abrugaro abrugaro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

/lgtm

@ugreener

ugreener commented Aug 4, 2026

Copy link
Copy Markdown

/pj-rehearse ack

@JonahSussman JonahSussman left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown

@JonahSussman: changing LGTM is restricted to collaborators

Details

In response to this:

LGTM

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abrugaro, eemcmullan, jmontleon, JonahSussman, slintes, ugreener, weshayutin

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:
  • OWNERS [abrugaro,eemcmullan,jmontleon,ugreener,weshayutin]

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

@weshayutin
weshayutin merged commit 11c924d into medik8s:main Aug 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants