Skip to content

Refactor ModelServing tests to use workloadRoleReplicas#867

Merged
volcano-sh-bot merged 1 commit intovolcano-sh:mainfrom
nalan2012:nalan2012-patch-2
Apr 7, 2026
Merged

Refactor ModelServing tests to use workloadRoleReplicas#867
volcano-sh-bot merged 1 commit intovolcano-sh:mainfrom
nalan2012:nalan2012-patch-2

Conversation

@nalan2012
Copy link
Copy Markdown
Contributor

Updated createBasicModelServing calls to include workloadRoleReplicas parameter for consistency across tests.
What type of PR is this?

What this PR does / why we need it:
optimize the createBasicModelServing funcs and use the func consistently in the test case, lower maintenance overhead in the future.

Which issue(s) this PR fixes:
Fixes #859

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Updated createBasicModelServing calls to include workloadRoleReplicas parameter for consistency across tests.

Signed-off-by: shuguansheng <[email protected]>
Copilot AI review requested due to automatic review settings April 3, 2026 09:48
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

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 ModelServing E2E tests by updating the createBasicModelServing helper function to include a workloadRoleReplicas parameter and a default RolloutStrategy. Feedback indicates that the new parameter's behavior is misleading because it is ignored when explicit roles are provided. Additionally, hardcoding a non-standard MaxUnavailable value in a basic helper is discouraged as it may mask issues or make test configurations less transparent.

return workloadRoleReplicas
}

func createBasicModelServing(name string, servingGroupReplicas, workloadRoleReplicas int32, roles ...workload.Role) *workload.ModelServing {
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

The workloadRoleReplicas parameter is only utilized when the roles variadic argument is empty. In several test cases (e.g., TestModelServingServingGroupRecreate at line 306 or TestModelServingControllerManagerRestart at line 1242), a value of 0 is passed but silently ignored because explicit roles are provided. This makes the helper's API misleading.

Consider renaming the parameter to defaultRoleReplicas to clarify that it only applies to the generated default role, or refactoring the helper to use a configuration struct to avoid passing ignored positional arguments.

Comment on lines +944 to +951
RolloutStrategy: &workload.RolloutStrategy{
Type: workload.ServingGroupRollingUpdate,
RollingUpdateConfiguration: &workload.RollingUpdateConfiguration{
MaxUnavailable: &intstr.IntOrString{
IntVal: 2, // maxUnavailable = 2
},
},
},
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

The createBasicModelServing helper now hardcodes a RolloutStrategy with MaxUnavailable: 2. This is problematic for two reasons:

  1. It deviates from the API default (1), meaning almost all tests using this helper are now running with a non-standard configuration that might mask or introduce unexpected behaviors.
  2. It makes tests that specifically verify rolling update constraints (like TestModelServingRollingUpdateMaxUnavailable) less transparent, as the magic number 2 is hidden inside the helper rather than being explicit in the test body.

It is recommended to remove this hardcoded strategy from the "Basic" helper. Tests that require a specific MaxUnavailable value should configure it explicitly on the returned object.

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 refactors ModelServing E2E tests to use a helper function (createBasicModelServing) consistently across test cases, aiming to reduce maintenance overhead. The PR adds a new workloadRoleReplicas parameter to the helper function and consolidates duplicated ModelServing creation logic.

Changes:

  • Added new workloadRoleReplicas parameter to createBasicModelServing function signature to control default role replica counts
  • Created a new getWorkloadRoleReplicas helper function that defaults to 1 replica when 0 is passed
  • Refactored test calls to use createBasicModelServing consistently, replacing inline ModelServing definitions
  • Removed unused k8s.io/utils/ptr import
  • Important behavioral change: Added a default RolloutStrategy with maxUnavailable=2 to all ModelServings created by createBasicModelServing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +944 to +951
RolloutStrategy: &workload.RolloutStrategy{
Type: workload.ServingGroupRollingUpdate,
RollingUpdateConfiguration: &workload.RollingUpdateConfiguration{
MaxUnavailable: &intstr.IntOrString{
IntVal: 2, // maxUnavailable = 2
},
},
},
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The addition of RolloutStrategy with maxUnavailable=2 to the createBasicModelServing function changes the behavior of ALL tests using this helper. Previously, only the two rolling update-specific tests explicitly set this strategy. Now it's applied globally. This could unintentionally affect tests that don't expect this behavior, such as TestModelServingLifecycle, TestModelServingScaleUp, TestModelServingScaleDown, etc. The RolloutStrategy might alter scaling and update behavior in ways those tests are not designed to handle. Consider either: (1) removing the RolloutStrategy from createBasicModelServing and applying it only where needed, (2) adding a parameter to control whether the strategy is applied, or (3) documenting why all tests should have this strategy.

Suggested change
RolloutStrategy: &workload.RolloutStrategy{
Type: workload.ServingGroupRollingUpdate,
RollingUpdateConfiguration: &workload.RollingUpdateConfiguration{
MaxUnavailable: &intstr.IntOrString{
IntVal: 2, // maxUnavailable = 2
},
},
},

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@LiZhenCheng9527 LiZhenCheng9527 left a comment

Choose a reason for hiding this comment

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

/lgtm

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu, LiZhenCheng9527

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

@volcano-sh-bot volcano-sh-bot merged commit 0d90eb6 into volcano-sh:main Apr 7, 2026
17 of 18 checks passed
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.

E2E Test use createBasicModelServing functions in a consistent way

5 participants