mirror of
https://github.com/redis/go-redis.git
synced 2025-10-18 22:08:50 +03:00
second and third client fix
This commit is contained in:
@@ -207,7 +207,7 @@ func TestEndpointTypesPushNotifications(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
ef("[FI] Failover action failed for %s: %v", endpointTest.name, err)
|
ef("[FI] Failover action failed for %s: %v", endpointTest.name, err)
|
||||||
}
|
}
|
||||||
p("[FI] Failover action completed for %s: %+v", endpointTest.name, status)
|
p("[FI] Failover action completed for %s: %+v", endpointTest.name, status.Status)
|
||||||
|
|
||||||
// Test migration with this endpoint type
|
// Test migration with this endpoint type
|
||||||
p("Testing migration with %s endpoint type...", endpointTest.name)
|
p("Testing migration with %s endpoint type...", endpointTest.name)
|
||||||
@@ -229,7 +229,7 @@ func TestEndpointTypesPushNotifications(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
ef("[FI] Migrate action failed for %s: %v", endpointTest.name, err)
|
ef("[FI] Migrate action failed for %s: %v", endpointTest.name, err)
|
||||||
}
|
}
|
||||||
p("[FI] Migrate action completed for %s: %+v", endpointTest.name, status)
|
p("[FI] Migrate action completed for %s: %+v", endpointTest.name, status.Status)
|
||||||
|
|
||||||
// Wait for MIGRATING notification
|
// Wait for MIGRATING notification
|
||||||
match, found = logCollector.MatchOrWaitForLogMatchFunc(func(s string) bool {
|
match, found = logCollector.MatchOrWaitForLogMatchFunc(func(s string) bool {
|
||||||
@@ -323,7 +323,7 @@ func TestEndpointTypesPushNotifications(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
ef("Bind action failed for %s: %v", endpointTest.name, err)
|
ef("Bind action failed for %s: %v", endpointTest.name, err)
|
||||||
}
|
}
|
||||||
p("Bind action completed for %s: %+v", endpointTest.name, bindStatus)
|
p("Bind action completed for %s: %+v", endpointTest.name, bindStatus.Status)
|
||||||
|
|
||||||
// Continue traffic for analysis
|
// Continue traffic for analysis
|
||||||
time.Sleep(30 * time.Second)
|
time.Sleep(30 * time.Second)
|
||||||
|
@@ -166,7 +166,7 @@ func TestPushNotifications(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
ef("[FI] Failover action failed: %v", err)
|
ef("[FI] Failover action failed: %v", err)
|
||||||
}
|
}
|
||||||
p("[FI] Failover action completed: %+v", status)
|
p("[FI] Failover action completed: %+v", status.Status)
|
||||||
|
|
||||||
p("FAILING_OVER / FAILED_OVER notifications test completed successfully")
|
p("FAILING_OVER / FAILED_OVER notifications test completed successfully")
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ func TestPushNotifications(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
ef("[FI] Migrate action failed: %v", err)
|
ef("[FI] Migrate action failed: %v", err)
|
||||||
}
|
}
|
||||||
p("[FI] Migrate action completed: %+v", status)
|
p("[FI] Migrate action completed: %+v", status.Status)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
p("Waiting for MIGRATED notification on conn %d with seqID %d...", connIDToObserve, seqIDToObserve+1)
|
p("Waiting for MIGRATED notification on conn %d with seqID %d...", connIDToObserve, seqIDToObserve+1)
|
||||||
@@ -266,6 +266,9 @@ func TestPushNotifications(t *testing.T) {
|
|||||||
errChan := make(chan error, 1)
|
errChan := make(chan error, 1)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
var match string
|
||||||
|
var matchNotif []interface{}
|
||||||
|
var found bool
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
errChan <- fmt.Errorf("goroutine panic: %v", r)
|
errChan <- fmt.Errorf("goroutine panic: %v", r)
|
||||||
@@ -290,15 +293,14 @@ func TestPushNotifications(t *testing.T) {
|
|||||||
// we know the maxconn is 15, assuming 16/17 was used to init the second client, so connID 18 should be from the second client
|
// we know the maxconn is 15, assuming 16/17 was used to init the second client, so connID 18 should be from the second client
|
||||||
// also validate big enough relaxed timeout
|
// also validate big enough relaxed timeout
|
||||||
p("Waiting for MOVING notification on second client")
|
p("Waiting for MOVING notification on second client")
|
||||||
match, found = logCollector.MatchOrWaitForLogMatchFunc(func(s string) bool {
|
matchNotif, found = tracker2.FindOrWaitForNotification("MOVING", 3*time.Minute)
|
||||||
return strings.Contains(s, logs2.ProcessingNotificationMessage) && notificationType(s, "MOVING") && connID(s, 18)
|
|
||||||
}, 3*time.Minute)
|
|
||||||
if !found {
|
if !found {
|
||||||
errChan <- fmt.Errorf("MOVING notification was not received within 3 minutes ON A SECOND CLIENT")
|
errChan <- fmt.Errorf("MOVING notification was not received within 3 minutes ON A SECOND CLIENT")
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
p("MOVING notification received on second client %v", logs2.ExtractDataFromLogMessage(match))
|
p("MOVING notification received on second client %v", matchNotif)
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for relaxation of 30m
|
// wait for relaxation of 30m
|
||||||
match, found = logCollector.MatchOrWaitForLogMatchFunc(func(s string) bool {
|
match, found = logCollector.MatchOrWaitForLogMatchFunc(func(s string) bool {
|
||||||
return strings.Contains(s, logs2.ApplyingRelaxedTimeoutDueToPostHandoffMessage) && strings.Contains(s, "30m")
|
return strings.Contains(s, logs2.ApplyingRelaxedTimeoutDueToPostHandoffMessage) && strings.Contains(s, "30m")
|
||||||
@@ -319,6 +321,7 @@ func TestPushNotifications(t *testing.T) {
|
|||||||
seqIDToObserve = int64(movingData["seqID"].(float64))
|
seqIDToObserve = int64(movingData["seqID"].(float64))
|
||||||
connIDToObserve = uint64(movingData["connID"].(float64))
|
connIDToObserve = uint64(movingData["connID"].(float64))
|
||||||
|
|
||||||
|
time.Sleep(3 * time.Second)
|
||||||
// start a third client but don't execute any commands on it
|
// start a third client but don't execute any commands on it
|
||||||
p("Starting a third client to observe notification during moving...")
|
p("Starting a third client to observe notification during moving...")
|
||||||
client3, err := factory.Create("push-notification-client-2", &CreateClientOptions{
|
client3, err := factory.Create("push-notification-client-2", &CreateClientOptions{
|
||||||
@@ -348,7 +351,7 @@ func TestPushNotifications(t *testing.T) {
|
|||||||
p("Third client created")
|
p("Third client created")
|
||||||
go commandsRunner3.FireCommandsUntilStop(ctx)
|
go commandsRunner3.FireCommandsUntilStop(ctx)
|
||||||
// wait for moving on third client
|
// wait for moving on third client
|
||||||
movingNotification, found := tracker.FindOrWaitForNotification("MOVING", 3*time.Minute)
|
movingNotification, found := tracker3.FindOrWaitForNotification("MOVING", 3*time.Minute)
|
||||||
if !found {
|
if !found {
|
||||||
p("[NOTICE] MOVING notification was not received within 3 minutes ON A THIRD CLIENT")
|
p("[NOTICE] MOVING notification was not received within 3 minutes ON A THIRD CLIENT")
|
||||||
} else {
|
} else {
|
||||||
@@ -379,7 +382,7 @@ func TestPushNotifications(t *testing.T) {
|
|||||||
ef("Bind action failed: %v", err)
|
ef("Bind action failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
p("Bind action completed: %+v", bindStatus)
|
p("Bind action completed: %+v", bindStatus.Status)
|
||||||
|
|
||||||
p("MOVING notification test completed successfully")
|
p("MOVING notification test completed successfully")
|
||||||
|
|
||||||
|
@@ -199,10 +199,10 @@ func TestStressPushNotifications(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
actionMutex.Lock()
|
actionMutex.Lock()
|
||||||
actionResults = append(actionResults, fmt.Sprintf("%s: %+v", actionName, status))
|
actionResults = append(actionResults, fmt.Sprintf("%s: %+v", actionName, status.Status))
|
||||||
actionMutex.Unlock()
|
actionMutex.Unlock()
|
||||||
|
|
||||||
p("[FI] %s action completed: %+v", actionName, status)
|
p("[FI] %s action completed: %+v", actionName, status.Status)
|
||||||
}(action.name, action.action, action.delay)
|
}(action.name, action.action, action.delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -209,7 +209,7 @@ func TestTimeoutConfigurationsPushNotifications(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
ef("[FI] Failover action failed for %s: %v", timeoutTest.name, err)
|
ef("[FI] Failover action failed for %s: %v", timeoutTest.name, err)
|
||||||
}
|
}
|
||||||
p("[FI] Failover action completed for %s: %+v", timeoutTest.name, status)
|
p("[FI] Failover action completed for %s: %+v", timeoutTest.name, status.Status)
|
||||||
|
|
||||||
// Continue traffic to observe timeout behavior
|
// Continue traffic to observe timeout behavior
|
||||||
p("Continuing traffic for %v to observe timeout behavior...", timeoutTest.relaxedTimeout*2)
|
p("Continuing traffic for %v to observe timeout behavior...", timeoutTest.relaxedTimeout*2)
|
||||||
@@ -236,7 +236,7 @@ func TestTimeoutConfigurationsPushNotifications(t *testing.T) {
|
|||||||
ef("[FI] Migrate action failed for %s: %v", timeoutTest.name, err)
|
ef("[FI] Migrate action failed for %s: %v", timeoutTest.name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
p("[FI] Migrate action completed for %s: %+v", timeoutTest.name, status)
|
p("[FI] Migrate action completed for %s: %+v", timeoutTest.name, status.Status)
|
||||||
|
|
||||||
// Wait for MIGRATING notification
|
// Wait for MIGRATING notification
|
||||||
match, found = logCollector.MatchOrWaitForLogMatchFunc(func(s string) bool {
|
match, found = logCollector.MatchOrWaitForLogMatchFunc(func(s string) bool {
|
||||||
@@ -265,7 +265,8 @@ func TestTimeoutConfigurationsPushNotifications(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
ef("[FI] Bind action failed for %s: %v", timeoutTest.name, err)
|
ef("[FI] Bind action failed for %s: %v", timeoutTest.name, err)
|
||||||
}
|
}
|
||||||
p("[FI] Bind action completed for %s: %+v", timeoutTest.name, status)
|
p("[FI] Bind action completed for %s: %+v", timeoutTest.name, status.Status)
|
||||||
|
|
||||||
// waiting for moving notification
|
// waiting for moving notification
|
||||||
match, found = logCollector.MatchOrWaitForLogMatchFunc(func(s string) bool {
|
match, found = logCollector.MatchOrWaitForLogMatchFunc(func(s string) bool {
|
||||||
return strings.Contains(s, logs2.ProcessingNotificationMessage) && notificationType(s, "MOVING")
|
return strings.Contains(s, logs2.ProcessingNotificationMessage) && notificationType(s, "MOVING")
|
||||||
|
Reference in New Issue
Block a user