File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
pkg/controller/priorityqueue Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -198,15 +198,24 @@ 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 , forwardQueueTimeBy := newQueueWithTimeForwarder ()
201
+ q , metrics := newQueue ()
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
+
208
+ cwq := q .(* priorityqueue [string ])
209
+ cwq .now = func () time.Time {
210
+ nowLock .Lock ()
211
+ defer nowLock .Unlock ()
212
+ return now
213
+ }
204
214
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 {
207
216
Expect (d ).To (Equal (time .Second ))
208
217
close (tickSetup )
209
- return originalTick ( d )
218
+ return tick
210
219
}
211
220
212
221
lowPriority := - 100
@@ -216,7 +225,10 @@ var _ = Describe("Controllerworkqueue", func() {
216
225
217
226
Eventually (tickSetup ).Should (BeClosed ())
218
227
219
- forwardQueueTimeBy (1 * time .Second )
228
+ nowLock .Lock ()
229
+ now = now .Add (time .Second )
230
+ nowLock .Unlock ()
231
+ tick <- now
220
232
key , prio , _ := q .GetWithPriority ()
221
233
222
234
Expect (key ).To (Equal ("prio" ))
You can’t perform that action at this time.
0 commit comments