From e38e4aefa93e147c70ea1764b72d50db07020e80 Mon Sep 17 00:00:00 2001 From: Endial Fang Date: Wed, 30 Jul 2025 12:28:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/tests/test-connection.yaml | 15 --------- templates/tests/test-postgres-connection.yaml | 30 ++++++++++++++++++ templates/tests/test-redis-connection.yaml | 31 +++++++++++++++++++ 3 files changed, 61 insertions(+), 15 deletions(-) delete mode 100644 templates/tests/test-connection.yaml create mode 100644 templates/tests/test-postgres-connection.yaml create mode 100644 templates/tests/test-redis-connection.yaml diff --git a/templates/tests/test-connection.yaml b/templates/tests/test-connection.yaml deleted file mode 100644 index f70c9df..0000000 --- a/templates/tests/test-connection.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "dify.fullname" . }}-test-connection" - labels: - {{- include "dify.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": test -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "dify.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never diff --git a/templates/tests/test-postgres-connection.yaml b/templates/tests/test-postgres-connection.yaml new file mode 100644 index 0000000..303c1f2 --- /dev/null +++ b/templates/tests/test-postgres-connection.yaml @@ -0,0 +1,30 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: "{{ include "dify.fullname" . }}-test-postgres-connection" + labels: + {{- include "dify.labels" . | nindent 4 }} + component: "postgres" + annotations: + "helm.sh/hook": test +spec: + template: + spec: + restartPolicy: Never + containers: + - name: check-postgres + image: "{{ .Values.postgresql.image.registry }}/{{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }}" + command: + - sh + - -c + - | + until PGPASSWORD=$DB_PASSWORD pg_isready -h $DB_HOST -U $DB_USERNAME -d $DB_DATABASE ; do + echo "Waiting for PostgreSQL sequence to be available..." + sleep 1 + done + echo "PostgreSQL is ready." + envFrom: + - configMapRef: + name: {{ template "dify.api.fullname" . }} + - secretRef: + name: {{ template "dify.api.fullname" . }} diff --git a/templates/tests/test-redis-connection.yaml b/templates/tests/test-redis-connection.yaml new file mode 100644 index 0000000..bb0aeac --- /dev/null +++ b/templates/tests/test-redis-connection.yaml @@ -0,0 +1,31 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: "{{ include "dify.fullname" . }}-test-redis-connection" + labels: + {{- include "dify.labels" . | nindent 4 }} + component: "redis" + annotations: + "helm.sh/hook": test +spec: + template: + spec: + restartPolicy: Never + containers: + - name: check-redis + image: "{{ .Values.redis.image.registry }}/{{ .Values.redis.image.repository }}:{{ .Values.redis.image.tag }}" + command: + - sh + - -c + - | + until redis-cli -h $REDIS_HOST -p $REDIS_PORT -a $REDIS_PASSWORD ping | grep -q PONG; do + echo "Waiting for Redis service to be available..." + sleep 1 + done + echo "Redis is ready." + envFrom: + - configMapRef: + name: {{ template "dify.api.fullname" . }} + - secretRef: + name: {{ template "dify.api.fullname" . }} +