Skip to content

Commit 05c3fc5

Browse files
Add CI tests for external MySQL (#354)
1 parent 98cf80e commit 05c3fc5

File tree

3 files changed

+2840
-0
lines changed

3 files changed

+2840
-0
lines changed

.github/workflows/ci-eso.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ on:
1919
options:
2020
- "legacy: using built-in components (baseline)"
2121
- "legacy: using external services (Redis, PostgreSQL, S3)"
22+
- "legacy: using external services (Redis, MySQL, S3)"
2223
- "external-secrets: using built-in components"
2324
- "external-secrets: using external services (S3, PostgreSQL, Elasticsearch, Redis)"
2425
- "external-secrets + OTEL: using external services (OpenTelemetry)"
@@ -141,6 +142,7 @@ jobs:
141142
use_external_pg: false
142143
use_external_s3: false
143144
use_external_es: false
145+
use_external_mysql: false
144146

145147
# Test all external components together (legacy) - Redis, PostgreSQL, S3
146148
- config_name: "legacy: using external services (Redis, PostgreSQL, S3)"
@@ -150,6 +152,17 @@ jobs:
150152
use_external_pg: true
151153
use_external_s3: true
152154
use_external_es: false
155+
use_external_mysql: false
156+
157+
# Test all external components together (legacy) - Redis, MySQL, S3
158+
- config_name: "legacy: using external services (Redis, MySQL, S3)"
159+
values_file: "values-legacy-external-mysql-all.yaml"
160+
use_eso: false
161+
use_external_redis: true
162+
use_external_pg: false
163+
use_external_s3: true
164+
use_external_es: false
165+
use_external_mysql: true
153166

154167
# Test ESO mechanism with built-in components (validates ESO integration)
155168
- config_name: "external-secrets: using built-in components"
@@ -159,6 +172,7 @@ jobs:
159172
use_external_pg: false
160173
use_external_s3: false
161174
use_external_es: false
175+
use_external_mysql: false
162176

163177
# Test ESO with all external components (most complex scenario, validates ESO with external services)
164178
- config_name: "external-secrets: using external services (S3, PostgreSQL, Elasticsearch, Redis)"
@@ -168,6 +182,7 @@ jobs:
168182
use_external_pg: true
169183
use_external_s3: true
170184
use_external_es: true
185+
use_external_mysql: false
171186

172187
# Test OTEL integration with ESO (modern stack)
173188
- config_name: "external-secrets + OTEL: using external services (OpenTelemetry)"
@@ -177,6 +192,7 @@ jobs:
177192
use_external_pg: false
178193
use_external_s3: false
179194
use_external_es: false
195+
use_external_mysql: false
180196
use_otel_collector: true
181197

182198
name: ${{ matrix.config_name }}
@@ -317,6 +333,26 @@ jobs:
317333
chmod +x ci/scripts/setup-external-postgres-dns.sh
318334
ci/scripts/setup-external-postgres-dns.sh
319335
336+
- name: Install external MySQL
337+
if: matrix.use_external_mysql
338+
run: |
339+
echo "Installing external MySQL..."
340+
helm install external-mysql bitnami/mysql \
341+
--version 10.3.0 \
342+
--set image.repository="bitnamilegacy/mysql" \
343+
--set auth.rootPassword="difyai123456" \
344+
--set auth.database="dify" \
345+
--set primary.service.type="ClusterIP" \
346+
--set primary.service.ports.mysql=3306 \
347+
--wait \
348+
--timeout 300s
349+
350+
- name: Setup external MySQL DNS
351+
if: matrix.use_external_mysql
352+
run: |
353+
chmod +x ci/scripts/setup-external-mysql-dns.sh
354+
ci/scripts/setup-external-mysql-dns.sh
355+
320356
- name: Install MinIO
321357
if: matrix.use_external_s3
322358
run: |
@@ -445,6 +481,7 @@ jobs:
445481
echo "Tested Configurations:"
446482
echo "- Legacy: Built-in (PostgreSQL, Redis) - baseline"
447483
echo "- Legacy: External services (Redis, PostgreSQL, S3) - merged external components"
484+
echo "- Legacy: External services (Redis, MySQL, S3) - merged external components with MySQL"
448485
echo "- ESO: Built-in (PostgreSQL, Redis) - validates ESO mechanism"
449486
echo "- ESO: External services (S3, PostgreSQL, Elasticsearch, Redis) - most complex scenario"
450487
echo "- ESO + OTEL: External services (OpenTelemetry) - modern stack"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
echo "INFO: Setting up external MySQL DNS resolution..."
5+
6+
# Wait for MySQL to be ready
7+
echo "INFO: Waiting for external MySQL to be ready..."
8+
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=mysql --timeout=300s
9+
10+
# Test database connection
11+
echo "INFO: Testing database connection..."
12+
kubectl run mysql-test --rm --image=mysql:8.0 --restart=Never -- \
13+
mysql -h external-mysql-mysql -u root -pdifyai123456 -e "SHOW DATABASES;" || echo "Connection test completed"
14+
15+
# Get the MySQL service cluster IP
16+
MYSQL_IP=$(kubectl get service external-mysql-mysql -o jsonpath='{.spec.clusterIP}')
17+
echo "INFO: MySQL service IP: $MYSQL_IP"
18+
19+
# Update CoreDNS to simulate external hostname resolution
20+
echo "INFO: Configuring CoreDNS for external MySQL hostname..."
21+
kubectl patch configmap coredns -n kube-system --type merge -p='{"data":{"Corefile":".:53 {\n errors\n health {\n lameduck 5s\n }\n ready\n kubernetes cluster.local in-addr.arpa ip6.arpa {\n pods insecure\n fallthrough in-addr.arpa ip6.arpa\n ttl 30\n }\n hosts {\n '$MYSQL_IP' mysql1.uat.internal.dify.ai\n fallthrough\n }\n prometheus :9153\n forward . /etc/resolv.conf {\n max_concurrent 1000\n }\n cache 30\n loop\n reload\n loadbalance\n}"}}'
22+
23+
# Restart CoreDNS to pick up the changes
24+
echo "INFO: Restarting CoreDNS..."
25+
kubectl rollout restart deployment/coredns -n kube-system
26+
kubectl rollout status deployment/coredns -n kube-system --timeout=120s
27+
28+
# Test external hostname resolution
29+
echo "INFO: Testing external hostname resolution..."
30+
kubectl run dns-test --rm --image=busybox --restart=Never -- nslookup mysql1.uat.internal.dify.ai || echo "DNS test completed"
31+
32+
echo "SUCCESS: External MySQL DNS setup completed"
33+
echo "INFO: MySQL available at: mysql1.uat.internal.dify.ai:3306"
34+
echo "INFO: Internal service: external-mysql-mysql:3306"
35+

0 commit comments

Comments
 (0)