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 <f@lex.la>
This commit is contained in:
Aleksei Sviridkin committed 2026-12-02 05:45:53 +03:00
1 parent aeb9bf6fbf
commit 1b5a5e5cf5
2 files changed
+80

No files matched your search

@@ -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
+12
View File
@@ -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"