Skip to content

refactor(provisioner): remove reflection from multi-provisioner tests#6219

Merged
devantler merged 1 commit into
mainfrom
claude/multi-provisioner-remove-reflection-6049
Jul 18, 2026
Merged

refactor(provisioner): remove reflection from multi-provisioner tests#6219
devantler merged 1 commit into
mainfrom
claude/multi-provisioner-remove-reflection-6049

Conversation

@devantler

Copy link
Copy Markdown
Contributor

🤖 Generated by the Daily AI Engineer

Why

The multi-provisioner tests inspected the Kind provisioner's private fields via reflection, so a routine rename or re-layout of those internals would silently break the tests — brittle coupling to another package's internals.

What

Adds a small injectable Kind-factory seam so the tests assert the config and kubeconfig arguments the minimal path hands to the factory directly, with no reflection. Production behaviour is unchanged (it always uses the real Kind factory). Test-only refactor — no runtime behaviour change, no flag needed.

Fixes #6049

The multi-provisioner tests reached into the Kind provisioner's unexported
kubeConfig/kindConfig fields via reflection, coupling them to internal field
names and layout. Introduce a package-level, injectable Kind factory seam
(swapped in tests via SetKindProvisionerFactory) so the tests assert the
kindConfig and kubeconfig arguments the minimal path passes to the factory
directly, with no reflection. Production always uses
kindprovisioner.CreateProvisioner, so behaviour is unchanged.

Fixes #6049

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@devantler

Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Daily AI Engineer

Readiness / tried-as-a-user (test-refactor): the exercisable surface of this change is the test suite itself, and I exercised it directly:

  • go build ./..., go vet, and golangci-lint run on the package are clean.
  • Full pkg/svc/provisioner/cluster suite: 74/74 pass with the reflection removed.
  • RED/GREEN on the seam's teeth: temporarily broke the source the two rewritten tests guard — mangled the kubeconfig forwarded to the factory (/tmp/…-kind-kubeconfig…-RED) and the kindConfig APIVersion (kind.x-k8s.io/v1alpha4BROKEN). Both spy-based tests failed on exactly those assertions; restoring the source returned them to green. So the argument assertions genuinely have teeth without reflecting over the provisioner's internals.

Production is unchanged — kindProvisionerFactory defaults to kindprovisioner.CreateProvisioner, and the existing Docker-error tests still drive the real factory.

@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

✅ Linters with no issues

actionlint, bash-exec, git_diff, hadolint, jscpd, jsonlint, lychee, markdown-table-formatter, markdownlint, prettier, prettier, shellcheck, shfmt, stylelint, syft, trivy-sbom, trufflehog, v8r, v8r, yamllint

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@github-code-quality

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: Go

Go / code-coverage/go

The overall coverage in the branch remains at 67%, unchanged from the branch.

Show a code coverage summary of the most impacted files.
File 3ff2d8c 47e0deb +/-
pkg/svc/provisi...base/bringup.go 92% 90% -2%
pkg/client/reconciler/poll.go 80% 84% +4%

Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@devantler

Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Daily AI Engineer

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 47e0debb21

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@devantler

Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Daily AI Engineer

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

@devantler I’ll review the changes in #6219.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a package-level Kind provisioner factory seam that defaults to the existing constructor and can be replaced by tests with a restore closure. Updates Vanilla-Kind tests to capture kubeconfig and v1alpha4.Cluster arguments directly, removing reflection and parallel execution. Assertions now validate the forwarded kubeconfig path and generated API version, kind, and name.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy #6049 by adding a private Kind factory seam and replacing reflection-based assertions with direct argument checks.
Out of Scope Changes check ✅ Passed The diff appears limited to the requested testability refactor and related test updates, with no clear out-of-scope work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately summarizes the main change: removing reflection from multi-provisioner tests.
Description check ✅ Passed The description directly matches the refactor and explains the new Kind factory seam and test changes.

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.

@devantler

Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Daily AI Engineer

Readiness record (self-promotion @47e0debb)

  • Programmatically tested — CI green (57 success / 12 skipped), premerge checks green (✅5), 0 unresolved threads, no reviewer body findings, CLEAN vs base. RED/GREEN proven: breaking APIVersion and the kubeconfig forward each failed exactly the two new factory-argument assertions; restoring returned them to green. 74/74 package tests; golangci / vet / gofmt clean.
  • Reviewed — Codex green at head: Didn't find any major issues, reviewed commit 47e0debb21.
  • Tried and evaluated as a user — this change's only runtime surface is the test suite itself, which was exercised in full; the injectable factory seam follows the repo's sanctioned DI pattern and the production path is unchanged.

Promoting and merging.

@devantler
devantler marked this pull request as ready for review July 18, 2026 06:17
@devantler
devantler merged commit 852e80e into main Jul 18, 2026
69 checks passed
@devantler
devantler deleted the claude/multi-provisioner-remove-reflection-6049 branch July 18, 2026 06:17
@github-project-automation github-project-automation Bot moved this from 🫴 Ready to ✅ Done in 🌊 Project Board Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Remove reflection from multi-provisioner tests

1 participant