You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kvrocks.apache.org by ti...@apache.org on 2022/09/13 00:44:11 UTC

[incubator-kvrocks] branch unstable updated: disable retry for go-redis client (#869)

This is an automated email from the ASF dual-hosted git repository.

tison pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/incubator-kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new dacce8b  disable retry for go-redis client (#869)
dacce8b is described below

commit dacce8b6d7ada42cbd8bc6d8a0d54f25bc8975dd
Author: tison <wa...@gmail.com>
AuthorDate: Tue Sep 13 08:44:06 2022 +0800

    disable retry for go-redis client (#869)
    
    Signed-off-by: tison <wa...@gmail.com>
---
 tests/gocase/unit/type/list/list_test.go | 7 +++++--
 tests/gocase/util/server.go              | 9 ++++++++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/tests/gocase/unit/type/list/list_test.go b/tests/gocase/unit/type/list/list_test.go
index e8a288a..138e482 100644
--- a/tests/gocase/unit/type/list/list_test.go
+++ b/tests/gocase/unit/type/list/list_test.go
@@ -28,6 +28,7 @@ import (
 	"testing"
 
 	"github.com/apache/incubator-kvrocks/tests/gocase/util"
+	"github.com/go-redis/redis/v9"
 	"github.com/stretchr/testify/require"
 	"modernc.org/mathutil"
 )
@@ -91,7 +92,9 @@ func TestZipList(t *testing.T) {
 	})
 	defer srv.Close()
 	ctx := context.Background()
-	rdb := srv.NewClient()
+	rdb := srv.NewClientWithOption(&redis.Options{
+		MaxRetries: -1,
+	})
 	defer func() { require.NoError(t, rdb.Close()) }()
 
 	rand.Seed(0)
@@ -167,7 +170,7 @@ func TestZipList(t *testing.T) {
 		key := "l"
 		for j := 0; j < iterations; j++ {
 			require.NoError(t, rdb.Del(ctx, key).Err())
-			lis := []string{}
+			var lis []string
 			for i := 0; i < 200; i++ {
 				op := rand.Int63n(7)
 				data := ""
diff --git a/tests/gocase/util/server.go b/tests/gocase/util/server.go
index ebe41cf..d0ab1b7 100644
--- a/tests/gocase/util/server.go
+++ b/tests/gocase/util/server.go
@@ -42,7 +42,14 @@ type KvrocksServer struct {
 }
 
 func (s *KvrocksServer) NewClient() *redis.Client {
-	return redis.NewClient(&redis.Options{Addr: s.addr.String()})
+	return s.NewClientWithOption(&redis.Options{Addr: s.addr.String()})
+}
+
+func (s *KvrocksServer) NewClientWithOption(options *redis.Options) *redis.Client {
+	if options.Addr == "" {
+		options.Addr = s.addr.String()
+	}
+	return redis.NewClient(options)
 }
 
 func (s *KvrocksServer) NewTCPClient() *tcpClient {