@@ -136,3 +136,43 @@ func TestClusterQueueBestEffortFIFO(t *testing.T) {
136136 })
137137 }
138138}
139+
140+ func TestDeleteFromQueue (t * testing.T ) {
141+ cq := utiltesting .MakeClusterQueue ("cq" ).Obj ()
142+ cqImpl , err := newClusterQueueBestEffortFIFO (cq )
143+ if err != nil {
144+ t .Fatalf ("Failed creating ClusterQueue %v" , err )
145+ }
146+ q := utiltesting .MakeQueue ("foo" , "" ).ClusterQueue (cq .Name ).Obj ()
147+ qImpl := newQueue (q )
148+ wl1 := utiltesting .MakeWorkload ("wl1" , "" ).Queue (q .Name ).Obj ()
149+ wl2 := utiltesting .MakeWorkload ("wl2" , "" ).Queue (q .Name ).Obj ()
150+ wl3 := utiltesting .MakeWorkload ("wl3" , "" ).Queue (q .Name ).Obj ()
151+ wl4 := utiltesting .MakeWorkload ("wl4" , "" ).Queue (q .Name ).Obj ()
152+ admissibleworkloads := []* kueue.Workload {wl1 , wl2 }
153+ inadmissibleWorkloads := []* kueue.Workload {wl3 , wl4 }
154+
155+ for _ , w := range admissibleworkloads {
156+ cqImpl .PushOrUpdate (w )
157+ qImpl .AddOrUpdate (w )
158+ }
159+
160+ for _ , w := range inadmissibleWorkloads {
161+ cqImpl .RequeueIfNotPresent (workload .NewInfo (w ), false )
162+ qImpl .AddOrUpdate (w )
163+ }
164+
165+ wantPending := len (admissibleworkloads ) + len (inadmissibleWorkloads )
166+ if pending := cqImpl .Pending (); pending != int32 (wantPending ) {
167+ t .Errorf ("clusterQueue's workload number not right, want %v, got %v" , wantPending , pending )
168+ }
169+ fifo := cqImpl .(* ClusterQueueBestEffortFIFO )
170+ if len (fifo .inadmissibleWorkloads ) != len (inadmissibleWorkloads ) {
171+ t .Errorf ("clusterQueue's workload number in inadmissibleWorkloads not right, want %v, got %v" , len (inadmissibleWorkloads ), len (fifo .inadmissibleWorkloads ))
172+ }
173+
174+ cqImpl .DeleteFromQueue (qImpl )
175+ if cqImpl .Pending () != 0 {
176+ t .Error ("clusterQueue should be empty" )
177+ }
178+ }
0 commit comments