Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions pkg/scheduler/statefulset/scheduler_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check failure on line 1 in pkg/scheduler/statefulset/scheduler_test.go

View workflow job for this annotation

GitHub Actions / style / Golang / Auto-format and Check

Please run goimports. diff --git a/pkg/scheduler/statefulset/scheduler_test.go b/pkg/scheduler/statefulset/scheduler_test.go index a02d0a1..7749810 100644 --- a/pkg/scheduler/statefulset/scheduler_test.go +++ b/pkg/scheduler/statefulset/scheduler_test.go @@ -643,18 +643,18 @@ func TestStatefulsetScheduler(t *testing.T) { err: controller.NewRequeueAfter(5 * time.Second), }, { - name: "Unschedulable pod", - vreplicas: 20, - replicas: int32(1), - capacity: 20, + name: "Unschedulable pod", + vreplicas: 20, + replicas: int32(1), + capacity: 20, unschedulablePods: sets.New[int32](0), - err: controller.NewRequeueAfter(5 * time.Second), + err: controller.NewRequeueAfter(5 * time.Second), }, { - name: "Unschedulable pod, with reserved and some space", - vreplicas: 20, - replicas: int32(2), - capacity: 20, + name: "Unschedulable pod, with reserved and some space", + vreplicas: 20, + replicas: int32(2), + capacity: 20, expected: []duckv1alpha1.Placement{ {PodName: "statefulset-name-0", VReplicas: 2}, }, @@ -672,13 +672,13 @@ func TestStatefulsetScheduler(t *testing.T) { }, }, unschedulablePods: sets.New[int32](1), - err: controller.NewRequeueAfter(5 * time.Second), + err: controller.NewRequeueAfter(5 * time.Second), }, { - name: "Unschedulable middle pod, with reserved and some space", - vreplicas: 20, - replicas: int32(3), - capacity: 20, + name: "Unschedulable middle pod, with reserved and some space", + vreplicas: 20, + replicas: int32(3), + capacity: 20, expected: []duckv1alpha1.Placement{ {PodName: "statefulset-name-0", VReplicas: 2}, {PodName: "statefulset-name-2", VReplicas: 18},
Copyright 2020 The Knative Authors

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -708,6 +708,21 @@

vpodClient := tscheduler.NewVPodClient()
vpod := vpodClient.Create(vpodNamespace, vpodName, tc.vreplicas, tc.placements)
for vPodKey, res := range tc.initialReserved {
if vPodKey.Namespace == vpodNamespace && vPodKey.Name == vpodName {
continue
}
var placements []duckv1alpha1.Placement
count := int32(0)
for pod, vReplicas := range res {
count += vReplicas
placements = append(placements, duckv1alpha1.Placement{
PodName: pod,
VReplicas: vReplicas,
})
}
vpodClient.Create(vPodKey.Namespace, vPodKey.Name, count, placements)
}

for i := int32(0); i < tc.replicas; i++ {
nodeName := "node" + fmt.Sprint(i)
Expand Down Expand Up @@ -745,7 +760,9 @@
t.Fatal("unexpected error", err)
}
if tc.initialReserved != nil {
s.reservedMu.Lock()
s.reserved = tc.initialReserved
s.reservedMu.Unlock()
}

// Give some time for the informer to notify the scheduler and set the number of replicas
Expand Down
Loading