@@ -40,15 +40,27 @@ const (
4040 sentinelPort3 = "9128"
4141)
4242
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+
4353var (
4454 sentinelAddrs = []string {":" + sentinelPort1 , ":" + sentinelPort2 , ":" + sentinelPort3 }
55+ aclSentinelAddrs = []string {":" + aclSentinelPort1 , ":" + aclSentinelPort2 , ":" + aclSentinelPort3 }
4556
4657 processes map [string ]* redisProcess
4758
48- redisMain * redisProcess
59+ redisMain , aclServer * redisProcess
4960 ringShard1 , ringShard2 , ringShard3 * redisProcess
5061 sentinelMaster , sentinelSlave1 , sentinelSlave2 * redisProcess
5162 sentinel1 , sentinel2 , sentinel3 * redisProcess
63+ aclSentinel1 , aclSentinel2 , aclSentinel3 * redisProcess
5264)
5365
5466var cluster = & clusterScenario {
@@ -101,6 +113,18 @@ var _ = BeforeSuite(func() {
101113 Expect (err ).NotTo (HaveOccurred ())
102114
103115 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 ())
104128})
105129
106130var _ = AfterSuite (func () {
@@ -364,6 +388,28 @@ func startSentinel(port, masterName, masterPort string) (*redisProcess, error) {
364388 return p , nil
365389}
366390
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+
367413//------------------------------------------------------------------------------
368414
369415type badConnError string
0 commit comments