4
4
"context"
5
5
"fmt"
6
6
"os"
7
+ "strconv"
7
8
"strings"
8
9
"testing"
9
10
"time"
@@ -162,7 +163,7 @@ func TestPushNotifications(t *testing.T) {
162
163
}()
163
164
commandsRunner .FireCommandsUntilStop (ctx )
164
165
if ! found {
165
- ef ("FAILING_OVER notification was not received within 2 minutes" )
166
+ ef ("FAILING_OVER notification was not received within 3 minutes" )
166
167
}
167
168
failingOverData := logs2 .ExtractDataFromLogMessage (match )
168
169
p ("FAILING_OVER notification received. %v" , failingOverData )
@@ -177,7 +178,7 @@ func TestPushNotifications(t *testing.T) {
177
178
}()
178
179
commandsRunner .FireCommandsUntilStop (ctx )
179
180
if ! found {
180
- ef ("FAILED_OVER notification was not received within 2 minutes" )
181
+ ef ("FAILED_OVER notification was not received within 3 minutes" )
181
182
}
182
183
failedOverData := logs2 .ExtractDataFromLogMessage (match )
183
184
p ("FAILED_OVER notification received. %v" , failedOverData )
@@ -237,7 +238,7 @@ func TestPushNotifications(t *testing.T) {
237
238
}()
238
239
commandsRunner .FireCommandsUntilStop (ctx )
239
240
if ! found {
240
- ef ("MIGRATED notification was not received within 2 minutes" )
241
+ ef ("MIGRATED notification was not received within 3 minutes" )
241
242
}
242
243
migratedData := logs2 .ExtractDataFromLogMessage (match )
243
244
p ("MIGRATED notification received. %v" , migratedData )
@@ -284,7 +285,7 @@ func TestPushNotifications(t *testing.T) {
284
285
logger2 := maintnotifications .NewLoggingHook (int (logging .LogLevelDebug ))
285
286
setupNotificationHooks (client2 , tracker2 , logger2 )
286
287
commandsRunner2 , _ := NewCommandRunner (client2 )
287
- t . Log ("Second client created" )
288
+ p ("Second client created" )
288
289
289
290
// Use a channel to communicate errors from the goroutine
290
291
errChan := make (chan error , 1 )
@@ -317,7 +318,7 @@ func TestPushNotifications(t *testing.T) {
317
318
return strings .Contains (s , logs2 .ProcessingNotificationMessage ) && notificationType (s , "MOVING" ) && connID (s , 18 )
318
319
}, 3 * time .Minute )
319
320
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" )
321
322
return
322
323
} else {
323
324
p ("MOVING notification received on second client %v" , logs2 .ExtractDataFromLogMessage (match ))
@@ -327,7 +328,7 @@ func TestPushNotifications(t *testing.T) {
327
328
return strings .Contains (s , logs2 .ApplyingRelaxedTimeoutDueToPostHandoffMessage ) && strings .Contains (s , "30m" )
328
329
}, 3 * time .Minute )
329
330
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" )
331
332
return
332
333
} else {
333
334
p ("Relaxed timeout applied on second client" )
@@ -342,6 +343,61 @@ func TestPushNotifications(t *testing.T) {
342
343
seqIDToObserve = int64 (movingData ["seqID" ].(float64 ))
343
344
connIDToObserve = uint64 (movingData ["connID" ].(float64 ))
344
345
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 ()
345
401
// Wait for the goroutine to complete and check for errors
346
402
if err := <- errChan ; err != nil {
347
403
ef ("Second client goroutine error: %v" , err )
0 commit comments