WIP discovery: refactor TestTargetUpdatesOrder

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
pull/4582/head
Simon Pasquier 6 years ago
parent 8fd891bf3f
commit 7dc3f11306

@ -658,13 +658,13 @@ func TestTargetUpdatesOrder(t *testing.T) {
for i, tc := range testCases { for i, tc := range testCases {
tc := tc tc := tc
t.Run(tc.title, func(t *testing.T) { t.Run(tc.title, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel() defer cancel()
discoveryManager := NewManager(ctx, log.NewNopLogger()) discoveryManager := NewManager(ctx, log.NewNopLogger())
discoveryManager.updatert = 100 * time.Millisecond discoveryManager.updatert = 100 * time.Millisecond
var totalUpdatesCount int var totalUpdatesCount int
provUpdates := make(chan []*targetgroup.Group) provUpdates := make(chan []*targetgroup.Group)
for _, up := range tc.updates { for _, up := range tc.updates {
go newMockDiscoveryProvider(up...).Run(ctx, provUpdates) go newMockDiscoveryProvider(up...).Run(ctx, provUpdates)
@ -676,7 +676,7 @@ func TestTargetUpdatesOrder(t *testing.T) {
Loop: Loop:
for x := 0; x < totalUpdatesCount; x++ { for x := 0; x < totalUpdatesCount; x++ {
select { select {
case <-time.After(10 * time.Second): case <-ctx.Done():
t.Errorf("%d: no update arrived within the timeout limit", x) t.Errorf("%d: no update arrived within the timeout limit", x)
break Loop break Loop
case tgs := <-provUpdates: case tgs := <-provUpdates:

Loading…
Cancel
Save