Skip to content

NO-JIRA: add ENVTEST_JOBS knob for parallel envtest execution#8243

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
jparrill:parallel-env-test
Apr 15, 2026
Merged

NO-JIRA: add ENVTEST_JOBS knob for parallel envtest execution#8243
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
jparrill:parallel-env-test

Conversation

@jparrill
Copy link
Copy Markdown
Contributor

@jparrill jparrill commented Apr 15, 2026

Summary

  • Add ENVTEST_JOBS variable to control parallel execution of envtest API validation suites
  • ENVTEST_JOBS=0 (default): sequential execution, backward compatible
  • ENVTEST_JOBS=N: run up to N versions in parallel
  • ENVTEST_JOBS=MAX: run all versions in parallel (auto-detects count from version list)
  • Each version runs in its own isolated envtest environment (etcd + kube-apiserver on random ports), so there are no conflicts between parallel runs
  • Assets are pre-fetched sequentially before parallel execution to avoid download race conditions

Usage

make test-envtest-ocp ENVTEST_JOBS=3     # 3 OCP versions in parallel
make test-envtest-ocp ENVTEST_JOBS=MAX   # all 6 OCP versions in parallel
make test-envtest-kube ENVTEST_JOBS=MAX  # all 5 kube versions in parallel
make test-envtest-api-all ENVTEST_JOBS=MAX

Test plan

  • make test-envtest-ocp (no ENVTEST_JOBS) runs sequentially as before
  • make test-envtest-ocp ENVTEST_JOBS=3 runs with 3 parallel jobs
  • make test-envtest-ocp ENVTEST_JOBS=MAX runs all 6 OCP versions in parallel
  • make test-envtest-kube ENVTEST_JOBS=MAX runs all 5 kube versions in parallel
  • Verify no test failures due to inter-version conflicts

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Configurable parallel execution for environment tests via ENVTEST_JOBS: 0 = sequential (default), N = up to N parallel version suites, MAX = all versions in parallel. Parallel mode pre-fetches test assets and runs isolated envtest instances for each version, with per-version logs and fail-on-fetch behavior.
  • Documentation

    • Updated testing docs and make target help with usage examples and guidance for ENVTEST_JOBS.

@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: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 15, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@jparrill: This pull request explicitly references no jira issue.

Details

In response to this:

Summary

  • Add ENVTEST_JOBS variable to control parallel execution of envtest API validation suites
  • ENVTEST_JOBS=0 (default): sequential execution, backward compatible
  • ENVTEST_JOBS=N: run up to N versions in parallel
  • ENVTEST_JOBS=MAX: run all versions in parallel (auto-detects count from version list)
  • Each version runs in its own isolated envtest environment (etcd + kube-apiserver on random ports), so there are no conflicts between parallel runs
  • Assets are pre-fetched sequentially before parallel execution to avoid download race conditions

Usage

make test-envtest-ocp ENVTEST_JOBS=3     # 3 OCP versions in parallel
make test-envtest-ocp ENVTEST_JOBS=MAX   # all 6 OCP versions in parallel
make test-envtest-kube ENVTEST_JOBS=MAX  # all 5 kube versions in parallel
make test-envtest-api-all ENVTEST_JOBS=MAX

Test plan

  • make test-envtest-ocp (no ENVTEST_JOBS) runs sequentially as before
  • make test-envtest-ocp ENVTEST_JOBS=3 runs with 3 parallel jobs
  • make test-envtest-ocp ENVTEST_JOBS=MAX runs all 6 OCP versions in parallel
  • make test-envtest-kube ENVTEST_JOBS=MAX runs all 5 kube versions in parallel
  • Verify no test failures due to inter-version conflicts

🤖 Generated with Claude Code

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 openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: 41d97a60-384d-4dfe-8448-c99945d7c5f0

📥 Commits

Reviewing files that changed from the base of the PR and between 80bb3fe and d8ab273.

📒 Files selected for processing (2)
  • Makefile
  • test/envtest/README.md
✅ Files skipped from review due to trivial changes (1)
  • test/envtest/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • Makefile

📝 Walkthrough

Walkthrough

