Skip to content

fix: use go run gotestsum instead of calling gotestsum directly#5206

Open
nestoracunablanco wants to merge 1 commit into
openshift:mainfrom
nestoracunablanco:fix/makeUnitTests
Open

fix: use go run gotestsum instead of calling gotestsum directly#5206
nestoracunablanco wants to merge 1 commit into
openshift:mainfrom
nestoracunablanco:fix/makeUnitTests

Conversation

@nestoracunablanco

@nestoracunablanco nestoracunablanco commented May 27, 2026

Copy link
Copy Markdown

This ensures that the tool will be available in the environments

Summary

This PR modifies the test execution script (hack/test-go.sh) to dynamically fetch and run the gotestsum test runner via go run gotest.tools/gotestsum@latest instead of relying on a pre-installed binary.

What Changed

The Go test runner invocation was updated from calling a pre-installed gotestsum binary to dynamically downloading and executing it using Go's go run mechanism. This change preserves all existing functionality including JUnit report generation, package selection, race condition detection, and custom test flags.

Practical Impact for CI Operators

This change eliminates a build-time dependency requirement for test execution environments. Previously, CI jobs needed to ensure gotestsum was pre-installed in their container images or execution environments. Now, the tool is automatically fetched at runtime when the test script runs, similar to how developers might use go run locally for tools. This makes the testing infrastructure more self-contained and reduces environmental setup complexity.

The modification specifically impacts how the ci-tools project runs its own unit and integration tests, making the test workflow more reliable and less dependent on pre-provisioned tooling in CI containers.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci openshift-ci Bot requested review from hector-vido and smg247 May 27, 2026 11:36
@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

hack/test-go.sh replaces the direct gotestsum binary invocation with go run gotest.tools/gotestsum@latest. All existing arguments — JUnit output, package selection, -race, and TESTFLAGS — are preserved unchanged.

Changes

gotestsum invocation

