Skip to content

Commit

Permalink
Remove reload count assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonip committed Nov 22, 2024
1 parent 01ab58f commit 817b840
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions internal/beatcmd/beat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"fmt"
"os"
"strconv"
"sync/atomic"
"testing"
"time"

Expand Down Expand Up @@ -201,18 +200,17 @@ func TestRunManager(t *testing.T) {

func TestRunManager_Reloader(t *testing.T) {
// This test asserts that unit changes are reloaded correctly.

var lastRevision int64
finish := make(chan struct{})
runCount := atomic.Int64{}
stopCount := atomic.Int64{}

registry := reload.NewRegistry()

reloader, err := NewReloader(beat.Info{}, registry, func(_ RunnerParams) (Runner, error) {
reloader, err := NewReloader(beat.Info{}, registry, func(p RunnerParams) (Runner, error) {
return runnerFunc(func(ctx context.Context) error {
runCount.Add(1)
<-ctx.Done()
stopCount.Add(1)
revision, err := p.Config.Int("revision", -1)
require.NoError(t, err)
lastRevision = revision
return nil
}), nil
})
Expand Down Expand Up @@ -343,12 +341,11 @@ func TestRunManager_Reloader(t *testing.T) {
err = reloader.Run(ctx)
require.NoError(t, err)

// It is not guaranteed that every revision is loaded due to debounce.
// Therefore, only assert the last revision.
assert.Eventually(t, func() bool {
// TODO(carsonip): There's a bug in EA manager causing an extra reload even if apm tracing config did not change
// see https://github.com/elastic/apm-server/issues/14580.
//return runCount.Load() == 2 && stopCount.Load() == 2
return runCount.Load() == 3 && stopCount.Load() == 3
}, 4*time.Second, 50*time.Millisecond)
return lastRevision == 2
}, 2*time.Second, 50*time.Millisecond)
}

func TestRunManager_Reloader_newRunnerError(t *testing.T) {
Expand Down

0 comments on commit 817b840

Please sign in to comment.