Skip to content

Commit 7bb8ed2

Browse files
committed
Rebase for releasebranch without newQueueWithTimeForwarder
1 parent 55e3426 commit 7bb8ed2

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

pkg/controller/priorityqueue/priorityqueue_test.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,24 @@ var _ = Describe("Controllerworkqueue", func() {
198198
})
199199

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

204+
now := time.Now().Round(time.Second)
205+
nowLock := sync.Mutex{}
206+
tick := make(chan time.Time)
207+
208+
cwq := q.(*priorityqueue[string])
209+
cwq.now = func() time.Time {
210+
nowLock.Lock()
211+
defer nowLock.Unlock()
212+
return now
213+
}
204214
tickSetup := make(chan any)
205-
originalTick := q.tick
206-
q.tick = func(d time.Duration) <-chan time.Time {
215+
cwq.tick = func(d time.Duration) <-chan time.Time {
207216
Expect(d).To(Equal(time.Second))
208217
close(tickSetup)
209-
return originalTick(d)
218+
return tick
210219
}
211220

212221
lowPriority := -100
@@ -216,7 +225,10 @@ var _ = Describe("Controllerworkqueue", func() {
216225

217226
Eventually(tickSetup).Should(BeClosed())
218227

219-
forwardQueueTimeBy(1 * time.Second)
228+
nowLock.Lock()
229+
now = now.Add(time.Second)
230+
nowLock.Unlock()
231+
tick <- now
220232
key, prio, _ := q.GetWithPriority()
221233

222234
Expect(key).To(Equal("prio"))

0 commit comments

Comments
 (0)