Skip to content

Commit

Permalink
test: add replication-test-go (#2496)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mixficsol authored and wuxianrong committed Mar 13, 2024
1 parent 5d5a7d6 commit 11a7abf
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/integration/replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,33 @@ var _ = Describe("should replication ", func() {
slaveWrite := clientSlave.Set(ctx, "foo", "bar", 0)
Expect(slaveWrite.Err()).To(MatchError("ERR Server in read-only"))

log.Println("Replication test 1 start")
err1 := clientMaster.SetEx(ctx, "key", "hello", 60*time.Second).Err()
Expect(err1).NotTo(HaveOccurred())
Eventually(func() error {
return clientMaster.Get(ctx, "key").Err()
}, "65s", "100ms").Should(Equal(redis.Nil))
Eventually(func() error {
return clientSlave.Get(ctx, "key").Err()
}, "65s", "100ms").Should(Equal(redis.Nil))
log.Println("Replication test 1 success")

log.Println("Replication test 2 start")
set := clientMaster.Set(ctx, "x", "y", 0)
Expect(set.Err()).NotTo(HaveOccurred())
Expect(set.Val()).To(Equal("OK"))
set1 := clientMaster.Set(ctx, "a", "b", 0)
Expect(set1.Err()).NotTo(HaveOccurred())
Expect(set1.Val()).To(Equal("OK"))
Expect(clientMaster.FlushDB(ctx).Err()).NotTo(HaveOccurred())
Eventually(func() error {
return clientMaster.Get(ctx, "x").Err()
}, "1s", "100ms").Should(Equal(redis.Nil))
Eventually(func() error {
return clientSlave.Get(ctx, "x").Err()
}, "1s", "100ms").Should(Equal(redis.Nil))
log.Println("Replication test 2 success")

log.Println("rpoplpush test start")
Expect(clientMaster.Del(ctx, "blist0", "blist1", "blist").Err()).NotTo(HaveOccurred())
execute(&ctx, clientMaster, 4, rpoplpushThread)
Expand Down

0 comments on commit 11a7abf

Please sign in to comment.