Skip to content

Commit fc2da24

Browse files
committed
wait more in e2e test
1 parent 09a2f07 commit fc2da24

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

maintnotifications/e2e/command_runner_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type CommandRunnerStats struct {
2020

2121
// CommandRunner provides utilities for running commands during tests
2222
type CommandRunner struct {
23+
executing atomic.Bool
2324
client redis.UniversalClient
2425
stopCh chan struct{}
2526
operationCount atomic.Int64
@@ -56,6 +57,10 @@ func (cr *CommandRunner) Close() {
5657

5758
// FireCommandsUntilStop runs commands continuously until stop signal
5859
func (cr *CommandRunner) FireCommandsUntilStop(ctx context.Context) {
60+
if !cr.executing.CompareAndSwap(false, true) {
61+
return
62+
}
63+
defer cr.executing.Store(false)
5964
fmt.Printf("[CR] Starting command runner...\n")
6065
defer fmt.Printf("[CR] Command runner stopped\n")
6166
// High frequency for timeout testing

maintnotifications/e2e/scenario_push_notifications_test.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,6 @@ func TestPushNotifications(t *testing.T) {
297297
// once moving is received, start a second client commands runner
298298
p("Starting commands on second client")
299299
go commandsRunner2.FireCommandsUntilStop(ctx)
300-
defer func() {
301-
// stop the second runner
302-
commandsRunner2.Stop()
303-
// destroy the second client
304-
factory.Destroy("push-notification-client-2")
305-
}()
306300

307301
p("Waiting for MOVING notification on second client")
308302
matchNotif, fnd := tracker2.FindOrWaitForNotification("MOVING", 3*time.Minute)
@@ -393,11 +387,15 @@ func TestPushNotifications(t *testing.T) {
393387

394388
p("MOVING notification test completed successfully")
395389

396-
p("Executing commands and collecting logs for analysis... This will take 30 seconds...")
390+
p("Executing commands and collecting logs for analysis... ")
397391
go commandsRunner.FireCommandsUntilStop(ctx)
398-
time.Sleep(time.Minute)
392+
go commandsRunner2.FireCommandsUntilStop(ctx)
393+
go commandsRunner3.FireCommandsUntilStop(ctx)
394+
time.Sleep(30 * time.Second)
399395
commandsRunner.Stop()
400-
time.Sleep(time.Minute)
396+
commandsRunner2.Stop()
397+
commandsRunner3.Stop()
398+
time.Sleep(5 * time.Minute)
401399
allLogsAnalysis := logCollector.GetAnalysis()
402400
trackerAnalysis := tracker.GetAnalysis()
403401

@@ -473,7 +471,7 @@ func TestPushNotifications(t *testing.T) {
473471

474472
// unrelaxed (and relaxed) after moving wont be tracked by the hook, so we have to exclude it
475473
if trackerAnalysis.UnrelaxedTimeoutCount != allLogsAnalysis.UnrelaxedTimeoutCount-allLogsAnalysis.UnrelaxedAfterMoving {
476-
e("Expected %d unrelaxed timeouts, got %d", trackerAnalysis.UnrelaxedTimeoutCount, allLogsAnalysis.UnrelaxedTimeoutCount)
474+
e("Expected %d unrelaxed timeouts, got %d", trackerAnalysis.UnrelaxedTimeoutCount, allLogsAnalysis.UnrelaxedTimeoutCount-allLogsAnalysis.UnrelaxedAfterMoving)
477475
}
478476
if trackerAnalysis.RelaxedTimeoutCount != allLogsAnalysis.RelaxedTimeoutCount-allLogsAnalysis.RelaxedPostHandoffCount {
479477
e("Expected %d relaxed timeouts, got %d", trackerAnalysis.RelaxedTimeoutCount, allLogsAnalysis.RelaxedTimeoutCount)

0 commit comments

Comments
 (0)