Repository navigation
cleanup: use helper for update modes in recommender tests - #9976
kubernetes-prow[bot] merged 3 commits into
Conversation
Signed-off-by: tanayarun <[email protected]>
|
This issue is currently awaiting triage. If SIG Autoscaling contributors determines this is a relevant issue, they will accept it by applying the The DetailsInstructions 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. |
|
Hi @tanayarun. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
Welcome @tanayarun! |
omerap12
left a comment
There was a problem hiding this comment.
Thanks for opening this. There are some issues that need to be addressed.
| } | ||
|
|
||
| for _, mode := range sortedUpdateModes() { | ||
| mode := mode |
There was a problem hiding this comment.
My bad, removed. The extra copy was not needed here.
| // vpa_types.GetUpdateModes helper, in a deterministic order. Sourcing the | ||
| // modes from the helper (instead of a hardcoded list) ensures these tests | ||
| // automatically pick up any new UpdateMode added to the API. | ||
| func sortedUpdateModes() []vpa_types.UpdateMode { |
There was a problem hiding this comment.
Why do we need to sort the update modes?
There was a problem hiding this comment.
GetUpdateModes() returns a map, so iteration order is non deterministic. I added sorting to keep the generated subtest order stable across runs and make test output deterministic.
There was a problem hiding this comment.
I don't think that's necessary. having this should suffice:
diff --git a/vertical-pod-autoscaler/pkg/utils/metrics/recommender/recommender_test.go b/vertical-pod-autoscaler/pkg/utils/metrics/recommender/recommender_test.go
index 8cc00e2d2..fe59ec1c3 100644
--- a/vertical-pod-autoscaler/pkg/utils/metrics/recommender/recommender_test.go
+++ b/vertical-pod-autoscaler/pkg/utils/metrics/recommender/recommender_test.go
@@ -317,7 +317,7 @@ func labelsToKey(labels []*dto.LabelPair) string {
}
func TestObjectCounterResetsAllUpdateModes(t *testing.T) {
- for _, mode := range sortedUpdateModes() {
+ for mode := range vpa_types.GetUpdateModes() {
t.Run(string(mode), func(t *testing.T) {
t.Cleanup(func() {
vpaObjectCount.Reset()There was a problem hiding this comment.
gotcha, I've removed the helper and now iterate directly over GetUpdateModes().
omerap12
left a comment
There was a problem hiding this comment.
Thanks!
/ok-to-test
/lgtm
/assign @adrianmoisey
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adrianmoisey, tanayarun The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Both
TestObjectCounterandTestObjectCounterResetsAllUpdateModesinrecommender_test.gohardcoded the list of VPA update modes, so they silently missedInPlaceand would miss any future mode as well.This PR adds a shared
sortedUpdateModes()helper (derived fromvpa_types.GetUpdateModes()) and uses it in both tests, keeping test coverage in sync with the supported API update modes and eliminating the need to manually update multiple test cases whenever a new mode is added.Which issue(s) this PR fixes:
Fixes #9971
Special notes for your reviewer:
Verified that all update modes returned by
GetUpdateModes(), includingInPlace, are covered by both tests.Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: