Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
ofekshenawa authored Sep 10, 2023
2 parents 08c2bf5 + 5bbd80d commit d119d91
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 36 deletions.
49 changes: 13 additions & 36 deletions redis_gears_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var _ = Describe("RedisGears commands", Label("gears"), func() {
BeforeEach(func() {
client = redis.NewClient(&redis.Options{Addr: ":6379"})
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
client.TFunctionDelete(ctx, "lib1")
})

AfterEach(func() {
Expand All @@ -48,23 +49,17 @@ var _ = Describe("RedisGears commands", Label("gears"), func() {

It("should TFunctionLoad, TFunctionLoadArgs and TFunctionDelete ", Label("gears", "tfunctionload"), func() {

resultAdd, err := client.TFunctionLoad(ctx, libCode("libtflo1")).Result()
resultAdd, err := client.TFunctionLoad(ctx, libCode("lib1")).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
opt := &redis.TFunctionLoadOptions{Replace: true, Config: `{"last_update_field_name":"last_update"}`}
resultAdd, err = client.TFunctionLoadArgs(ctx, libCodeWithConfig("libtflo1"), opt).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
resultAdd, err = client.TFunctionDelete(ctx, "libtflo1").Result()
resultAdd, err = client.TFunctionLoadArgs(ctx, libCodeWithConfig("lib1"), opt).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))

})
It("should TFunctionList", Label("gears", "tfunctionlist"), func() {
resultAdd, err := client.TFunctionLoad(ctx, libCode("libtfli1")).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
resultAdd, err = client.TFunctionLoad(ctx, libCode("libtfli2")).Result()
resultAdd, err := client.TFunctionLoad(ctx, libCode("lib1")).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
resultList, err := client.TFunctionList(ctx).Result()
Expand All @@ -73,67 +68,49 @@ var _ = Describe("RedisGears commands", Label("gears"), func() {
opt := &redis.TFunctionListOptions{Withcode: true, Verbose: 2}
resultListArgs, err := client.TFunctionListArgs(ctx, opt).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultListArgs[0]["code"]).To(BeEquivalentTo(libCode("libtfli1")))
resultAdd, err = client.TFunctionDelete(ctx, "libtfli1").Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
resultAdd, err = client.TFunctionDelete(ctx, "libtfli2").Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
Expect(resultListArgs[0]["code"]).NotTo(BeEquivalentTo(""))
})

It("should TFCall", Label("gears", "tfcall"), func() {
var resultAdd interface{}
resultAdd, err := client.TFunctionLoad(ctx, libCode("libtfc1")).Result()
resultAdd, err := client.TFunctionLoad(ctx, libCode("lib1")).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
resultAdd, err = client.TFCall(ctx, "libtfc1", "foo", 0).Result()
resultAdd, err = client.TFCall(ctx, "lib1", "foo", 0).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("bar"))
resultAdd, err = client.TFunctionDelete(ctx, "libtfc1").Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
})

It("should TFCallArgs", Label("gears", "tfcallargs"), func() {
var resultAdd interface{}
resultAdd, err := client.TFunctionLoad(ctx, libCode("libtfca1")).Result()
resultAdd, err := client.TFunctionLoad(ctx, libCode("lib1")).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
opt := &redis.TFCallOptions{Arguments: []string{"foo", "bar"}}
resultAdd, err = client.TFCallArgs(ctx, "libtfca1", "foo", 0, opt).Result()
resultAdd, err = client.TFCallArgs(ctx, "lib1", "foo", 0, opt).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("bar"))
resultAdd, err = client.TFunctionDelete(ctx, "libtfca1").Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
})

It("should TFCallASYNC", Label("gears", "TFCallASYNC"), func() {
var resultAdd interface{}
resultAdd, err := client.TFunctionLoad(ctx, libCode("libtfc1")).Result()
resultAdd, err := client.TFunctionLoad(ctx, libCode("lib1")).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
resultAdd, err = client.TFCallASYNC(ctx, "libtfc1", "foo", 0).Result()
resultAdd, err = client.TFCallASYNC(ctx, "lib1", "foo", 0).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("bar"))
resultAdd, err = client.TFunctionDelete(ctx, "libtfc1").Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
})

It("should TFCallASYNCArgs", Label("gears", "TFCallASYNCargs"), func() {
var resultAdd interface{}
resultAdd, err := client.TFunctionLoad(ctx, libCode("libtfca1")).Result()
resultAdd, err := client.TFunctionLoad(ctx, libCode("lib1")).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
opt := &redis.TFCallOptions{Arguments: []string{"foo", "bar"}}
resultAdd, err = client.TFCallASYNCArgs(ctx, "libtfca1", "foo", 0, opt).Result()
resultAdd, err = client.TFCallASYNCArgs(ctx, "lib1", "foo", 0, opt).Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("bar"))
resultAdd, err = client.TFunctionDelete(ctx, "libtfca1").Result()
Expect(err).NotTo(HaveOccurred())
Expect(resultAdd).To(BeEquivalentTo("OK"))
})

})
3 changes: 3 additions & 0 deletions sentinel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ var _ = Describe("NewFailoverClusterClient", func() {
})

It("should facilitate failover", func() {
Skip("Flaky Test")
// Set value.
err := client.Set(ctx, "foo", "master", 0).Err()
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -283,6 +284,7 @@ var _ = Describe("NewFailoverClusterClient", func() {
})

It("should sentinel cluster client setname", func() {
Skip("Flaky Test")
err := client.ForEachShard(ctx, func(ctx context.Context, c *redis.Client) error {
return c.Ping(ctx).Err()
})
Expand All @@ -297,6 +299,7 @@ var _ = Describe("NewFailoverClusterClient", func() {
})

It("should sentinel cluster PROTO 3", func() {
Skip("Flaky Test")
_ = client.ForEachShard(ctx, func(ctx context.Context, c *redis.Client) error {
val, err := client.Do(ctx, "HELLO").Result()
Expect(err).NotTo(HaveOccurred())
Expand Down
1 change: 1 addition & 0 deletions universal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var _ = Describe("UniversalClient", func() {
})

It("should connect to failover servers", func() {
Skip("Flaky Test")
client = redis.NewUniversalClient(&redis.UniversalOptions{
MasterName: sentinelName,
Addrs: sentinelAddrs,
Expand Down

0 comments on commit d119d91

Please sign in to comment.