Skip to content

Commit 85abe51

Browse files
committed
feat: add comprehensive Docker testing with CI integration
- Add cascading Docker Compose test (cluster init -> db create -> API validation -> Redis test) - Add Docker test workflow for CI - Simplify Dockerfile to use Debian bookworm-slim for compatibility - Remove private image requirement, default to official Redis Enterprise image
1 parent 35e614d commit 85abe51

File tree

3 files changed

+156
-17
lines changed

3 files changed

+156
-17
lines changed

.github/workflows/docker-test.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Docker Test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- 'docker-compose.yml'
8+
- 'Dockerfile'
9+
- '.github/workflows/docker-test.yml'
10+
- 'crates/**'
11+
pull_request:
12+
paths:
13+
- 'docker-compose.yml'
14+
- 'Dockerfile'
15+
- '.github/workflows/docker-test.yml'
16+
- 'crates/**'
17+
18+
env:
19+
CARGO_TERM_COLOR: always
20+
21+
jobs:
22+
docker-test:
23+
name: Docker Compose Test
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 15
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Build Docker images
35+
run: docker compose build
36+
37+
- name: Run Docker Compose test cascade
38+
run: |
39+
docker compose up --abort-on-container-exit --exit-code-from test-redis
40+
EXIT_CODE=$?
41+
docker compose logs
42+
docker compose down -v
43+
exit $EXIT_CODE
44+
45+
- name: Cleanup
46+
if: always()
47+
run: docker compose down -v

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ COPY crates/ ./crates/
1212
# Build release binary
1313
RUN cargo build --release --bin redisctl
1414

15-
# Runtime stage - minimal debian image
15+
# Runtime stage - Debian for compatibility
1616
FROM debian:bookworm-slim
1717

1818
# Install runtime dependencies

docker-compose.yml

Lines changed: 108 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
# Redis Enterprise Test Environment
1+
# Redis Enterprise Test Environment with Full Validation
22
#
33
# Usage:
4-
# docker compose up -d # Start enterprise and initialize cluster
5-
# docker compose logs init # Check initialization status
4+
# docker compose up -d # Start and run full test cascade
5+
# docker compose logs -f # Watch all service logs
66
# docker compose down -v # Clean up everything
7+
#
8+
# For Mac users: Set REDIS_ENTERPRISE_IMAGE=kurtfm/rs-arm:latest
79

810
services:
911
# Redis Enterprise server
@@ -29,12 +31,12 @@ services:
2931
networks:
3032
- redis-net
3133

32-
# Initialize cluster and create database
33-
init:
34+
# Initialize cluster
35+
init-cluster:
3436
build:
3537
context: .
3638
dockerfile: Dockerfile
37-
container_name: redis-enterprise-init
39+
container_name: init-cluster
3840
restart: "no"
3941
depends_on:
4042
enterprise:
@@ -47,43 +49,133 @@ services:
4749
command: |
4850
sh -c '
4951
echo "========================================" &&
50-
echo "Initializing Redis Enterprise cluster..." &&
52+
echo "Step 1: Initializing Redis Enterprise cluster..." &&
5153
echo "========================================" &&
5254
53-
# Initialize cluster
5455
redisctl enterprise workflow init-cluster \
5556
--insecure \
5657
--name "test-cluster" \
5758
--username "[email protected]" \
5859
--password "Redis123!" \
5960
--accept-eula &&
6061
61-
echo "" &&
62+
echo "✓ Cluster initialized successfully" &&
63+
echo ""
64+
'
65+
66+
# Create database
67+
create-db:
68+
build:
69+
context: .
70+
dockerfile: Dockerfile
71+
container_name: create-db
72+
restart: "no"
73+
depends_on:
74+
init-cluster:
75+
condition: service_completed_successfully
76+
environment:
77+
REDIS_ENTERPRISE_URL: "https://enterprise:9443"
78+
REDIS_ENTERPRISE_USER: "[email protected]"
79+
REDIS_ENTERPRISE_PASSWORD: "Redis123!"
80+
RUST_LOG: ${RUST_LOG:-info}
81+
networks:
82+
- redis-net
83+
command: |
84+
sh -c '
6285
echo "========================================" &&
63-
echo "Creating test database..." &&
86+
echo "Step 2: Creating test database..." &&
6487
echo "========================================" &&
6588
66-
# Create database using the workflow
6789
redisctl enterprise workflow create-database \
6890
--insecure \
6991
--name "test-db" \
7092
--memory 100MB \
7193
--port 12000 &&
7294
95+
echo "✓ Database created successfully" &&
96+
echo ""
97+
'
98+
99+
# Validate API
100+
validate-api:
101+
build:
102+
context: .
103+
dockerfile: Dockerfile
104+
container_name: validate-api
105+
restart: "no"
106+
depends_on:
107+
create-db:
108+
condition: service_completed_successfully
109+
environment:
110+
REDIS_ENTERPRISE_URL: "https://enterprise:9443"
111+
REDIS_ENTERPRISE_USER: "[email protected]"
112+
REDIS_ENTERPRISE_PASSWORD: "Redis123!"
113+
RUST_LOG: ${RUST_LOG:-info}
114+
networks:
115+
- redis-net
116+
command: |
117+
sh -c '
118+
echo "========================================" &&
119+
echo "Step 3: Validating API endpoints..." &&
120+
echo "========================================" &&
121+
122+
echo "→ Listing databases..." &&
123+
redisctl enterprise database list --insecure --output table &&
124+
125+
echo "" &&
126+
echo "→ Getting database info..." &&
127+
redisctl enterprise database get 1 --insecure --output json | head -20 &&
128+
73129
echo "" &&
130+
echo "→ Checking cluster info..." &&
131+
redisctl enterprise cluster info --insecure --query "name" &&
132+
133+
echo "✓ API validation successful" &&
134+
echo ""
135+
'
136+
137+
# Test Redis connection
138+
test-redis:
139+
image: redis:7-alpine
140+
container_name: test-redis
141+
restart: "no"
142+
depends_on:
143+
validate-api:
144+
condition: service_completed_successfully
145+
networks:
146+
- redis-net
147+
command: |
148+
sh -c '
74149
echo "========================================" &&
75-
echo "Setup complete!" &&
150+
echo "Step 4: Testing Redis connection..." &&
151+
echo "========================================" &&
152+
153+
# Wait for database to be fully ready
154+
sleep 5 &&
155+
156+
echo "→ Setting test key..." &&
157+
redis-cli -h enterprise -p 12000 SET test:key "Hello from Docker!" &&
158+
159+
echo "→ Getting test key..." &&
160+
redis-cli -h enterprise -p 12000 GET test:key &&
161+
162+
echo "→ Running PING..." &&
163+
redis-cli -h enterprise -p 12000 PING &&
164+
165+
echo "→ Getting INFO..." &&
166+
redis-cli -h enterprise -p 12000 INFO server | head -10 &&
167+
168+
echo "" &&
169+
echo "========================================" &&
170+
echo "✅ All tests passed successfully!" &&
76171
echo "" &&
77172
echo "Web UI: https://localhost:8443" &&
78173
echo "Username: [email protected]" &&
79174
echo "Password: Redis123!" &&
80175
echo "" &&
81176
echo "API: https://localhost:9443" &&
82177
echo "Database: redis://localhost:12000" &&
83-
echo "========================================" &&
84-
85-
# List databases to confirm
86-
redisctl enterprise database list --insecure --output table
178+
echo "========================================"
87179
'
88180
89181
networks:

0 commit comments

Comments
 (0)