This pull request adds ENVTEST_JOBS ?= 0 to the Makefile to control envtest execution mode. ENVTEST_JOBS=0 preserves the prior sequential per-Kubernetes-version loop; a numeric value or MAX switches to a two-phase flow that pre-fetches envtest assets for all configured versions, then runs per-version test jobs in parallel via a new internal pattern target _run-single-envtest-%. Targets updated: test-envtest-ocp, test-envtest-kube, and test-envtest-api-all. test/envtest/README.md gains a "Parallel execution" section documenting usage.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Make as Make (main)
    participant Fetch as Asset Fetch
    participant Parallel as Parallel Make<br/>(v1..vN)
    participant Test as Test Runner<br/>(_run-single-envtest-%)

    User->>Make: make test-envtest-kube<br/>ENVTEST_JOBS=3
    Make->>Fetch: Pre-fetch envtest assets<br/>for all versions
    Fetch-->>Make: Assets ready
    Make->>Parallel: make -j3 _run-single-envtest-v1 _run-single-envtest-v2 _run-single-envtest-v3
    par Parallel Execution
        Parallel->>Test: run v1 test
        Parallel->>Test: run v2 test
        Parallel->>Test: run v3 test
    and
        Test->>Test: go test -tags envtest<br/>(isolated env v1)
        Test->>Test: go test -tags envtest<br/>(isolated env v2)
        Test->>Test: go test -tags envtest<br/>(isolated env v3)
    end
    Test-->>Parallel: Results
    Parallel-->>Make: All tests done
    Make-->>User: Complete
Loading
sequenceDiagram
    participant User
    participant Make as Make (main)
    participant Test as Test Runner<br/>(_run-single-envtest-%)

    User->>Make: make test-envtest-kube<br/>ENVTEST_JOBS=0
    rect rgba(200, 100, 100, 0.5)
    Note over Make,Test: Sequential execution (per-version)
    end
    loop For each version (v1, v2, v3...)
        Make->>Test: _run-single-envtest-v1
        Test->>Test: Fetch assets + go test
        Test-->>Make: Complete
        Make->>Test: _run-single-envtest-v2
        Test->>Test: Fetch assets + go test
        Test-->>Make: Complete
    end
    Make-->>User: All tests done
