Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix intermittent notifier stress test #261

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions internal/notifier/notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,14 @@ func TestNotifier(t *testing.T) {
notifyChans[i] = make(chan TopicAndPayload, 1000)
}

var wg sync.WaitGroup

// Start a goroutine to send messages constantly.
shutdown := make(chan struct{})
wg.Add(1)
go func() {
defer wg.Done()

ticker := time.NewTicker(10 * time.Millisecond)
defer ticker.Stop()

Expand All @@ -430,7 +435,6 @@ func TestNotifier(t *testing.T) {
}
}()

var wg sync.WaitGroup
wg.Add(len(notifyChans))
for i := range notifyChans {
notifyChan := notifyChans[i]
Expand All @@ -443,15 +447,15 @@ func TestNotifier(t *testing.T) {
require.NoError(t, err)

// Pause a random brief amount of time.
notifier.BaseService.CancellableSleepRandomBetween(ctx, 5*time.Millisecond, 50*time.Millisecond)
notifier.BaseService.CancellableSleepRandomBetween(ctx, 15*time.Millisecond, 50*time.Millisecond)

sub.Unlisten(ctx)
}
}()
}

wg.Wait()
close(shutdown)
wg.Wait()
notifier.Stop()

for i := range notifyChans {
Expand Down
Loading