Skip to content

Commit

Permalink
[helpers] add SimulateTLSMemcachedReady
Browse files Browse the repository at this point in the history
adds helper which sets status.TLSSupport = true. This allows
to add tests where the memcached instance is configured for tls.

OSPRH-5283
  • Loading branch information
stuggi committed Apr 8, 2024
1 parent cacd7b5 commit bd78abd
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions apis/test/helpers/memcached.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,28 @@ func (tc *TestHelper) SimulateMemcachedReady(name types.NamespacedName) {

tc.Logger.Info("Simulated memcached ready", "on", name)
}

// SimulateTLSMemcachedReady simulates a ready state for a Memcached instance in a Kubernetes cluster which supports TLS.
func (tc *TestHelper) SimulateTLSMemcachedReady(name types.NamespacedName) {
t.Eventually(func(g t.Gomega) {
mc := tc.GetMemcached(name)
mc.Status.Conditions.MarkTrue(condition.ReadyCondition, condition.ReadyMessage)
mc.Status.ReadyCount = *mc.Spec.Replicas

serverList := []string{}
serverListWithInet := []string{}
for i := 0; i < int(*mc.Spec.Replicas); i++ {
serverList = append(serverList, fmt.Sprintf("%s-%d.%s.%s.svc:11211", mc.Name, i, mc.Name, mc.Namespace))
serverListWithInet = append(serverListWithInet, fmt.Sprintf("inet:[%s-%d.%s.%s.svc]:11211", mc.Name, i, mc.Name, mc.Namespace))
}
mc.Status.ServerList = serverList
mc.Status.ServerListWithInet = serverListWithInet
mc.Status.TLSSupport = true

// This can return conflict so we have the t.Eventually block to retry
g.Expect(tc.K8sClient.Status().Update(tc.Ctx, mc)).To(t.Succeed())

}, tc.Timeout, tc.Interval).Should(t.Succeed())

tc.Logger.Info("Simulated memcached ready", "on", name)
}

0 comments on commit bd78abd

Please sign in to comment.