Skip to content

test: move generic Pod builder into test/framework/k8s#32

Open
chethanuk wants to merge 1 commit into
feat/1188-context-movefrom
feat/1188-k8s-builders
Open

test: move generic Pod builder into test/framework/k8s#32
chethanuk wants to merge 1 commit into
feat/1188-context-movefrom
feat/1188-k8s-builders

Conversation

@chethanuk

Copy link
Copy Markdown
Owner

What type of PR is this?

/kind cleanup
/kind test

What this PR does / why we need it:

Fourth of eight in the llm-d#1188 split. It follows the NewTestContext move. One block of
builders moves and four call sites follow it.

pkg/epp/util/testing/wrappers.go holds two unrelated things: GAIE wrappers and a
PodWrapper fluent builder over corev1.Pod. The Pod builders are plain Kubernetes
object construction, and two of their callers live outside the EPP tree under
test/integration/epp. They move to test/framework/k8s, leaving wrappers.go with
only the GAIE wrappers it is named for. The corev1 import has to drop with them or
the remaining file does not compile.

The table-driven test is here for the coverage gate, not the move. CI computes one
number across ./test/framework/... and allows a 2.0pp regression, so a package
arriving without tests drags down everything already there. It also pins Complete's
default-namespace branch, which nothing in the repo executed before.

Test plan:

  • go build and go vet ./test/... clean at this commit
  • go test ./test/framework/... passes, builders at 100% coverage

Which issue(s) this PR fixes:

Part of llm-d#1188

Release note (write NONE if no user-facing change):

NONE

The Pod builders in pkg/epp/util/testing are plain Kubernetes object helpers
with nothing EPP-specific about them, and they are used from outside the EPP
tree. Moving them to test/framework/k8s leaves wrappers.go holding only the
GAIE wrappers it is named for. The moved code is unchanged apart from the
package clause, a license header, and a package comment; the corev1 import
drops from wrappers.go because the remainder never used it.

Part of llm-d#1188

Signed-off-by: ChethanUK <chethanuk@outlook.com>
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5f6ca05b-d189-4d46-994a-d9605af5b8ba

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/1188-k8s-builders

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.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the test utilities by moving the PodWrapper helper from pkg/epp/util/testing to a new shared framework package test/framework/k8s, updating all references across test files and integration harnesses, and adding comprehensive unit tests for the builder. The review feedback points out a potential issue in FromBase where a shallow copy of the Kubernetes Pod object is used, which can lead to shared state mutation bugs in tests; it is recommended to use DeepCopy() instead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +33 to +37
func FromBase(pod *corev1.Pod) *PodWrapper {
return &PodWrapper{
Pod: *pod,
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using a shallow copy (*pod) for a Kubernetes Pod object can lead to shared state mutation bugs in tests. Since corev1.Pod contains reference types like maps (Labels, Annotations) and slices (Containers, Conditions), modifying these fields on the wrapper will inadvertently mutate the original base pod's fields if they are not reassigned.

To ensure complete isolation and prevent accidental mutations of the base pod, use DeepCopy() which is built into Kubernetes API types. Additionally, we should add a nil check to prevent a nil-pointer dereference panic.

func FromBase(pod *corev1.Pod) *PodWrapper {
	if pod == nil {
		return nil
	}
	return &PodWrapper{
		Pod: *pod.DeepCopy(),
	}
}

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.

1 participant