Skip to content

Commit

Permalink
Close test with channel instead
Browse files Browse the repository at this point in the history
  • Loading branch information
damemi committed Jun 15, 2023
1 parent 7a86527 commit b8c2635
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions exporter/collector/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2201,8 +2201,10 @@ func TestRunWALReadAndExportLoop(t *testing.T) {
doneChan := make(chan bool)

tmpDir, _ := os.MkdirTemp("", "wal-test-")
shutdown := make(chan struct{})
mExp := &MetricsExporter{
obs: selfObservability{zap.NewNop()},
obs: selfObservability{zap.NewNop()},
shutdownC: shutdown,
cfg: Config{
MetricConfig: MetricConfig{
WALConfig: &WALConfig{
Expand All @@ -2224,7 +2226,7 @@ func TestRunWALReadAndExportLoop(t *testing.T) {
_, _, err := mExp.setupWAL()
require.NoError(t, err)

ctx, cancel := context.WithCancel(context.Background())
ctx := context.Background()
mExp.goroutines.Add(1)
go func() {
mExp.runWALReadAndExportLoop(ctx)
Expand All @@ -2248,6 +2250,6 @@ func TestRunWALReadAndExportLoop(t *testing.T) {
// give the loop a second to realize it's at the end of the WAL
time.Sleep(time.Duration(1 * time.Second))

cancel()
close(mExp.shutdownC)
mExp.goroutines.Wait()
}

0 comments on commit b8c2635

Please sign in to comment.