Layer / File(s) Summary
go run gotestsum invocation
hack/test-go.sh
Replaces the bare gotestsum binary call with go run gotest.tools/gotestsum@latest; all CLI arguments remain identical.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Container-Privileges ❌ Error PR adds Kubernetes manifests with allowPrivilegeEscalation: true in 3 new files: nested-podman/rbac.yaml, zz_fixture_TestGeneratePods_enable_nested_podman.yaml, and zz_fixture_TestGeneratePods_leas... Remove allowPrivilegeEscalation: true from container specs or justify the necessity for privilege escalation in these test/reference manifests.
✅ Passed checks (16 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: switching from calling gotestsum directly to using 'go run gotestsum'. This aligns with the core modification in hack/test-go.sh.
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.
Go Error Handling ✅ Passed PR modifies only hack/test-go.sh (bash script), not Go code. The Go error handling check is inapplicable to shell script modifications.
Test Coverage For New Features ✅ Passed PR modifies hack/test-go.sh (shell script) to install gotestsum before running tests. This is a configuration/tooling change exempt from test coverage requirements per the check's exceptions for "c...
Stable And Deterministic Test Names ✅ Passed PR modifies hack/test-go.sh for gotestsum installation; no Ginkgo test titles are added or modified, making this check not applicable.
Test Structure And Quality ✅ Passed Custom check for Ginkgo test quality is not applicable; PR modifies only hack/test-go.sh (shell script), and repository contains no Ginkgo tests.
Microshift Test Compatibility ✅ Passed This PR modifies the test runner infrastructure (hack/test-go.sh) but does not add any new Ginkgo e2e tests. The check only applies when new tests are added, making it inapplicable here.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests added. PR modifies only hack/test-go.sh shell script for gotestsum invocation. Check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies only hack/test-go.sh, a test runner script. Topology-aware scheduling check applies only to deployment manifests, operator code, and controllers—none of which are modified here.
Ote Binary Stdout Contract ✅ Passed PR modifies shell script (hack/test-go.sh) to invoke gotestsum differently. The OTE Binary Stdout Contract check applies to OTE binary implementations, which this PR does not create or modify. No G...
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR adds no new Ginkgo e2e tests. The change only adds a shell script (hack/test-go.sh) that invokes gotestsum. IPv6/disconnected network compatibility check is not applicable.
No-Weak-Crypto ✅ Passed PR modifies test runner script (hack/test-go.sh) to invoke gotestsum via go run. No cryptographic code, weak crypto patterns (MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB), custom crypto implementation...
No-Sensitive-Data-In-Logs ✅ Passed No sensitive data (passwords, tokens, API keys, PII, or credentials) is added to logs. The PR only changes the gotestsum invocation method while maintaining existing xtrace behavior.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ 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 and usage tips.

@openshift-ci openshift-ci Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 27, 2026
@openshift-ci

openshift-ci Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Hi @nestoracunablanco. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Makefile (1)

144-144: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add gotestsum install to the e2e target (it calls hack/test-go.sh which requires it).

hack/test-go.sh runs gotestsum directly (Makefile hack/test-go.sh line 11) but only the test target installs gotest.tools/gotestsum@latest. make e2e currently calls hack/test-go.sh without installing gotestsum, so it can fail when gotestsum isn’t already present.

🔧 Proposed fix
e2e: $(TMPDIR)/.boskos-credentials
+	go install gotest.tools/gotestsum@latest
 	BOSKOS_CREDENTIALS_FILE="$(TMPDIR)/.boskos-credentials" PACKAGES="$(PACKAGES)" TESTFLAGS="$(TESTFLAGS) -tags $(TAGS) -timeout 70m -parallel 100" hack/test-go.sh
🤖 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 `@Makefile` at line 144, The e2e Makefile target calls hack/test-go.sh which
expects gotestsum to be installed but e2e doesn’t install it; update the e2e
target (the rule invoking hack/test-go.sh) to install gotestsum the same way the
test target does (e.g., run the go install gotest.tools/gotestsum@latest step)
before calling hack/test-go.sh so hack/test-go.sh can use gotestsum reliably;
reference the Makefile e2e target and hack/test-go.sh when making the change.
🤖 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.

Outside diff comments:
In `@Makefile`:
- Line 144: The e2e Makefile target calls hack/test-go.sh which expects
gotestsum to be installed but e2e doesn’t install it; update the e2e target (the
rule invoking hack/test-go.sh) to install gotestsum the same way the test target
does (e.g., run the go install gotest.tools/gotestsum@latest step) before
calling hack/test-go.sh so hack/test-go.sh can use gotestsum reliably; reference
the Makefile e2e target and hack/test-go.sh when making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 9bb6d2ab-83fe-4c7e-9b82-d8ea566e8521

📥 Commits

Reviewing files that changed from the base of the PR and between 628dff0 and 2839c56.

📒 Files selected for processing (1)
  • Makefile

@nestoracunablanco

Copy link
Copy Markdown
Author

@hector-vido @smg247 , what do you think about this change?

@nestoracunablanco

Copy link
Copy Markdown
Author

/pj-rehearse ack

@bear-redhat

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jun 12, 2026
@openshift-ci

openshift-ci Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bear-redhat, nestoracunablanco

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 Jun 12, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 4b8b1c4 and 2 for PR HEAD a3d73d1 in total

@nestoracunablanco

Copy link
Copy Markdown
Author

/test ci/prow/breaking-changes
/test ci/prow/integration
/test ci/prow/unit
/test ci/prow/e2e

@nestoracunablanco

Copy link
Copy Markdown
Author

/test breaking-changes
/test integration
/test unit
/test e2e

@openshift-ci

openshift-ci Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

@nestoracunablanco: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/test ci/prow/breaking-changes
/test ci/prow/integration
/test ci/prow/unit
/test ci/prow/e2e

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 Jun 15, 2026

Copy link
Copy Markdown
Contributor

@nestoracunablanco: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/test breaking-changes
/test integration
/test unit
/test e2e

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-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 074066f and 1 for PR HEAD a3d73d1 in total

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 98989ed and 0 for PR HEAD a3d73d1 in total

@openshift-ci

openshift-ci Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

@nestoracunablanco: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/breaking-changes a3d73d1 link false /test breaking-changes
ci/prow/unit a3d73d1 link true /test unit

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/hold

Revision a3d73d1 was retested 3 times: holding

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 16, 2026
This ensures that the tool will be available in the environments

Signed-off-by: nestoracunablanco <nestor.acuna@ibm.com>
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 17, 2026
@openshift-ci

openshift-ci Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

@nestoracunablanco nestoracunablanco changed the title fix: gotestsum instllation before running tests fix: use go run gotestsum instead of calling gotestsum directly Jun 17, 2026
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. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants