From 1b5a5e5cf5f7bb37cbc04b17b02c0a27928a99e8 Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Wed, 25 Nov 2026 20:02:42 +0300 Subject: [PATCH] test(redis): assert a scaled-down instance loses its Sentinel PDB Every Redis e2e case runs two replicas, so the single-Sentinel path, where the chart disables the Sentinel PDB and the operator has to delete the one it created for three Sentinels, was covered only by the operator's unit test. Scale the base instance from two replicas to one and assert that the PDB existed before, is gone after, and that the data pods' PDB stays. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- hack/e2e-chainsaw/redis/chainsaw-test.yaml | 68 ++++++++++++++++++++++ hack/e2e-chainsaw/redis/redis-single.yaml | 12 ++++ 2 files changed, 80 insertions(+) create mode 100644 hack/e2e-chainsaw/redis/redis-single.yaml diff --git a/hack/e2e-chainsaw/redis/chainsaw-test.yaml b/hack/e2e-chainsaw/redis/chainsaw-test.yaml index 2945e8351..feb45281e 100644 --- a/hack/e2e-chainsaw/redis/chainsaw-test.yaml +++ b/hack/e2e-chainsaw/redis/chainsaw-test.yaml @@ -13,6 +13,12 @@ spec: - podLogs: selector: app.kubernetes.io/instance=redis-test tail: 50 + # The scale-down step waits on the operator deleting a PDB, which leaves its + # trace in the operator's log and nowhere in the tenant namespace. + - podLogs: + namespace: cozy-redis-operator + selector: app.kubernetes.io/name=redis-operator + tail: 100 steps: - name: create-redis try: @@ -74,6 +80,68 @@ spec: name: rfr-redis-test status: readyReplicas: 2 + + # One replica runs one Sentinel with its PDB disabled. The PDB the operator + # created for the three Sentinels of two replicas has to go with it, or its + # minAvailable: 1 pins the only Sentinel against every eviction. + - name: scale-down-drops-sentinel-pdb + try: + # Positive control: the absence asserted below is also what an operator + # that never created the PDB looks like. + - assert: + timeout: 2m + resource: + apiVersion: policy/v1 + kind: PodDisruptionBudget + metadata: + name: rfs-redis-test + - apply: + file: redis-single.yaml + # The upgraded chart reaching the RedisFailover is what starts the + # operator's part; asserting it first tells a chart that never disabled + # the PDB apart from an operator that left it behind. + - assert: + timeout: 5m + resource: + apiVersion: databases.spotahome.com/v1 + kind: RedisFailover + metadata: + name: redis-test + spec: + sentinel: + replicas: 1 + disablePodDisruptionBudget: true + # 2m: a RedisFailover change triggers a reconcile, and the operator + # resyncs every 30s besides. + - error: + timeout: 2m + resource: + apiVersion: policy/v1 + kind: PodDisruptionBudget + metadata: + name: rfs-redis-test + # The data pods' PDB is still enabled and must stay. + - assert: + timeout: 1m + resource: + apiVersion: policy/v1 + kind: PodDisruptionBudget + metadata: + name: rfr-redis-test + # The upgrade holds the release until the StatefulSet has scaled, and + # cleanup cannot uninstall it before then. Same 11m as the install wait; + # matching generations keep the Ready left from the install from passing. + - assert: + timeout: 11m + resource: + apiVersion: helm.toolkit.fluxcd.io/v2 + kind: HelmRelease + metadata: + name: redis-test + (status.observedGeneration == metadata.generation): true + status: + (conditions[?type == 'Ready']): + - status: "True" --- # TLS on. Everything the unit tests can only render runs live here: the # rebuilt operator with the TLS patch, the CRD and ClusterRole patches on its diff --git a/hack/e2e-chainsaw/redis/redis-single.yaml b/hack/e2e-chainsaw/redis/redis-single.yaml new file mode 100644 index 000000000..caebe997c --- /dev/null +++ b/hack/e2e-chainsaw/redis/redis-single.yaml @@ -0,0 +1,12 @@ +apiVersion: apps.cozystack.io/v1alpha1 +kind: Redis +metadata: + name: test +spec: + external: false + size: 1Gi + replicas: 1 + storageClass: "" + authEnabled: true + resources: {} + resourcesPreset: "nano"