@@ -32,7 +32,7 @@ func TestPushNotifications(t *testing.T) {
32
32
var status * ActionStatusResponse
33
33
34
34
var p = func (format string , args ... interface {}) {
35
- format = "[%s] " + format
35
+ format = "[%s][PUSH-NOTIFICATIONS] " + format
36
36
ts := time .Now ().Format ("15:04:05.000" )
37
37
args = append ([]interface {}{ts }, args ... )
38
38
t .Logf (format , args ... )
@@ -41,12 +41,20 @@ func TestPushNotifications(t *testing.T) {
41
41
var errorsDetected = false
42
42
var e = func (format string , args ... interface {}) {
43
43
errorsDetected = true
44
- format = "[%s][ERROR] " + format
44
+ format = "[%s][PUSH-NOTIFICATIONS][ ERROR] " + format
45
45
ts := time .Now ().Format ("15:04:05.000" )
46
46
args = append ([]interface {}{ts }, args ... )
47
47
t .Errorf (format , args ... )
48
48
}
49
49
50
+ var ef = func (format string , args ... interface {}) {
51
+ errorsDetected = true
52
+ format = "[%s][PUSH-NOTIFICATIONS][ERROR] " + format
53
+ ts := time .Now ().Format ("15:04:05.000" )
54
+ args = append ([]interface {}{ts }, args ... )
55
+ t .Fatalf (format , args ... )
56
+ }
57
+
50
58
logCollector .ClearLogs ()
51
59
defer func () {
52
60
if dump {
@@ -61,14 +69,14 @@ func TestPushNotifications(t *testing.T) {
61
69
// Create client factory from configuration
62
70
factory , err := CreateTestClientFactory ("standalone" )
63
71
if err != nil {
64
- t .Skipf ("Enterprise cluster not available, skipping push notification tests: %v" , err )
72
+ t .Skipf ("[PUSH-NOTIFICATIONS][SKIP] Enterprise cluster not available, skipping push notification tests: %v" , err )
65
73
}
66
74
endpointConfig := factory .GetConfig ()
67
75
68
76
// Create fault injector
69
77
faultInjector , err := CreateTestFaultInjector ()
70
78
if err != nil {
71
- t . Fatalf ("Failed to create fault injector: %v" , err )
79
+ ef ("Failed to create fault injector: %v" , err )
72
80
}
73
81
74
82
minIdleConns := 5
@@ -91,7 +99,7 @@ func TestPushNotifications(t *testing.T) {
91
99
ClientName : "push-notification-test-client" ,
92
100
})
93
101
if err != nil {
94
- t . Fatalf ("Failed to create client: %v" , err )
102
+ ef ("Failed to create client: %v" , err )
95
103
}
96
104
97
105
defer func () {
@@ -116,7 +124,7 @@ func TestPushNotifications(t *testing.T) {
116
124
// Verify initial connectivity
117
125
err = client .Ping (ctx ).Err ()
118
126
if err != nil {
119
- t . Fatalf ("Failed to ping Redis: %v" , err )
127
+ ef ("Failed to ping Redis: %v" , err )
120
128
}
121
129
122
130
p ("Client connected successfully, starting push notification test" )
@@ -143,7 +151,7 @@ func TestPushNotifications(t *testing.T) {
143
151
},
144
152
})
145
153
if err != nil {
146
- t . Fatalf ("Failed to trigger failover action: %v" , err )
154
+ ef ("Failed to trigger failover action: %v" , err )
147
155
}
148
156
go func () {
149
157
p ("Waiting for FAILING_OVER notification" )
@@ -154,7 +162,7 @@ func TestPushNotifications(t *testing.T) {
154
162
}()
155
163
commandsRunner .FireCommandsUntilStop (ctx )
156
164
if ! found {
157
- t . Fatal ("FAILING_OVER notification was not received within 2 minutes" )
165
+ ef ("FAILING_OVER notification was not received within 2 minutes" )
158
166
}
159
167
failingOverData := logs2 .ExtractDataFromLogMessage (match )
160
168
p ("FAILING_OVER notification received. %v" , failingOverData )
@@ -169,7 +177,7 @@ func TestPushNotifications(t *testing.T) {
169
177
}()
170
178
commandsRunner .FireCommandsUntilStop (ctx )
171
179
if ! found {
172
- t . Fatal ("FAILED_OVER notification was not received within 2 minutes" )
180
+ ef ("FAILED_OVER notification was not received within 2 minutes" )
173
181
}
174
182
failedOverData := logs2 .ExtractDataFromLogMessage (match )
175
183
p ("FAILED_OVER notification received. %v" , failedOverData )
@@ -179,7 +187,7 @@ func TestPushNotifications(t *testing.T) {
179
187
WithPollInterval (1 * time .Second ),
180
188
)
181
189
if err != nil {
182
- t . Fatalf ("[FI] Failover action failed: %v" , err )
190
+ ef ("[FI] Failover action failed: %v" , err )
183
191
}
184
192
fmt .Printf ("[FI] Failover action completed: %s\n " , status .Status )
185
193
@@ -194,7 +202,7 @@ func TestPushNotifications(t *testing.T) {
194
202
},
195
203
})
196
204
if err != nil {
197
- t . Fatalf ("Failed to trigger migrate action: %v" , err )
205
+ ef ("Failed to trigger migrate action: %v" , err )
198
206
}
199
207
go func () {
200
208
match , found = logCollector .WaitForLogMatchFunc (func (s string ) bool {
@@ -204,7 +212,7 @@ func TestPushNotifications(t *testing.T) {
204
212
}()
205
213
commandsRunner .FireCommandsUntilStop (ctx )
206
214
if ! found {
207
- t . Fatal ("MIGRATING notification for migrate action was not received within 20 seconds" )
215
+ ef ("MIGRATING notification for migrate action was not received within 20 seconds" )
208
216
}
209
217
migrateData := logs2 .ExtractDataFromLogMessage (match )
210
218
seqIDToObserve = int64 (migrateData ["seqID" ].(float64 ))
@@ -216,7 +224,7 @@ func TestPushNotifications(t *testing.T) {
216
224
WithPollInterval (1 * time .Second ),
217
225
)
218
226
if err != nil {
219
- t . Fatalf ("[FI] Migrate action failed: %v" , err )
227
+ ef ("[FI] Migrate action failed: %v" , err )
220
228
}
221
229
fmt .Printf ("[FI] Migrate action completed: %s\n " , status .Status )
222
230
@@ -229,7 +237,7 @@ func TestPushNotifications(t *testing.T) {
229
237
}()
230
238
commandsRunner .FireCommandsUntilStop (ctx )
231
239
if ! found {
232
- t . Fatal ("MIGRATED notification was not received within 2 minutes" )
240
+ ef ("MIGRATED notification was not received within 2 minutes" )
233
241
}
234
242
migratedData := logs2 .ExtractDataFromLogMessage (match )
235
243
p ("MIGRATED notification received. %v" , migratedData )
@@ -247,7 +255,7 @@ func TestPushNotifications(t *testing.T) {
247
255
},
248
256
})
249
257
if err != nil {
250
- t . Fatalf ("Failed to trigger bind action: %v" , err )
258
+ ef ("Failed to trigger bind action: %v" , err )
251
259
}
252
260
253
261
// start a second client but don't execute any commands on it
@@ -269,7 +277,7 @@ func TestPushNotifications(t *testing.T) {
269
277
})
270
278
271
279
if err != nil {
272
- t . Fatalf ("failed to create client: %v" , err )
280
+ ef ("failed to create client: %v" , err )
273
281
}
274
282
// setup tracking for second client
275
283
tracker2 := NewTrackingNotificationsHook ()
@@ -336,15 +344,15 @@ func TestPushNotifications(t *testing.T) {
336
344
337
345
// Wait for the goroutine to complete and check for errors
338
346
if err := <- errChan ; err != nil {
339
- t . Fatalf ("Second client goroutine error: %v" , err )
347
+ ef ("Second client goroutine error: %v" , err )
340
348
}
341
349
342
350
// Wait for bind action to complete
343
351
bindStatus , err := faultInjector .WaitForAction (ctx , bindResp .ActionID ,
344
352
WithMaxWaitTime (120 * time .Second ),
345
353
WithPollInterval (2 * time .Second ))
346
354
if err != nil {
347
- t . Fatalf ("Bind action failed: %v" , err )
355
+ ef ("Bind action failed: %v" , err )
348
356
}
349
357
350
358
p ("Bind action completed: %s" , bindStatus .Status )
@@ -457,7 +465,7 @@ func TestPushNotifications(t *testing.T) {
457
465
trackerAnalysis .Print (t )
458
466
logCollector .Clear ()
459
467
tracker .Clear ()
460
- t . Fatalf ("[FAIL] Errors detected in push notification test" )
468
+ ef ("[FAIL] Errors detected in push notification test" )
461
469
}
462
470
463
471
p ("Analysis complete, no errors found" )
0 commit comments