From 7455bb45eddaf9855aa55bfb9f07ae6874460d72 Mon Sep 17 00:00:00 2001 From: Lianhao Lu Date: Wed, 22 Jan 2025 02:53:23 +0000 Subject: [PATCH] redis: improve redis test Improve redis test for retry in case of k8s service is not ready in time. Signed-off-by: Lianhao Lu --- .../redis-vector-db/templates/tests/test-pod.yaml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/helm-charts/common/redis-vector-db/templates/tests/test-pod.yaml b/helm-charts/common/redis-vector-db/templates/tests/test-pod.yaml index d694c1f63..7e37e03c0 100644 --- a/helm-charts/common/redis-vector-db/templates/tests/test-pod.yaml +++ b/helm-charts/common/redis-vector-db/templates/tests/test-pod.yaml @@ -17,9 +17,14 @@ spec: command: ['sh', '-c'] args: - | - redis-cli -h {{ include "redis-vector-db.fullname" . }} \ - {{- with (first .Values.service.ports) }} - -p {{ .port }} \ - {{- end }} - ping + host={{ include "redis-vector-db.fullname" . }}; + {{- with (first .Values.service.ports) }} + port={{ .port }}; + {{- end }} + max_retry=10; + j=0; + while ! redis-cli -h "${host}" -p ${port} ping; do + [[ $j -ge ${max_retry} ]] && echo "ERROR: redis ping to ${host}:${port} error" && exit 1; + j=$((j+1)); sleep 1; + done; restartPolicy: Never