Loading
🚥 Pre-merge checks | ✅ 10
✅ Passed checks (10 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding an ENVTEST_JOBS variable to enable parallel envtest execution, which aligns with all changes in the Makefile and documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Stable And Deterministic Test Names ✅ Passed This PR only modifies Makefile and documentation, not Ginkgo test files or test names. The custom check does not apply.
Test Structure And Quality ✅ Passed PR modifies only Makefile and test/envtest/README.md. No Ginkgo test code files (containing It/Describe blocks) are being added or modified. Changes are infrastructure and documentation only.
Microshift Test Compatibility ✅ Passed This PR does not add any new Ginkgo e2e tests. The changes are purely infrastructure-related: they add parallel execution capability to the Makefile for existing envtest runs and update documentation.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR does not add new Ginkgo e2e tests; it only modifies Makefile and README for test execution control.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies only test infrastructure (Makefile and test/envtest/README.md) to add ENVTEST_JOBS parallelization. No deployment manifests, operators, or pod scheduling constraints are introduced.
Ote Binary Stdout Contract ✅ Passed PR only modifies Makefile and documentation for test execution infrastructure; no Go source code changes or OTE binary code present.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This pull request does not add any new Ginkgo e2e tests, only infrastructure modifications to the Makefile and documentation updates.

✏️ 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 review from bryan-cox and muraee April 15, 2026 08:43
@openshift-ci openshift-ci bot added the area/testing Indicates the PR includes changes for e2e testing label Apr 15, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 15, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jparrill

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed do-not-merge/needs-area labels Apr 15, 2026
@jparrill
Copy link
Copy Markdown
Contributor Author

jparrill commented Apr 15, 2026

This is how looks like the execution in local:

make test-envtest-kube ENVTEST_JOBS=MAX
GO111MODULE=on GOWORK=off GOFLAGS=-mod=vendor go generate ./...
=== Pre-fetching Kubernetes envtest assets ===
  Fetching K8s 1.31.0...
  Fetching K8s 1.32.0...
  Fetching K8s 1.33.0...
  Fetching K8s 1.34.0...
  Fetching K8s 1.35.0...
=== Running Kubernetes envtest in parallel (jobs=5) ===
=== Running envtest for K8s 1.33.0 ===
ok      github.com/openshift/hypershift/test/envtest    153.709s
=== Running envtest for K8s 1.31.0 ===
ok      github.com/openshift/hypershift/test/envtest    153.841s
=== Running envtest for K8s 1.32.0 ===
ok      github.com/openshift/hypershift/test/envtest    154.823s
=== Running envtest for K8s 1.34.0 ===
ok      github.com/openshift/hypershift/test/envtest    154.935s
=== Running envtest for K8s 1.35.0 ===
ok      github.com/openshift/hypershift/test/envtest    166.690s
=== All Kubernetes envtest versions passed ===

Copy link
Copy Markdown
Contributor

@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

🧹 Nitpick comments (1)
Makefile (1)

368-369: Add upfront validation for ENVTEST_JOBS to fail early with clear error messages.

Currently, invalid values (e.g., ENVTEST_JOBS=abc or negative numbers) pass through to make -j... on lines 401 and 432, causing vague parallelism errors. Adding a check near the target entry catches this immediately.

Suggested fix
 test-envtest-ocp: generate $(SETUP_ENVTEST) ## Run envtest tests for all supported OCP versions (ENVTEST_JOBS=0|N|MAX)
+	`@if` ! echo "$(ENVTEST_JOBS)" | grep -Eq '^(0|MAX|[1-9][0-9]*)$$'; then \
+		echo "Invalid ENVTEST_JOBS='$(ENVTEST_JOBS)'. Use 0, MAX, or a positive integer."; \
+		exit 2; \
+	fi
 ifeq ($(ENVTEST_JOBS),0)
@@
 test-envtest-kube: generate $(SETUP_ENVTEST) ## Run envtest tests for all supported Kubernetes versions (ENVTEST_JOBS=0|N|MAX)
+	`@if` ! echo "$(ENVTEST_JOBS)" | grep -Eq '^(0|MAX|[1-9][0-9]*)$$'; then \
+		echo "Invalid ENVTEST_JOBS='$(ENVTEST_JOBS)'. Use 0, MAX, or a positive integer."; \
+		exit 2; \
+	fi
 ifeq ($(ENVTEST_JOBS),0)

Also applies to lines 410–411.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 368 - 369, Add upfront validation for the ENVTEST_JOBS
Make variable so invalid values (non-integer, negative) fail fast with a clear
message; detect the special "MAX" token or a non-negative integer, and if the
value is invalid call $(error ...) from the Makefile before any make
-j$(ENVTEST_JOBS) invocations (referencing the ENVTEST_JOBS variable and the
targets that run make -j), e.g., insert a validation block near the target entry
that checks ENVTEST_JOBS with make functions (filter, or shell test via
expr/grep) and emits a descriptive error like "ENVTEST_JOBS must be 'MAX' or a
non-negative integer" when the check fails.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Makefile`:
- Around line 389-392: The envtest prefetch loops (iterating over
ENVTEST_OCP_K8S_VERSIONS and the other mirror loop) currently redirect
$(SETUP_ENVTEST) output to /dev/null but do not abort on failure; update both
loops so the $(SETUP_ENVTEST) use ... $$k8s_ver > /dev/null command is followed
by a failure guard (e.g. || exit 1 or || { echo "Failed to fetch envtest assets
for $$k8s_ver"; exit 1; }) so that failures in SETUP_ENVTEST cause the Makefile
to stop instead of continuing with stale/missing assets; apply the same change
to the second loop that uses ENVTEST_OCP_ASSETS_DIR/ENVTEST_OCP_INDEX to ensure
both prefetch loops fail fast.

---

Nitpick comments:
In `@Makefile`:
- Around line 368-369: Add upfront validation for the ENVTEST_JOBS Make variable
so invalid values (non-integer, negative) fail fast with a clear message; detect
the special "MAX" token or a non-negative integer, and if the value is invalid
call $(error ...) from the Makefile before any make -j$(ENVTEST_JOBS)
invocations (referencing the ENVTEST_JOBS variable and the targets that run make
-j), e.g., insert a validation block near the target entry that checks
ENVTEST_JOBS with make functions (filter, or shell test via expr/grep) and emits
a descriptive error like "ENVTEST_JOBS must be 'MAX' or a non-negative integer"
when the check fails.
🪄 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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: af7ffe58-75df-4809-ab0f-e9ea8202a559

📥 Commits

Reviewing files that changed from the base of the PR and between 9b4b004 and 90a83ff.

📒 Files selected for processing (2)
  • Makefile
  • test/envtest/README.md

Comment thread Makefile
@jparrill jparrill force-pushed the parallel-env-test branch from 90a83ff to 80bb3fe Compare April 15, 2026 08:54
Copy link
Copy Markdown
Contributor

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

♻️ Duplicate comments (1)
Makefile (1)

394-397: ⚠️ Potential issue | 🟠 Major

Fail fast on envtest asset prefetch failures.

Both prefetch loops ignore setup-envtest exit status. A failed fetch can silently continue and only fail later with harder-to-debug test errors.

Suggested fix
 	`@for` k8s_ver in $(ENVTEST_OCP_K8S_VERSIONS); do \
 		echo "  Fetching K8s $$k8s_ver..."; \
-		$(SETUP_ENVTEST) use --use-env --bin-dir $(ENVTEST_OCP_ASSETS_DIR) -p path --index $(ENVTEST_OCP_INDEX) $$k8s_ver > /dev/null; \
+		$(SETUP_ENVTEST) use --use-env --bin-dir $(ENVTEST_OCP_ASSETS_DIR) -p path --index $(ENVTEST_OCP_INDEX) $$k8s_ver > /dev/null || { echo "Failed to fetch envtest assets for $$k8s_ver"; exit 1; }; \
 	done
@@
 	`@for` k8s_ver in $(ENVTEST_KUBE_VERSIONS); do \
 		echo "  Fetching K8s $$k8s_ver..."; \
-		$(SETUP_ENVTEST) use --use-env --bin-dir $(ENVTEST_KUBE_ASSETS_DIR) -p path $$k8s_ver > /dev/null; \
+		$(SETUP_ENVTEST) use --use-env --bin-dir $(ENVTEST_KUBE_ASSETS_DIR) -p path $$k8s_ver > /dev/null || { echo "Failed to fetch envtest assets for $$k8s_ver"; exit 1; }; \
 	done

Also applies to: 425-428

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 394 - 397, The envtest prefetch loops ignore the exit
status of the setup-envtest command, allowing failures to be swallowed; update
the loops that call $(SETUP_ENVTEST) (the blocks iterating over
ENVTEST_OCP_K8S_VERSIONS and the similar loop at lines 425-428) to detect
failures and fail fast—e.g., run $(SETUP_ENVTEST) ... $$k8s_ver and if it
returns non-zero then print an error referencing ENVTEST_OCP_ASSETS_DIR and
ENVTEST_OCP_INDEX and exit with a non-zero status (use shell conditional or "||
exit 1") so any fetch failure aborts immediately.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@Makefile`:
- Around line 394-397: The envtest prefetch loops ignore the exit status of the
setup-envtest command, allowing failures to be swallowed; update the loops that
call $(SETUP_ENVTEST) (the blocks iterating over ENVTEST_OCP_K8S_VERSIONS and
the similar loop at lines 425-428) to detect failures and fail fast—e.g., run
$(SETUP_ENVTEST) ... $$k8s_ver and if it returns non-zero then print an error
referencing ENVTEST_OCP_ASSETS_DIR and ENVTEST_OCP_INDEX and exit with a
non-zero status (use shell conditional or "|| exit 1") so any fetch failure
aborts immediately.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: f7bbc945-07bb-4b32-8c36-0900cc53b059

📥 Commits

Reviewing files that changed from the base of the PR and between 90a83ff and 80bb3fe.

📒 Files selected for processing (2)
  • Makefile
  • test/envtest/README.md
✅ Files skipped from review due to trivial changes (1)
  • test/envtest/README.md

Allow running envtest API validation suites in parallel across
Kubernetes versions via ENVTEST_JOBS (0=sequential, N=parallel jobs,
MAX=all versions at once). Each version gets its own isolated envtest
environment so there are no conflicts between runs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Juan Manuel Parrilla Madrid <jparrill@redhat.com>
@jparrill jparrill force-pushed the parallel-env-test branch from 80bb3fe to d8ab273 Compare April 15, 2026 09:04
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 34.65%. Comparing base (9b4b004) to head (d8ab273).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8243   +/-   ##
=======================================
  Coverage   34.65%   34.65%           
=======================================
  Files         767      767           
  Lines       93263    93263           
=======================================
  Hits        32318    32318           
  Misses      58266    58266           
  Partials     2679     2679           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@muraee
Copy link
Copy Markdown
Contributor

muraee commented Apr 15, 2026

/lgtm

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

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aks
/test e2e-aws
/test e2e-aws-upgrade-hypershift-operator
/test e2e-azure-self-managed
/test e2e-kubevirt-aws-ovn-reduced
/test e2e-v2-aws

@cwbotbot
Copy link
Copy Markdown

cwbotbot commented Apr 15, 2026

Test Results

e2e-aws

e2e-aks

@bryan-cox
Copy link
Copy Markdown
Member

/verified by envtests

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Apr 15, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@bryan-cox: This PR has been marked as verified by envtests.

Details

In response to this:

/verified by envtests

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 15, 2026

@jparrill: all tests passed!

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 openshift-merge-bot bot merged commit aa9ecf2 into openshift:main Apr 15, 2026
38 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. area/testing Indicates the PR includes changes for e2e testing jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants