Skip to content

Commit 113edc5

Browse files
committed
extend tests
1 parent 87670b2 commit 113edc5

File tree

1 file changed

+62
-6
lines changed

1 file changed

+62
-6
lines changed

maintnotifications/e2e/scenario_push_notifications_test.go

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"os"
7+
"strconv"
78
"strings"
89
"testing"
910
"time"
@@ -162,7 +163,7 @@ func TestPushNotifications(t *testing.T) {
162163
}()
163164
commandsRunner.FireCommandsUntilStop(ctx)
164165
if !found {
165-
ef("FAILING_OVER notification was not received within 2 minutes")
166+
ef("FAILING_OVER notification was not received within 3 minutes")
166167
}
167168
failingOverData := logs2.ExtractDataFromLogMessage(match)
168169
p("FAILING_OVER notification received. %v", failingOverData)
@@ -177,7 +178,7 @@ func TestPushNotifications(t *testing.T) {
177178
}()
178179
commandsRunner.FireCommandsUntilStop(ctx)
179180
if !found {
180-
ef("FAILED_OVER notification was not received within 2 minutes")
181+
ef("FAILED_OVER notification was not received within 3 minutes")
181182
}
182183
failedOverData := logs2.ExtractDataFromLogMessage(match)
183184
p("FAILED_OVER notification received. %v", failedOverData)
@@ -237,7 +238,7 @@ func TestPushNotifications(t *testing.T) {
237238
}()
238239
commandsRunner.FireCommandsUntilStop(ctx)
239240
if !found {
240-
ef("MIGRATED notification was not received within 2 minutes")
241+
ef("MIGRATED notification was not received within 3 minutes")
241242
}
242243
migratedData := logs2.ExtractDataFromLogMessage(match)
243244
p("MIGRATED notification received. %v", migratedData)
@@ -284,7 +285,7 @@ func TestPushNotifications(t *testing.T) {
284285
logger2 := maintnotifications.NewLoggingHook(int(logging.LogLevelDebug))
285286
setupNotificationHooks(client2, tracker2, logger2)
286287
commandsRunner2, _ := NewCommandRunner(client2)
287-
t.Log("Second client created")
288+
p("Second client created")
288289

289290
// Use a channel to communicate errors from the goroutine
290291
errChan := make(chan error, 1)
@@ -317,7 +318,7 @@ func TestPushNotifications(t *testing.T) {
317318
return strings.Contains(s, logs2.ProcessingNotificationMessage) && notificationType(s, "MOVING") && connID(s, 18)
318319
}, 3*time.Minute)
319320
if !found {
320-
errChan <- fmt.Errorf("MOVING notification was not received within 2 minutes ON A SECOND CLIENT")
321+
errChan <- fmt.Errorf("MOVING notification was not received within 3 minutes ON A SECOND CLIENT")
321322
return
322323
} else {
323324
p("MOVING notification received on second client %v", logs2.ExtractDataFromLogMessage(match))
@@ -327,7 +328,7 @@ func TestPushNotifications(t *testing.T) {
327328
return strings.Contains(s, logs2.ApplyingRelaxedTimeoutDueToPostHandoffMessage) && strings.Contains(s, "30m")
328329
}, 3*time.Minute)
329330
if !found {
330-
errChan <- fmt.Errorf("relaxed timeout was not applied within 2 minutes ON A SECOND CLIENT")
331+
errChan <- fmt.Errorf("relaxed timeout was not applied within 3 minutes ON A SECOND CLIENT")
331332
return
332333
} else {
333334
p("Relaxed timeout applied on second client")
@@ -342,6 +343,61 @@ func TestPushNotifications(t *testing.T) {
342343
seqIDToObserve = int64(movingData["seqID"].(float64))
343344
connIDToObserve = uint64(movingData["connID"].(float64))
344345

346+
// start a third client but don't execute any commands on it
347+
p("Starting a third client to observe notification during moving...")
348+
client3, err := factory.Create("push-notification-client-2", &CreateClientOptions{
349+
Protocol: 3, // RESP3 required for push notifications
350+
PoolSize: poolSize,
351+
MinIdleConns: minIdleConns,
352+
MaxActiveConns: maxConnections,
353+
MaintNotificationsConfig: &maintnotifications.Config{
354+
Mode: maintnotifications.ModeEnabled,
355+
HandoffTimeout: 40 * time.Second, // 30 seconds
356+
RelaxedTimeout: 30 * time.Minute, // 30 minutes relaxed timeout for second client
357+
PostHandoffRelaxedDuration: 2 * time.Second, // 2 seconds post-handoff relaxed duration
358+
MaxWorkers: 20,
359+
EndpointType: maintnotifications.EndpointTypeExternalIP, // Use external IP for enterprise
360+
},
361+
ClientName: "push-notification-test-client-3",
362+
})
363+
364+
if err != nil {
365+
ef("failed to create client: %v", err)
366+
}
367+
// setup tracking for second client
368+
tracker3 := NewTrackingNotificationsHook()
369+
logger3 := maintnotifications.NewLoggingHook(int(logging.LogLevelDebug))
370+
setupNotificationHooks(client3, tracker3, logger3)
371+
commandsRunner3, _ := NewCommandRunner(client3)
372+
p("Third client created")
373+
go commandsRunner3.FireCommandsUntilStop(ctx)
374+
// wait for moving on third client
375+
match, found = logCollector.MatchOrWaitForLogMatchFunc(func(s string) bool {
376+
return strings.Contains(s, logs2.ProcessingNotificationMessage) && notificationType(s, "MOVING") && connID(s, 19)
377+
}, 3*time.Minute)
378+
if !found {
379+
ef("MOVING notification was not received within 3 minutes ON A THIRD CLIENT")
380+
} else {
381+
p("MOVING notification received on third client")
382+
data := logs2.ExtractDataFromLogMessage(match)
383+
mNotif := data["notification"].(string)
384+
// format MOVING <seqID> <timeS> endpoint
385+
mNotifParts := strings.Split(mNotif, " ")
386+
if len(mNotifParts) != 4 {
387+
ef("Invalid MOVING notification format: %s", mNotif)
388+
}
389+
mNotifTimeS, err := strconv.Atoi(mNotifParts[2])
390+
if err != nil {
391+
ef("Invalid timeS in MOVING notification: %s", mNotif)
392+
}
393+
// expect timeS to be less than 15
394+
if mNotifTimeS < 15 {
395+
ef("Expected timeS < 15, got %d", mNotifTimeS)
396+
}
397+
398+
p("MOVING notification received on third client. %v", data)
399+
}
400+
commandsRunner3.Stop()
345401
// Wait for the goroutine to complete and check for errors
346402
if err := <-errChan; err != nil {
347403
ef("Second client goroutine error: %v", err)

0 commit comments

Comments
 (0)