File tree Expand file tree Collapse file tree 1 file changed +5
-18
lines changed
pkg/controller/priorityqueue Expand file tree Collapse file tree 1 file changed +5
-18
lines changed Original file line number Diff line number Diff line change @@ -198,24 +198,15 @@ var _ = Describe("Controllerworkqueue", func() {
198
198
})
199
199
200
200
It ("returns high priority item that became ready before low priority item" , func () {
201
- q , metrics := newQueue ()
201
+ q , metrics , forwardQueueTimeBy := newQueueWithTimeForwarder ()
202
202
defer q .ShutDown ()
203
203
204
- now := time .Now ().Round (time .Second )
205
- nowLock := sync.Mutex {}
206
- tick := make (chan time.Time )
207
204
tickSetup := make (chan any )
208
-
209
- cwq := q .(* priorityqueue [string ])
210
- cwq .now = func () time.Time {
211
- nowLock .Lock ()
212
- defer nowLock .Unlock ()
213
- return now
214
- }
215
- cwq .tick = func (d time.Duration ) <- chan time.Time {
205
+ originalTick := q .tick
206
+ q .tick = func (d time.Duration ) <- chan time.Time {
216
207
Expect (d ).To (Equal (time .Second ))
217
208
close (tickSetup )
218
- return tick
209
+ return originalTick ( d )
219
210
}
220
211
221
212
lowPriority := - 100
@@ -225,11 +216,7 @@ var _ = Describe("Controllerworkqueue", func() {
225
216
226
217
Eventually (tickSetup ).Should (BeClosed ())
227
218
228
- nowLock .Lock ()
229
- now = now .Add (time .Second )
230
- nowLock .Unlock ()
231
- tick <- now
232
-
219
+ forwardQueueTimeBy (1 * time .Second )
233
220
key , prio , _ := q .GetWithPriority ()
234
221
235
222
Expect (key ).To (Equal ("prio" ))
You can’t perform that action at this time.
0 commit comments