Skip to content

Commit

Permalink
Address review comments from kwiesmueller
Browse files Browse the repository at this point in the history
  • Loading branch information
ialidzhikov committed Jul 2, 2024
1 parent c29cb95 commit 216b0ac
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
16 changes: 14 additions & 2 deletions vertical-pod-autoscaler/pkg/recommender/model/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ import (
)

var (
ctx = context.Background()

testPodID = PodID{"namespace-1", "pod-1"}
testPodID3 = PodID{"namespace-1", "pod-3"}
testPodID4 = PodID{"namespace-1", "pod-4"}
Expand Down Expand Up @@ -100,6 +98,8 @@ func TestClusterAddSample(t *testing.T) {
}

func TestClusterGCAggregateContainerStateDeletesOld(t *testing.T) {
ctx := context.Background()

// Create a pod with a single container.
cluster := NewClusterState(testGcPeriod)
vpa := addTestVpa(cluster)
Expand All @@ -123,6 +123,8 @@ func TestClusterGCAggregateContainerStateDeletesOld(t *testing.T) {
}

func TestClusterGCAggregateContainerStateDeletesOldEmpty(t *testing.T) {
ctx := context.Background()

// Create a pod with a single container.
cluster := NewClusterState(testGcPeriod)
vpa := addTestVpa(cluster)
Expand Down Expand Up @@ -154,6 +156,8 @@ func TestClusterGCAggregateContainerStateDeletesOldEmpty(t *testing.T) {
}

func TestClusterGCAggregateContainerStateDeletesEmptyInactiveWithoutController(t *testing.T) {
ctx := context.Background()

// Create a pod with a single container.
cluster := NewClusterState(testGcPeriod)
vpa := addTestVpa(cluster)
Expand Down Expand Up @@ -186,6 +190,8 @@ func TestClusterGCAggregateContainerStateDeletesEmptyInactiveWithoutController(t
}

func TestClusterGCAggregateContainerStateLeavesEmptyInactiveWithController(t *testing.T) {
ctx := context.Background()

// Create a pod with a single container.
cluster := NewClusterState(testGcPeriod)
vpa := addTestVpa(cluster)
Expand Down Expand Up @@ -214,6 +220,8 @@ func TestClusterGCAggregateContainerStateLeavesEmptyInactiveWithController(t *te
}

func TestClusterGCAggregateContainerStateLeavesValid(t *testing.T) {
ctx := context.Background()

// Create a pod with a single container.
cluster := NewClusterState(testGcPeriod)
vpa := addTestVpa(cluster)
Expand All @@ -236,6 +244,8 @@ func TestClusterGCAggregateContainerStateLeavesValid(t *testing.T) {
}

func TestAddSampleAfterAggregateContainerStateGCed(t *testing.T) {
ctx := context.Background()

// Create a pod with a single container.
cluster := NewClusterState(testGcPeriod)
vpa := addTestVpa(cluster)
Expand Down Expand Up @@ -275,6 +285,8 @@ func TestAddSampleAfterAggregateContainerStateGCed(t *testing.T) {
}

func TestClusterGCRateLimiting(t *testing.T) {
ctx := context.Background()

// Create a pod with a single container.
cluster := NewClusterState(testGcPeriod)
usageSample := makeTestUsageSample()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const (
)

var (
ctx = context.Background()
wellKnownControllers = []wellKnownController{daemonSet, deployment, replicaSet, statefulSet, replicationController, job, cronJob}
trueVar = true
)
Expand Down Expand Up @@ -409,7 +408,7 @@ func TestControllerFetcher(t *testing.T) {
for _, obj := range tc.objects {
addController(t, f, obj)
}
topMostWellKnownOrScalableController, err := f.FindTopMostWellKnownOrScalable(ctx, tc.key)
topMostWellKnownOrScalableController, err := f.FindTopMostWellKnownOrScalable(context.Background(), tc.key)
if tc.expectedKey == nil {
assert.Nil(t, topMostWellKnownOrScalableController)
} else {
Expand Down
4 changes: 1 addition & 3 deletions vertical-pod-autoscaler/pkg/utils/vpa/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ const (
)

var (
ctx = context.Background()

anytime = time.Unix(0, 0)
)

Expand Down Expand Up @@ -177,7 +175,7 @@ func TestGetControllingVPAForPod(t *testing.T) {
Name: "test-sts",
APIVersion: "apps/v1",
}
chosen := GetControllingVPAForPod(ctx, pod, []*VpaWithSelector{
chosen := GetControllingVPAForPod(context.Background(), pod, []*VpaWithSelector{
{vpaB, parseLabelSelector("app = testingApp")},
{vpaA, parseLabelSelector("app = testingApp")},
{nonMatchingVPA, parseLabelSelector("app = other")},
Expand Down

0 comments on commit 216b0ac

Please sign in to comment.