Skip to content

Commit

Permalink
test: improve flaky
Browse files Browse the repository at this point in the history
Signed-off-by: Rueian <[email protected]>
  • Loading branch information
rueian committed Feb 2, 2025
1 parent 50d5c83 commit fb1f897
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions sentinel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1276,12 +1276,12 @@ func TestSentinelClientPubSub(t *testing.T) {
// switch to false master
messages <- PubSubMessage{Channel: "+switch-master", Message: "test 1 2"}

for atomic.LoadInt32(&m2close) != 2 {
for atomic.LoadInt32(&m2close) < 2 {
t.Log("wait false m2 to be close", atomic.LoadInt32(&m2close))
time.Sleep(time.Millisecond * 100)
}

for atomic.LoadInt32(&s0count) != 3 {
for atomic.LoadInt32(&s0count) < 3 {
t.Log("wait s0 to be call third time", atomic.LoadInt32(&s0count))
time.Sleep(time.Millisecond * 100)
}
Expand All @@ -1294,7 +1294,7 @@ func TestSentinelClientPubSub(t *testing.T) {
// switch to master by reboot
messages <- PubSubMessage{Channel: "+reboot", Message: "master test 4"}

for atomic.LoadInt32(&m1close) != 1 {
for atomic.LoadInt32(&m1close) < 1 {
t.Log("wait old m1 to be close", atomic.LoadInt32(&m1close))
time.Sleep(time.Millisecond * 100)
}
Expand All @@ -1307,11 +1307,11 @@ func TestSentinelClientPubSub(t *testing.T) {
close(messages)
client.Close()

for atomic.LoadInt32(&s0close) != 4 {
for atomic.LoadInt32(&s0close) < 4 {
t.Log("wait old s0 to be close", atomic.LoadInt32(&s0close))
time.Sleep(time.Millisecond * 100)
}
for atomic.LoadInt32(&m4close) != 1 {
for atomic.LoadInt32(&m4close) < 1 {
t.Log("wait old m1 to be close", atomic.LoadInt32(&m4close))
time.Sleep(time.Millisecond * 100)
}
Expand Down Expand Up @@ -1465,17 +1465,17 @@ func TestSentinelReplicaOnlyClientPubSub(t *testing.T) {
// it will cause s0 to return :2 in DoMulti response
messages <- PubSubMessage{Channel: "+slave", Message: "slave 0:0 0 2 @ replicaonly 0 0"}

for atomic.LoadInt32(&slave2close) != 1 {
for atomic.LoadInt32(&slave2close) < 1 {
t.Log("wait false slave2 to be close", atomic.LoadInt32(&slave2close))
time.Sleep(time.Millisecond * 100)
}

for atomic.LoadInt32(&s0count) != 3 {
for atomic.LoadInt32(&s0count) < 3 {
t.Log("wait s0 to be call third time", atomic.LoadInt32(&s0count))
time.Sleep(time.Millisecond * 100)
}

for atomic.LoadInt32(&slave1close) != 1 {
for atomic.LoadInt32(&slave1close) < 1 {
t.Log("wait for slave1 to close (and for client to use slave4)", atomic.LoadInt32(&slave1close))
time.Sleep(time.Millisecond * 100)
}
Expand All @@ -1488,7 +1488,7 @@ func TestSentinelReplicaOnlyClientPubSub(t *testing.T) {
// switch to new slave by reboot
messages <- PubSubMessage{Channel: "+reboot", Message: "slave 0:0 0 1 @ replicaonly 0 0"}

for atomic.LoadInt32(&slave4close) != 1 {
for atomic.LoadInt32(&slave4close) < 1 {
t.Log("wait old slave4 to be close", atomic.LoadInt32(&slave4close))
time.Sleep(time.Millisecond * 100)
}
Expand All @@ -1501,11 +1501,11 @@ func TestSentinelReplicaOnlyClientPubSub(t *testing.T) {
close(messages)
client.Close()

for atomic.LoadInt32(&s0close) != 4 {
for atomic.LoadInt32(&s0close) < 4 {
t.Log("wait old s0 to be close", atomic.LoadInt32(&s0close))
time.Sleep(time.Millisecond * 100)
}
for atomic.LoadInt32(&slave1close) != 2 {
for atomic.LoadInt32(&slave1close) < 2 {
t.Log("wait old slave1 to be close", atomic.LoadInt32(&slave1close))
time.Sleep(time.Millisecond * 100)
}
Expand Down

0 comments on commit fb1f897

Please sign in to comment.