Skip to content

Commit ed5895f

Browse files
committed
rm async from test
1 parent bd68c81 commit ed5895f

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

pkg/controller/priorityqueue/priorityqueue_test.go

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,14 @@ var _ = Describe("Controllerworkqueue", func() {
197197
Expect(metrics.retries["test"]).To(Equal(1))
198198
})
199199

200-
It("returns high priority item that became ready before low priority items", func() {
200+
It("returns high priority item that became ready before low priority item", func() {
201201
q, metrics := newQueue()
202202
defer q.ShutDown()
203203

204204
now := time.Now().Round(time.Second)
205205
nowLock := sync.Mutex{}
206206
tick := make(chan time.Time)
207+
tickSetup := make(chan any)
207208

208209
cwq := q.(*priorityqueue[string])
209210
cwq.now = func() time.Time {
@@ -213,47 +214,28 @@ var _ = Describe("Controllerworkqueue", func() {
213214
}
214215
cwq.tick = func(d time.Duration) <-chan time.Time {
215216
Expect(d).To(Equal(time.Second))
217+
close(tickSetup)
216218
return tick
217219
}
218220

219-
retrievedItem := make(chan any)
220-
getNext := make(chan any)
221-
222-
go func() {
223-
defer GinkgoRecover()
224-
defer close(retrievedItem)
225-
226-
key, prio, _ := q.GetWithPriority()
227-
Expect(key).To(Equal("foo"))
228-
Expect(prio).To(Equal(-100))
229-
230-
retrievedItem <- nil
231-
<-getNext
232-
233-
key, prio, _ = q.GetWithPriority()
234-
Expect(key).To(Equal("prio"))
235-
Expect(prio).To(Equal(0))
236-
}()
237-
238221
lowPriority := -100
239222
highPriority := 0
240223
q.AddWithOpts(AddOpts{After: 0, Priority: &lowPriority}, "foo")
241-
q.AddWithOpts(AddOpts{After: 0, Priority: &lowPriority}, "bar")
242224
q.AddWithOpts(AddOpts{After: time.Second, Priority: &highPriority}, "prio")
243225

244-
<-retrievedItem
226+
Eventually(tickSetup).Should(BeClosed())
245227

246228
nowLock.Lock()
247229
now = now.Add(time.Second)
248230
nowLock.Unlock()
249231
tick <- now
250-
getNext <- nil
251232

252-
Eventually(retrievedItem).Should(BeClosed())
253-
close(getNext)
233+
key, prio, _ := q.GetWithPriority()
254234

235+
Expect(key).To(Equal("prio"))
236+
Expect(prio).To(Equal(0))
255237
Expect(metrics.depth["test"]).To(Equal(map[int]int{-100: 1, 0: 0}))
256-
Expect(metrics.adds["test"]).To(Equal(3))
238+
Expect(metrics.adds["test"]).To(Equal(2))
257239
Expect(metrics.retries["test"]).To(Equal(1))
258240
})
259241

0 commit comments

Comments
 (0)