Skip to content

Commit bd26904

Browse files
committed
test: improve flaky
Signed-off-by: Rueian <[email protected]>
1 parent 3ca23f7 commit bd26904

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

sentinel_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,12 +1274,12 @@ func TestSentinelClientPubSub(t *testing.T) {
12741274
// switch to false master
12751275
messages <- PubSubMessage{Channel: "+switch-master", Message: "test 1 2"}
12761276

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

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

1295-
for atomic.LoadInt32(&m1close) != 1 {
1295+
for atomic.LoadInt32(&m1close) < 1 {
12961296
t.Log("wait old m1 to be close", atomic.LoadInt32(&m1close))
12971297
time.Sleep(time.Millisecond * 100)
12981298
}
@@ -1305,11 +1305,11 @@ func TestSentinelClientPubSub(t *testing.T) {
13051305
close(messages)
13061306
client.Close()
13071307

1308-
for atomic.LoadInt32(&s0close) != 4 {
1308+
for atomic.LoadInt32(&s0close) < 4 {
13091309
t.Log("wait old s0 to be close", atomic.LoadInt32(&s0close))
13101310
time.Sleep(time.Millisecond * 100)
13111311
}
1312-
for atomic.LoadInt32(&m4close) != 1 {
1312+
for atomic.LoadInt32(&m4close) < 1 {
13131313
t.Log("wait old m1 to be close", atomic.LoadInt32(&m4close))
13141314
time.Sleep(time.Millisecond * 100)
13151315
}
@@ -1461,17 +1461,17 @@ func TestSentinelReplicaOnlyClientPubSub(t *testing.T) {
14611461
// it will cause s0 to return :2 in DoMulti response
14621462
messages <- PubSubMessage{Channel: "+slave", Message: "slave 0:0 0 2 @ replicaonly 0 0"}
14631463

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

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

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

1487-
for atomic.LoadInt32(&slave4close) != 1 {
1487+
for atomic.LoadInt32(&slave4close) < 1 {
14881488
t.Log("wait old slave4 to be close", atomic.LoadInt32(&slave4close))
14891489
time.Sleep(time.Millisecond * 100)
14901490
}
@@ -1497,11 +1497,11 @@ func TestSentinelReplicaOnlyClientPubSub(t *testing.T) {
14971497
close(messages)
14981498
client.Close()
14991499

1500-
for atomic.LoadInt32(&s0close) != 4 {
1500+
for atomic.LoadInt32(&s0close) < 4 {
15011501
t.Log("wait old s0 to be close", atomic.LoadInt32(&s0close))
15021502
time.Sleep(time.Millisecond * 100)
15031503
}
1504-
for atomic.LoadInt32(&slave1close) != 2 {
1504+
for atomic.LoadInt32(&slave1close) < 2 {
15051505
t.Log("wait old slave1 to be close", atomic.LoadInt32(&slave1close))
15061506
time.Sleep(time.Millisecond * 100)
15071507
}

0 commit comments

Comments
 (0)