Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
brother-jin committed Aug 14, 2024
1 parent 0aaa704 commit 5911dc5
Showing 1 changed file with 52 additions and 53 deletions.
105 changes: 52 additions & 53 deletions tests/integration/replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,25 +637,24 @@ var _ = Describe("should replication ", func() {

for i := 1; i <= 5; i++ {
go func() {
client := redis.NewClient(PikaOption(MASTERADDR))
defer client.Close()
client := redis.NewClient(PikaOption(MASTERADDR))
defer client.Close()

client.BLPop(ctx, 0, lists...)
client.BLPop(ctx, 0, lists...)
}()
go func() {
client := redis.NewClient(PikaOption(MASTERADDR))
defer client.Close()
client := redis.NewClient(PikaOption(MASTERADDR))
defer client.Close()

client.BRPop(ctx, 0, lists...)
client.BRPop(ctx, 0, lists...)
}()
}
execute(&ctx, clientMaster, 5, issuePushPopFrequency)


time.Sleep(3 * time.Second);
//reconnect to avoid timeout-kill
clientSlave := redis.NewClient(PikaOption(SLAVEADDR))
// Fail("Stopping the test due to some condition");
time.Sleep(3 * time.Second)
//reconnect to avoid timeout-kill
clientSlave := redis.NewClient(PikaOption(SLAVEADDR))
// Fail("Stopping the test due to some condition");
for i := int64(0); i < clientMaster.LLen(ctx, "blist0").Val(); i++ {
Expect(clientMaster.LIndex(ctx, "blist0", i)).To(Equal(clientSlave.LIndex(ctx, "blist0", i)))
}
Expand Down Expand Up @@ -753,48 +752,48 @@ var _ = Describe("should replication ", func() {
Expect(r.Err()).To(MatchError("ERR EXEC without MULTI"))

err = clientMaster.Del(ctx, "txkey1")
/The test below is related with issue: https://github.com/OpenAtomFoundation/pika/issues/2643
r1 := clientMaster.Do(ctx, "MULTI")
Expect(r1.Err()).NotTo(HaveOccurred())

setkey1 := clientMaster.Set(ctx, "Tnxkey1", "Tnxvalue1", 0)
Expect(setkey1.Err()).NotTo(HaveOccurred())
Expect(setkey1.Val()).To(Equal("QUEUED"))

setkey2 := clientMaster.Set(ctx, "Tnxkey2", "Tnxvalue2", 0)
Expect(setkey2.Err()).NotTo(HaveOccurred())
Expect(setkey2.Val()).To(Equal("QUEUED"))

r2 := clientMaster.Do(ctx, "EXEC")
Expect(r2.Err()).NotTo(HaveOccurred())
Expect(r2.Val()).To(Equal([]interface{}{"OK", "OK"}))

time.Sleep(3 * time.Second)

getkey1 := clientSlave.Get(ctx, "Tnxkey1")
Expect(getkey1.Err()).NotTo(HaveOccurred())
Expect(getkey1.Val()).To(Equal("Tnxvalue1"))

getkey2 := clientSlave.Get(ctx, "Tnxkey2")
Expect(getkey2.Err()).NotTo(HaveOccurred())
Expect(getkey2.Val()).To(Equal("Tnxvalue2"))

ticker := time.NewTicker(500 * time.Millisecond)
defer ticker.Stop()
loopCount := 0

for loopCount < 10 {
select {
case <-ticker.C:
infoResExec := clientSlave.Info(ctx, "replication")
Expect(infoResExec.Err()).NotTo(HaveOccurred())
Expect(infoResExec.Val()).To(ContainSubstring("master_link_status:up"))
loopCount++
if loopCount >= 10 {
ticker.Stop()
}
}
}
//The test below is related with issue: https://github.com/OpenAtomFoundation/pika/issues/2643
r1 := clientMaster.Do(ctx, "MULTI")
Expect(r1.Err()).NotTo(HaveOccurred())

setkey1 := clientMaster.Set(ctx, "Tnxkey1", "Tnxvalue1", 0)
Expect(setkey1.Err()).NotTo(HaveOccurred())
Expect(setkey1.Val()).To(Equal("QUEUED"))

setkey2 := clientMaster.Set(ctx, "Tnxkey2", "Tnxvalue2", 0)
Expect(setkey2.Err()).NotTo(HaveOccurred())
Expect(setkey2.Val()).To(Equal("QUEUED"))

r2 := clientMaster.Do(ctx, "EXEC")
Expect(r2.Err()).NotTo(HaveOccurred())
Expect(r2.Val()).To(Equal([]interface{}{"OK", "OK"}))

time.Sleep(3 * time.Second)

getkey1 := clientSlave.Get(ctx, "Tnxkey1")
Expect(getkey1.Err()).NotTo(HaveOccurred())
Expect(getkey1.Val()).To(Equal("Tnxvalue1"))

getkey2 := clientSlave.Get(ctx, "Tnxkey2")
Expect(getkey2.Err()).NotTo(HaveOccurred())
Expect(getkey2.Val()).To(Equal("Tnxvalue2"))

ticker := time.NewTicker(500 * time.Millisecond)
defer ticker.Stop()
loopCount := 0

for loopCount < 10 {
select {
case <-ticker.C:
infoResExec := clientSlave.Info(ctx, "replication")
Expect(infoResExec.Err()).NotTo(HaveOccurred())
Expect(infoResExec.Val()).To(ContainSubstring("master_link_status:up"))
loopCount++
if loopCount >= 10 {
ticker.Stop()
}
}
}
log.Println("master-slave replication test success")
})
It("should simulate the master node setex and incr operation", func() {
Expand Down

0 comments on commit 5911dc5

Please sign in to comment.