Skip to content

Commit

Permalink
Fix sometimes flaky test (#5391)
Browse files Browse the repository at this point in the history
* Fix sometimes flaky test

* Fix incorrect use of TestMain
  • Loading branch information
thampiotr authored Oct 6, 2023
1 parent 52ed27f commit 671dd75
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions component/discovery/consulagent/promtail_consulagent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,15 @@ func TestAllServices(t *testing.T) {

ctx, cancel := context.WithCancel(context.Background())
ch := make(chan []*targetgroup.Group)
done := make(chan struct{})
go func() {
d.Run(ctx, ch)
close(ch)
done <- struct{}{}
}()
checkOneTarget(t, <-ch)
checkOneTarget(t, <-ch)
cancel()
<-ch
<-done
}

// targetgroup with no targets is emitted if no services were discovered.
Expand Down

0 comments on commit 671dd75

Please sign in to comment.