@@ -40,15 +40,27 @@ const (
40
40
sentinelPort3 = "9128"
41
41
)
42
42
43
+ const (
44
+ aclSentinelUsername = "sentinel-user"
45
+ aclSentinelPassword = "sentinel-pass"
46
+ aclSentinelName = "my_server"
47
+ aclServerPort = "10001"
48
+ aclSentinelPort1 = "10002"
49
+ aclSentinelPort2 = "10003"
50
+ aclSentinelPort3 = "10004"
51
+ )
52
+
43
53
var (
44
54
sentinelAddrs = []string {":" + sentinelPort1 , ":" + sentinelPort2 , ":" + sentinelPort3 }
55
+ aclSentinelAddrs = []string {":" + aclSentinelPort1 , ":" + aclSentinelPort2 , ":" + aclSentinelPort3 }
45
56
46
57
processes map [string ]* redisProcess
47
58
48
- redisMain * redisProcess
59
+ redisMain , aclServer * redisProcess
49
60
ringShard1 , ringShard2 , ringShard3 * redisProcess
50
61
sentinelMaster , sentinelSlave1 , sentinelSlave2 * redisProcess
51
62
sentinel1 , sentinel2 , sentinel3 * redisProcess
63
+ aclSentinel1 , aclSentinel2 , aclSentinel3 * redisProcess
52
64
)
53
65
54
66
var cluster = & clusterScenario {
@@ -101,6 +113,18 @@ var _ = BeforeSuite(func() {
101
113
Expect (err ).NotTo (HaveOccurred ())
102
114
103
115
Expect (startCluster (ctx , cluster )).NotTo (HaveOccurred ())
116
+
117
+ aclServer , err = startRedis (aclServerPort )
118
+ Expect (err ).NotTo (HaveOccurred ())
119
+
120
+ aclSentinel1 , err = startSentinelWithAcl (aclSentinelPort1 , aclSentinelName , aclServerPort )
121
+ Expect (err ).NotTo (HaveOccurred ())
122
+
123
+ aclSentinel2 , err = startSentinelWithAcl (aclSentinelPort2 , aclSentinelName , aclServerPort )
124
+ Expect (err ).NotTo (HaveOccurred ())
125
+
126
+ aclSentinel3 , err = startSentinelWithAcl (aclSentinelPort3 , aclSentinelName , aclServerPort )
127
+ Expect (err ).NotTo (HaveOccurred ())
104
128
})
105
129
106
130
var _ = AfterSuite (func () {
@@ -364,6 +388,28 @@ func startSentinel(port, masterName, masterPort string) (*redisProcess, error) {
364
388
return p , nil
365
389
}
366
390
391
+ func startSentinelWithAcl (port , masterName , masterPort string ) (* redisProcess , error ) {
392
+ process , err := startSentinel (port , masterName , masterPort )
393
+ if err != nil {
394
+ return nil , err
395
+ }
396
+
397
+ for _ , cmd := range []* redis.StatusCmd {
398
+ redis .NewStatusCmd (ctx , "ACL" , "SETUSER" , aclSentinelUsername , "ON" , ">" + aclSentinelPassword , "-@all" ,
399
+ "+auth" , "+client|getname" , "+client|id" , "+client|setname" , "+command" , "+hello" , "+ping" , "+role" ,
400
+ "+sentinel|get-master-addr-by-name" , "+sentinel|master" , "+sentinel|myid" , "+sentinel|replicas" ,
401
+ "+sentinel|sentinels" ),
402
+ } {
403
+ process .Client .Process (ctx , cmd )
404
+ if err := cmd .Err (); err != nil {
405
+ process .Kill ()
406
+ return nil , err
407
+ }
408
+ }
409
+
410
+ return process , nil
411
+ }
412
+
367
413
//------------------------------------------------------------------------------
368
414
369
415
type badConnError string
0 commit comments