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 @@ -185,24 +185,15 @@ var _ = Describe("Controllerworkqueue", func() {
185
185
})
186
186
187
187
It ("returns high priority item that became ready before low priority item" , func () {
188
- q , metrics := newQueue ()
188
+ q , metrics , forwardQueueTimeBy := newQueueWithTimeForwarder ()
189
189
defer q .ShutDown ()
190
190
191
- now := time .Now ().Round (time .Second )
192
- nowLock := sync.Mutex {}
193
- tick := make (chan time.Time )
194
191
tickSetup := make (chan any )
195
-
196
- cwq := q .(* priorityqueue [string ])
197
- cwq .now = func () time.Time {
198
- nowLock .Lock ()
199
- defer nowLock .Unlock ()
200
- return now
201
- }
202
- cwq .tick = func (d time.Duration ) <- chan time.Time {
192
+ originalTick := q .tick
193
+ q .tick = func (d time.Duration ) <- chan time.Time {
203
194
Expect (d ).To (Equal (time .Second ))
204
195
close (tickSetup )
205
- return tick
196
+ return originalTick ( d )
206
197
}
207
198
208
199
lowPriority := - 100
@@ -212,11 +203,7 @@ var _ = Describe("Controllerworkqueue", func() {
212
203
213
204
Eventually (tickSetup ).Should (BeClosed ())
214
205
215
- nowLock .Lock ()
216
- now = now .Add (time .Second )
217
- nowLock .Unlock ()
218
- tick <- now
219
-
206
+ forwardQueueTimeBy (1 * time .Second )
220
207
key , prio , _ := q .GetWithPriority ()
221
208
222
209
Expect (key ).To (Equal ("prio" ))
You can’t perform that action at this time.
0 commit comments