53
53
- name : Wait for services to be ready
54
54
run : |
55
55
echo "Waiting for services to be ready..."
56
-
56
+
57
57
# Wait for NGINX to be ready
58
58
for i in {1..30}; do
59
59
if curl -s http://localhost:8081/stub_status > /dev/null 2>&1; then
63
63
echo "Waiting for NGINX stub_status... (attempt $i/30)"
64
64
sleep 2
65
65
done
66
-
66
+
67
67
# Wait for NGINX Exporter to be ready
68
68
for i in {1..30}; do
69
69
if curl -s http://localhost:9113/metrics > /dev/null 2>&1; then
@@ -78,15 +78,15 @@ jobs:
78
78
run : |
79
79
echo "Verifying container status..."
80
80
docker-compose ps
81
-
81
+
82
82
# Check if nginx-exporter container is running
83
83
if ! docker-compose ps nginx-exporter | grep -q "Up"; then
84
84
echo "❌ NGINX Exporter container is not running"
85
85
docker-compose logs nginx-exporter
86
86
exit 1
87
87
fi
88
88
echo "✓ NGINX Exporter container is running"
89
-
89
+
90
90
# Check if nginx container is running
91
91
if ! docker-compose ps nginx | grep -q "Up"; then
92
92
echo "❌ NGINX container is not running"
@@ -99,12 +99,12 @@ jobs:
99
99
run : |
100
100
echo "Testing NGINX stub_status endpoint..."
101
101
response=$(curl -s http://localhost:8081/stub_status)
102
-
102
+
103
103
if [[ -z "$response" ]]; then
104
104
echo "❌ NGINX stub_status endpoint returned empty response"
105
105
exit 1
106
106
fi
107
-
107
+
108
108
# Check if response contains expected metrics
109
109
if echo "$response" | grep -q "Active connections:"; then
110
110
echo "✓ NGINX stub_status endpoint is working correctly"
@@ -118,12 +118,12 @@ jobs:
118
118
run : |
119
119
echo "Testing NGINX Exporter metrics endpoint..."
120
120
response=$(curl -s http://localhost:9113/metrics)
121
-
121
+
122
122
if [[ -z "$response" ]]; then
123
123
echo "❌ NGINX Exporter metrics endpoint returned empty response"
124
124
exit 1
125
125
fi
126
-
126
+
127
127
# Check if response contains expected NGINX metrics
128
128
if echo "$response" | grep -q "nginx_connections_accepted"; then
129
129
echo "✓ NGINX Exporter metrics endpoint is working correctly"
@@ -136,20 +136,20 @@ jobs:
136
136
- name : Verify metrics collection
137
137
run : |
138
138
echo "Verifying metrics collection..."
139
-
139
+
140
140
# Generate some traffic to NGINX
141
141
echo "Generating traffic to NGINX..."
142
142
for i in {1..5}; do
143
143
curl -s http://localhost:80 > /dev/null || true
144
144
sleep 1
145
145
done
146
-
146
+
147
147
# Wait a moment for metrics to be updated
148
148
sleep 3
149
-
149
+
150
150
# Check if metrics are being collected
151
151
metrics=$(curl -s http://localhost:9113/metrics)
152
-
152
+
153
153
# Verify nginx_up metric exists and is 1
154
154
if echo "$metrics" | grep -q "nginx_up 1"; then
155
155
echo "✓ NGINX Exporter is successfully collecting metrics"
@@ -159,7 +159,7 @@ jobs:
159
159
echo "$metrics" | grep "nginx_up" || echo "nginx_up metric not found"
160
160
exit 1
161
161
fi
162
-
162
+
163
163
# Verify connection metrics exist
164
164
if echo "$metrics" | grep -q "nginx_connections_accepted"; then
165
165
echo "✓ Connection metrics are being collected"
@@ -171,7 +171,7 @@ jobs:
171
171
- name : Test service connectivity
172
172
run : |
173
173
echo "Testing service connectivity..."
174
-
174
+
175
175
# Test that services can communicate internally
176
176
docker exec nginx-prometheus-exporter curl -f http://nginx:8081/stub_status > /dev/null
177
177
echo "✓ Services can communicate internally"
@@ -214,13 +214,13 @@ jobs:
214
214
- name : Wait for all services to be ready
215
215
run : |
216
216
echo "Waiting for all services to be ready..."
217
-
217
+
218
218
# Wait for all services to be healthy
219
219
services=("nginx:8081/stub_status" "nginx-exporter:9113/metrics" "prometheus:9090/-/ready" "grafana:3000/api/health")
220
-
220
+
221
221
for service in "${services[@]}"; do
222
222
IFS=':' read -r host_port path <<< "$service"
223
-
223
+
224
224
for i in {1..60}; do
225
225
if curl -s "http://localhost:${host_port}${path}" > /dev/null 2>&1; then
226
226
echo "✓ Service ${host_port} is ready"
@@ -235,10 +235,10 @@ jobs:
235
235
run : |
236
236
echo "Verifying all containers are running..."
237
237
docker-compose ps
238
-
238
+
239
239
# Check that all expected services are up
240
240
services=("nginx" "nginx-exporter" "prometheus" "grafana" "app")
241
-
241
+
242
242
for service in "${services[@]}"; do
243
243
if ! docker-compose ps "$service" | grep -q "Up"; then
244
244
echo "❌ Service $service is not running"
@@ -251,7 +251,7 @@ jobs:
251
251
- name : Test full stack integration
252
252
run : |
253
253
echo "Testing full stack integration..."
254
-
254
+
255
255
# Test Prometheus can scrape NGINX Exporter
256
256
prometheus_targets=$(curl -s http://localhost:9090/api/v1/targets)
257
257
if echo "$prometheus_targets" | grep -q "nginx-exporter:9113"; then
@@ -260,7 +260,7 @@ jobs:
260
260
echo "❌ Prometheus is not configured to scrape NGINX Exporter"
261
261
exit 1
262
262
fi
263
-
263
+
264
264
# Test Grafana is accessible
265
265
grafana_health=$(curl -s http://localhost:3000/api/health)
266
266
if echo "$grafana_health" | grep -q "ok"; then
0 commit comments