Skip to content

chore(test): assert info state mutations and build errors in TestFlux- Fixes #3409#3410

Open
gojogourav wants to merge 2 commits intokubeflow:masterfrom
gojogourav:update-flux-tests
Open

chore(test): assert info state mutations and build errors in TestFlux- Fixes #3409#3410
gojogourav wants to merge 2 commits intokubeflow:masterfrom
gojogourav:update-flux-tests

Conversation

@gojogourav
Copy link
Copy Markdown

Why:

  • Previously, the TestFlux table-driven tests only verified the final generated Kubernetes objects and container properties.
  • Expanded the test cases to explicitly assert against wantInfo, wantMLPolicyError, and wantBuildError.
  • This ensures that EnforceMLPolicy and Build correctly mutate the internal runtime.Info state and bubble up appropriate error values, preventing silent regressions in the plugin's state management.

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in Fixes #<issue number>, #<issue number>, ... format, will close the issue(s) when PR gets merged):
Fixes #

Checklist:

  • Docs included if any changes are user facing

Why:
- Previously, the TestFlux table-driven tests only verified the final generated Kubernetes objects and container properties.
- Expanded the test cases to explicitly assert against wantInfo, wantMLPolicyError, and wantBuildError.
- This ensures that EnforceMLPolicy and Build correctly mutate the internal runtime.Info state and bubble up appropriate error values, preventing silent regressions in the plugin's state management.

Signed-off-by: gojogourav <gojogourav@gmail.com>
Copilot AI review requested due to automatic review settings April 5, 2026 17:39
@google-oss-prow
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign johnugeorge for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands the TestFlux table-driven tests to explicitly assert against Info state mutations and error values returned from the plugin's EnforceMLPolicy and Build methods. Previously, the tests only verified the final generated Kubernetes objects and container properties. The changes replace fatal error assertions with comparative error checks and add detailed state verification.

Changes:

  • Add wantInfo, wantMLPolicyError, and wantBuildError fields to the test case struct
  • Replace t.Fatalf error assertions with gocmp.Diff comparisons using cmpopts.EquateErrors()
  • Add comprehensive Info state comparison after EnforceMLPolicy calls with appropriate comparison options

Comment on lines 76 to +95
"flux mutations are applied correctly": {

wantInfo: &runtime.Info{
RuntimePolicy: runtime.RuntimePolicy{
MLPolicySource: &trainer.MLPolicySource{
Flux: &trainer.FluxMLPolicySource{
NumProcPerNode: &procs,
},
},
},
TemplateSpec: runtime.TemplateSpec{
PodSets: []runtime.PodSet{
{
Name: constants.Node,
Ancestor: ptr.To(constants.AncestorTrainer),
Count: ptr.To[int32](1),
},
},
},
},
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

The second test case is missing explicit wantMLPolicyError and wantBuildError field assignments for consistency with the first test case. Add wantMLPolicyError: nil and wantBuildError: nil to clarify the expected behavior.

Copilot generated this review using guidance from repository custom instructions.
Signed-off-by: gojogourav <gojogourav@gmail.com>
@gojogourav gojogourav changed the title test(flux): assert info state mutations and build errors in TestFlux chore(flux): assert info state mutations and build errors in TestFlux Apr 5, 2026
@gojogourav gojogourav changed the title chore(flux): assert info state mutations and build errors in TestFlux chore(test): assert info state mutations and build errors in TestFlux Apr 5, 2026
@gojogourav gojogourav changed the title chore(test): assert info state mutations and build errors in TestFlux chore(test): assert info state mutations and build errors in TestFlux- Fixes #3409 Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants