Skip to content

Commit 85ca388

Browse files
[release-1.17] Guard reserved access with lock and create vpods in tests (#8504)
* Guard reserved access with lock in tests * Create vpods in test Signed-off-by: Pierangelo Di Pilato <[email protected]> --------- Signed-off-by: Pierangelo Di Pilato <[email protected]> Co-authored-by: Pierangelo Di Pilato <[email protected]>
1 parent 5b7b030 commit 85ca388

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pkg/scheduler/statefulset/scheduler_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,21 @@ func TestStatefulsetScheduler(t *testing.T) {
708708

709709
vpodClient := tscheduler.NewVPodClient()
710710
vpod := vpodClient.Create(vpodNamespace, vpodName, tc.vreplicas, tc.placements)
711+
for vPodKey, res := range tc.initialReserved {
712+
if vPodKey.Namespace == vpodNamespace && vPodKey.Name == vpodName {
713+
continue
714+
}
715+
var placements []duckv1alpha1.Placement
716+
count := int32(0)
717+
for pod, vReplicas := range res {
718+
count += vReplicas
719+
placements = append(placements, duckv1alpha1.Placement{
720+
PodName: pod,
721+
VReplicas: vReplicas,
722+
})
723+
}
724+
vpodClient.Create(vPodKey.Namespace, vPodKey.Name, count, placements)
725+
}
711726

712727
for i := int32(0); i < tc.replicas; i++ {
713728
nodeName := "node" + fmt.Sprint(i)
@@ -745,7 +760,9 @@ func TestStatefulsetScheduler(t *testing.T) {
745760
t.Fatal("unexpected error", err)
746761
}
747762
if tc.initialReserved != nil {
763+
s.reservedMu.Lock()
748764
s.reserved = tc.initialReserved
765+
s.reservedMu.Unlock()
749766
}
750767

751768
// Give some time for the informer to notify the scheduler and set the number of replicas

0 commit comments

Comments
 (0)