mirror of https://github.com/knative/pkg.git
Reorder statements for more precise behavior and harden the test (#1534)
This commit is contained in:
parent
0166004ef1
commit
557b6826ef
|
|
@ -70,8 +70,8 @@ func process(q workqueue.Interface, ch chan interface{}) {
|
||||||
if d {
|
if d {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
ch <- i
|
|
||||||
q.Done(i)
|
q.Done(i)
|
||||||
|
ch <- i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,20 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSlowQueue(t *testing.T) {
|
func TestSlowQueue(t *testing.T) {
|
||||||
q := newTwoLaneWorkQueue("live-in-the-fast-lane")
|
q := newTwoLaneWorkQueue("live-in-the-fast-lane")
|
||||||
q.SlowLane().Add("1")
|
q.SlowLane().Add("1")
|
||||||
if got, want := q.Len(), 1; got != want {
|
// Queue has async moving parts so if we check at the wrong moment, this might still be 0.
|
||||||
t.Errorf("Len = %d, want: 1", got)
|
if wait.PollImmediate(10*time.Millisecond, 250*time.Millisecond, func() (bool, error) {
|
||||||
|
return q.Len() == 1, nil
|
||||||
|
}) != nil {
|
||||||
|
t.Error("Queue length was never 1")
|
||||||
}
|
}
|
||||||
|
|
||||||
k, done := q.Get()
|
k, done := q.Get()
|
||||||
if got, want := k.(string), "1"; got != want {
|
if got, want := k.(string), "1"; got != want {
|
||||||
t.Errorf(`Got = %q, want: "1"`, got)
|
t.Errorf(`Got = %q, want: "1"`, got)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue