@@ -33,23 +33,6 @@ var slotsResp = newResult(RedisMessage{typ: '*', values: []RedisMessage{
33
33
}},
34
34
}}, nil )
35
35
36
- var slotsRespWithChangedRole = newResult (RedisMessage {typ : '*' , values : []RedisMessage {
37
- {typ : '*' , values : []RedisMessage {
38
- {typ : ':' , integer : 0 },
39
- {typ : ':' , integer : 16383 },
40
- {typ : '*' , values : []RedisMessage { // master
41
- {typ : '+' , string : "127.0.1.1" },
42
- {typ : ':' , integer : 1 },
43
- {typ : '+' , string : "" },
44
- }},
45
- {typ : '*' , values : []RedisMessage { // replica
46
- {typ : '+' , string : "127.0.0.1" },
47
- {typ : ':' , integer : 0 },
48
- {typ : '+' , string : "" },
49
- }},
50
- }},
51
- }}, nil )
52
-
53
36
var slotsMultiResp = newResult (RedisMessage {typ : '*' , values : []RedisMessage {
54
37
{typ : '*' , values : []RedisMessage {
55
38
{typ : ':' , integer : 0 },
@@ -1937,13 +1920,6 @@ func TestClusterClient_SendToOnlyPrimaryNodes(t *testing.T) {
1937
1920
t .Fatalf ("unexpected err %v" , err )
1938
1921
}
1939
1922
1940
- t .Run ("Do with no slot" , func (t * testing.T ) {
1941
- c := client .B ().Info ().Build ()
1942
- if v , err := client .Do (context .Background (), c ).ToString (); err != nil || v != "INFO" {
1943
- t .Fatalf ("unexpected response %v %v" , v , err )
1944
- }
1945
- })
1946
-
1947
1923
t .Run ("Do" , func (t * testing.T ) {
1948
1924
c := client .B ().Get ().Key ("Do" ).Build ()
1949
1925
if v , err := client .Do (context .Background (), c ).ToString (); err != nil || v != "GET Do" {
@@ -2443,13 +2419,6 @@ func TestClusterClient_SendToOnlyReplicaNodes(t *testing.T) {
2443
2419
t .Fatalf ("unexpected err %v" , err )
2444
2420
}
2445
2421
2446
- t .Run ("Do with no slot" , func (t * testing.T ) {
2447
- c := client .B ().Info ().Build ()
2448
- if v , err := client .Do (context .Background (), c ).ToString (); err != nil || v != "INFO" {
2449
- t .Fatalf ("unexpected response %v %v" , v , err )
2450
- }
2451
- })
2452
-
2453
2422
t .Run ("Do" , func (t * testing.T ) {
2454
2423
c := client .B ().Get ().Key ("Do" ).Build ()
2455
2424
if v , err := client .Do (context .Background (), c ).ToString (); err != nil || v != "GET Do" {
@@ -2647,6 +2616,9 @@ func TestClusterClient_SendToOnlyReplicaNodes(t *testing.T) {
2647
2616
primaryNodeConn .AcquireFn = func () wire {
2648
2617
return w
2649
2618
}
2619
+ replicaNodeConn .AcquireFn = func () wire {
2620
+ return w
2621
+ } // Subscribe can work on replicas
2650
2622
if err := client .Dedicated (func (c DedicatedClient ) error {
2651
2623
return c .Receive (context .Background (), c .B ().Subscribe ().Channel ("a" ).Build (), func (msg PubSubMessage ) {})
2652
2624
}); err != e {
@@ -2988,13 +2960,6 @@ func TestClusterClient_SendReadOperationToReplicaNodesWriteOperationToPrimaryNod
2988
2960
t .Fatalf ("unexpected err %v" , err )
2989
2961
}
2990
2962
2991
- t .Run ("Do with no slot" , func (t * testing.T ) {
2992
- c := client .B ().Info ().Build ()
2993
- if v , err := client .Do (context .Background (), c ).ToString (); err != nil || v != "INFO" {
2994
- t .Fatalf ("unexpected response %v %v" , v , err )
2995
- }
2996
- })
2997
-
2998
2963
t .Run ("Do read operation" , func (t * testing.T ) {
2999
2964
c := client .B ().Get ().Key ("Do" ).Build ()
3000
2965
if v , err := client .Do (context .Background (), c ).ToString (); err != nil || v != "GET Do" {
@@ -3241,6 +3206,9 @@ func TestClusterClient_SendReadOperationToReplicaNodesWriteOperationToPrimaryNod
3241
3206
primaryNodeConn .AcquireFn = func () wire {
3242
3207
return w
3243
3208
}
3209
+ replicaNodeConn .AcquireFn = func () wire {
3210
+ return w
3211
+ } // Subscribe can work on replicas
3244
3212
if err := client .Dedicated (func (c DedicatedClient ) error {
3245
3213
return c .Receive (context .Background (), c .B ().Subscribe ().Channel ("a" ).Build (), func (msg PubSubMessage ) {})
3246
3214
}); err != e {
@@ -5090,55 +5058,6 @@ func TestClusterTopologyRefreshment(t *testing.T) {
5090
5058
}
5091
5059
}
5092
5060
})
5093
-
5094
- t .Run ("node role are changed" , func (t * testing.T ) {
5095
- var callCount int64
5096
- refreshWaitCh := make (chan struct {})
5097
- cli , err := newClusterClient (
5098
- & ClientOption {
5099
- InitAddress : []string {"127.0.0.1:0" },
5100
- ClusterOption : ClusterOption {
5101
- ShardsRefreshInterval : time .Second ,
5102
- },
5103
- },
5104
- func (dst string , opt * ClientOption ) conn {
5105
- return & mockConn {
5106
- DoFn : func (cmd Completed ) RedisResult {
5107
- if c := atomic .AddInt64 (& callCount , 1 ); c >= 6 {
5108
- defer func () { recover () }()
5109
- defer close (refreshWaitCh )
5110
- return slotsRespWithChangedRole
5111
- } else if c >= 3 {
5112
- return slotsRespWithChangedRole
5113
- }
5114
- return slotsResp
5115
- },
5116
- }
5117
- },
5118
- newRetryer (defaultRetryDelayFn ),
5119
- )
5120
- if err != nil {
5121
- t .Fatalf ("unexpected err %v" , err )
5122
- }
5123
-
5124
- select {
5125
- case <- refreshWaitCh :
5126
- cli .Close ()
5127
-
5128
- cli .mu .Lock ()
5129
- conns := cli .conns
5130
- cli .mu .Unlock ()
5131
- if len (conns ) != 2 {
5132
- t .Fatalf ("unexpected conns %v" , conns )
5133
- }
5134
- if cc , ok := conns ["127.0.0.1:0" ]; ! ok || ! cc .replica {
5135
- t .Fatalf ("unexpected conns %v" , conns )
5136
- }
5137
- if cc , ok := conns ["127.0.1.1:1" ]; ! ok || cc .replica {
5138
- t .Fatalf ("unexpected conns %v" , conns )
5139
- }
5140
- }
5141
- })
5142
5061
}
5143
5062
5144
5063
func TestClusterClientLoadingRetry (t * testing.T ) {
0 commit comments