@@ -152,7 +152,7 @@ func (tc *TestHelper) SimulateMemcachedReady(name types.NamespacedName) {
152152 serverListWithInet := []string {}
153153 for i := 0 ; i < int (* mc .Spec .Replicas ); i ++ {
154154 serverList = append (serverList , fmt .Sprintf ("%s-%d.%s.%s.svc:11211" , mc .Name , i , mc .Name , mc .Namespace ))
155- serverListWithInet = append (serverListWithInet , fmt .Sprintf ("inet:[ %s-%d.%s.%s.svc] :11211" , mc .Name , i , mc .Name , mc .Namespace ))
155+ serverListWithInet = append (serverListWithInet , fmt .Sprintf ("inet:%s-%d.%s.%s.svc:11211" , mc .Name , i , mc .Name , mc .Namespace ))
156156 }
157157 mc .Status .ServerList = serverList
158158 mc .Status .ServerListWithInet = serverListWithInet
@@ -177,7 +177,7 @@ func (tc *TestHelper) SimulateTLSMemcachedReady(name types.NamespacedName) {
177177 serverListWithInet := []string {}
178178 for i := 0 ; i < int (* mc .Spec .Replicas ); i ++ {
179179 serverList = append (serverList , fmt .Sprintf ("%s-%d.%s.%s.svc:11211" , mc .Name , i , mc .Name , mc .Namespace ))
180- serverListWithInet = append (serverListWithInet , fmt .Sprintf ("inet:[ %s-%d.%s.%s.svc] :11211" , mc .Name , i , mc .Name , mc .Namespace ))
180+ serverListWithInet = append (serverListWithInet , fmt .Sprintf ("inet:%s-%d.%s.%s.svc:11211" , mc .Name , i , mc .Name , mc .Namespace ))
181181 }
182182 mc .Status .ServerList = serverList
183183 mc .Status .ServerListWithInet = serverListWithInet
@@ -203,7 +203,7 @@ func (tc *TestHelper) SimulateMTLSMemcachedReady(name types.NamespacedName) {
203203 serverListWithInet := []string {}
204204 for i := 0 ; i < int (* mc .Spec .Replicas ); i ++ {
205205 serverList = append (serverList , fmt .Sprintf ("%s-%d.%s.%s.svc:11211" , mc .Name , i , mc .Name , mc .Namespace ))
206- serverListWithInet = append (serverListWithInet , fmt .Sprintf ("inet:[ %s-%d.%s.%s.svc] :11211" , mc .Name , i , mc .Name , mc .Namespace ))
206+ serverListWithInet = append (serverListWithInet , fmt .Sprintf ("inet:%s-%d.%s.%s.svc:11211" , mc .Name , i , mc .Name , mc .Namespace ))
207207 }
208208 mc .Status .ServerList = serverList
209209 mc .Status .ServerListWithInet = serverListWithInet
@@ -226,3 +226,28 @@ func (tc *TestHelper) GetDefaultMemcachedSpec() memcachedv1.MemcachedSpec {
226226 },
227227 }
228228}
229+
230+ // SimulateIPv6MemcachedReady simulates a ready state for a Memcached instance in a Kubernetes cluster with IPv6 server list formatting.
231+ func (tc * TestHelper ) SimulateIPv6MemcachedReady (name types.NamespacedName ) {
232+ t .Eventually (func (g t.Gomega ) {
233+ mc := tc .GetMemcached (name )
234+ mc .Status .ObservedGeneration = mc .Generation
235+ mc .Status .Conditions .MarkTrue (condition .ReadyCondition , condition .ReadyMessage )
236+ mc .Status .ReadyCount = * mc .Spec .Replicas
237+
238+ serverList := []string {}
239+ serverListWithInet := []string {}
240+ for i := 0 ; i < int (* mc .Spec .Replicas ); i ++ {
241+ serverList = append (serverList , fmt .Sprintf ("%s-%d.%s.%s.svc:11211" , mc .Name , i , mc .Name , mc .Namespace ))
242+ serverListWithInet = append (serverListWithInet , fmt .Sprintf ("inet6:[%s-%d.%s.%s.svc]:11211" , mc .Name , i , mc .Name , mc .Namespace ))
243+ }
244+ mc .Status .ServerList = serverList
245+ mc .Status .ServerListWithInet = serverListWithInet
246+
247+ // This can return conflict so we have the t.Eventually block to retry
248+ g .Expect (tc .K8sClient .Status ().Update (tc .Ctx , mc )).To (t .Succeed ())
249+
250+ }, tc .Timeout , tc .Interval ).Should (t .Succeed ())
251+
252+ tc .Logger .Info ("Simulated IPv6 memcached ready" , "on" , name )
253+ }
0 commit comments