Skip to content

Commit

Permalink
Fix tests scheduler test getting stuck
Browse files Browse the repository at this point in the history
This was due to some tests stopping taking samples before stopping
emitting them.

closes #3008
  • Loading branch information
mstoykov committed Apr 6, 2023
1 parent b4d4f77 commit 04150a4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions execution/scheduler_ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ func TestSchedulerRunNonDefault(t *testing.T) {

stopEmission, err := execScheduler.Init(ctx, samples)
require.NoError(t, err)
defer stopEmission()

go func() {
defer close(done)
defer stopEmission()
assert.NoError(t, execScheduler.Run(ctx, ctx, samples))
close(done)
}()
for {
select {
Expand Down Expand Up @@ -271,11 +271,11 @@ func TestSchedulerRunEnv(t *testing.T) {

stopEmission, err := execScheduler.Init(ctx, samples)
require.NoError(t, err)
defer stopEmission()

go func() {
defer close(done)
defer stopEmission()
assert.NoError(t, execScheduler.Run(ctx, ctx, samples))
close(done)
}()
for {
select {
Expand Down Expand Up @@ -344,11 +344,11 @@ func TestSchedulerSystemTags(t *testing.T) {

stopEmission, err := execScheduler.Init(ctx, samples)
require.NoError(t, err)
defer stopEmission()

done := make(chan struct{})
go func() {
defer close(done)
defer stopEmission()
require.NoError(t, execScheduler.Run(ctx, ctx, samples))
}()

Expand Down Expand Up @@ -481,10 +481,10 @@ func TestSchedulerRunCustomTags(t *testing.T) {

stopEmission, err := execScheduler.Init(ctx, samples)
require.NoError(t, err)
defer stopEmission()

go func() {
defer close(done)
defer stopEmission()
require.NoError(t, execScheduler.Run(ctx, ctx, samples))
}()
var gotTrailTag, gotNetTrailTag bool
Expand Down Expand Up @@ -1202,11 +1202,11 @@ func TestRealTimeAndSetupTeardownMetrics(t *testing.T) {

stopEmission, err := execScheduler.Init(ctx, samples)
require.NoError(t, err)
defer stopEmission()

go func() {
defer close(done)
defer stopEmission()
assert.NoError(t, execScheduler.Run(ctx, ctx, samples))
close(done)
}()

expectIn := func(from, to time.Duration, expected metrics.SampleContainer) {
Expand Down

0 comments on commit 04150a4

Please sign in to comment.