1111 - ' content/opensource_packages/apisix.md'
1212 - ' .github/workflows/test-apisix.yml'
1313
14-
1514jobs :
1615 test-apisix :
1716 runs-on : ubuntu-24.04-arm
18-
17+
1918 steps :
2019 - name : Checkout repository
2120 uses : actions/checkout@v4
22-
21+
2322 - name : Set test metadata
2423 id : metadata
2524 run : |
2625 echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT
2726 echo "package_slug=apisix" >> $GITHUB_OUTPUT
2827 echo "dashboard_link=/opensource_packages/apisix" >> $GITHUB_OUTPUT
29-
28+
3029 - name : Install Apache APISIX
3130 id : install
3231 run : |
3332 echo "Installing Apache APISIX via Docker..."
34-
33+
34+ # Clean up any old containers from previous runs
35+ docker rm -f apisix etcd 2>/dev/null || true
36+
3537 # Using APISIX 3.8.0 (late 2023)
3638 # etcd is required as a dependency
37-
38- docker network create apisix-net
39-
40- echo "Starting etcd..."
39+
40+ docker network create apisix-net 2>/dev/null || true
41+
42+ echo "Starting etcd (bitnami/etcd:3.5.10) ..."
4143 docker run -d --name etcd \
4244 --network apisix-net \
4345 -p 2379:2379 \
44- gcr.io/etcd-development/etcd:v3.5.10 \
45- /usr/local/bin/etcd \
46- --name s1 \
47- --data-dir=/etcd-data \
48- --listen-client-urls=http://0.0.0.0:2379 \
49- --advertise-client-urls=http://etcd:2379 \
50- --listen-peer-urls=http://0.0.0.0:2380 \
51- --initial-advertise-peer-urls=http://etcd:2380 \
52- --initial-cluster=s1=http://etcd:2380 \
53- --initial-cluster-state=new
54-
55- # Wait for etcd to be ready
56- echo "Waiting for etcd to become ready..."
57- for i in {1..15}; do
58- if docker exec etcd /usr/local/bin/etcdctl \
59- --endpoints=http://127.0.0.1:2379 endpoint health >/dev/null 2>&1; then
60- echo "etcd is healthy"
61- break
62- fi
63- echo "etcd not ready yet, retrying..."
64- sleep 2
65- done
66-
46+ -e ALLOW_NONE_AUTHENTICATION=yes \
47+ -e ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379 \
48+ -e ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 \
49+ bitnami/etcd:3.5.10
50+
51+ # Give etcd time to start
52+ echo "Waiting for etcd to start..."
53+ sleep 20
54+
6755 echo "Starting APISIX..."
6856 docker run -d --name apisix \
6957 --network apisix-net \
7058 -p 9080:9080 -p 9091:9091 -p 9443:9443 -p 9180:9180 \
7159 -e APISIX_STAND_ALONE=false \
7260 -e ETCD_HOST="http://etcd:2379" \
7361 apache/apisix:3.8.0-debian
74-
62+
7563 # Wait for APISIX
7664 echo "Waiting for APISIX to start..."
7765 sleep 20
78-
66+
7967 echo "install_status=success" >> $GITHUB_OUTPUT
80-
68+
8169 - name : Get APISIX version
8270 id : version
8371 run : |
8472 VERSION=$(docker exec apisix apisix version | grep "version" | awk '{print $3}')
8573 if [ -z "$VERSION" ]; then VERSION="3.8.0"; fi
8674 echo "version=$VERSION" >> $GITHUB_OUTPUT
8775 echo "Detected APISIX version: $VERSION"
88-
76+
8977 - name : Test 1 - Check container running
9078 id : test1
9179 run : |
9280 START_TIME=$(date +%s)
93-
81+
9482 if docker ps | grep -q "apisix"; then
9583 echo "✓ apisix container running"
9684 echo "status=passed" >> $GITHUB_OUTPUT
9785 else
9886 echo "✗ apisix container not running"
99- docker ps
87+ echo "=== docker ps ==="
88+ docker ps || true
89+ echo "=== apisix logs ==="
10090 docker logs apisix || true
91+ echo "=== etcd logs ==="
92+ docker logs etcd || true
10193 echo "status=failed" >> $GITHUB_OUTPUT
10294 exit 1
10395 fi
104-
96+
10597 END_TIME=$(date +%s)
10698 echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT
107-
99+
108100 - name : Test 2 - Check Admin API
109101 id : test2
110102 run : |
111103 START_TIME=$(date +%s)
112-
104+
113105 # Default admin key is edd1c9f034335f136f87ad84b625c8f1
114106 if curl -s -H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1" \
115107 http://127.0.0.1:9180/apisix/admin/routes | grep -q "list"; then
@@ -121,15 +113,15 @@ jobs:
121113 echo "status=failed" >> $GITHUB_OUTPUT
122114 exit 1
123115 fi
124-
116+
125117 END_TIME=$(date +%s)
126118 echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT
127119
128120 - name : Test 3 - Create a Route
129121 id : test3
130122 run : |
131123 START_TIME=$(date +%s)
132-
124+
133125 # Create a route that forwards /get to httpbin.org
134126 RESPONSE=$(curl -s -X PUT \
135127 -H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1" \
@@ -143,7 +135,7 @@ jobs:
143135 }
144136 }
145137 }')
146-
138+
147139 if echo "$RESPONSE" | grep -q "key"; then
148140 echo "✓ route creation works"
149141 echo "status=passed" >> $GITHUB_OUTPUT
@@ -153,18 +145,18 @@ jobs:
153145 echo "status=failed" >> $GITHUB_OUTPUT
154146 exit 1
155147 fi
156-
148+
157149 END_TIME=$(date +%s)
158150 echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT
159151
160152 - name : Test 4 - Access the Route
161153 id : test4
162154 run : |
163155 START_TIME=$(date +%s)
164-
156+
165157 # Give it a moment to sync
166158 sleep 3
167-
159+
168160 if curl -s http://127.0.0.1:9080/get | grep -q "httpbin.org"; then
169161 echo "✓ route access works"
170162 echo "status=passed" >> $GITHUB_OUTPUT
@@ -174,15 +166,15 @@ jobs:
174166 echo "status=failed" >> $GITHUB_OUTPUT
175167 exit 1
176168 fi
177-
169+
178170 END_TIME=$(date +%s)
179171 echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT
180172
181173 - name : Test 5 - Check Version Endpoint
182174 id : test5
183175 run : |
184176 START_TIME=$(date +%s)
185-
177+
186178 if curl -s -H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1" \
187179 http://127.0.0.1:9180/apisix/admin/system/info | grep -q "version"; then
188180 echo "✓ system info endpoint works"
@@ -194,7 +186,7 @@ jobs:
194186 echo "status=failed" >> $GITHUB_OUTPUT
195187 exit 1
196188 fi
197-
189+
198190 END_TIME=$(date +%s)
199191 echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT
200192
@@ -205,7 +197,7 @@ jobs:
205197 PASSED=0
206198 FAILED=0
207199 TOTAL_DURATION=0
208-
200+
209201 process_test() {
210202 local status=$1
211203 local duration=$2
@@ -216,30 +208,30 @@ jobs:
216208 fi
217209 TOTAL_DURATION=$((TOTAL_DURATION + duration))
218210 }
219-
211+
220212 process_test "${{ steps.test1.outputs.status }}" "${{ steps.test1.outputs.duration || 0 }}"
221213 process_test "${{ steps.test2.outputs.status }}" "${{ steps.test2.outputs.duration || 0 }}"
222214 process_test "${{ steps.test3.outputs.status }}" "${{ steps.test3.outputs.duration || 0 }}"
223215 process_test "${{ steps.test4.outputs.status }}" "${{ steps.test4.outputs.duration || 0 }}"
224216 process_test "${{ steps.test5.outputs.status }}" "${{ steps.test5.outputs.duration || 0 }}"
225-
217+
226218 echo "passed=$PASSED" >> $GITHUB_OUTPUT
227219 echo "failed=$FAILED" >> $GITHUB_OUTPUT
228220 echo "duration=$TOTAL_DURATION" >> $GITHUB_OUTPUT
229-
221+
230222 if [ "$FAILED" -eq 0 ]; then
231223 echo "overall_status=success" >> $GITHUB_OUTPUT
232224 echo "badge_status=passing" >> $GITHUB_OUTPUT
233225 else
234226 echo "overall_status=failure" >> $GITHUB_OUTPUT
235227 echo "badge_status=failing" >> $GITHUB_OUTPUT
236228 fi
237-
229+
238230 - name : Generate test results JSON
239231 if : always()
240232 run : |
241233 mkdir -p test-results
242-
234+
243235 cat > test-results/apisix.json << EOF
244236 {
245237 "schema_version": "1.0",
@@ -298,29 +290,29 @@ jobs:
298290 }
299291 }
300292 EOF
301-
293+
302294 echo "Generated test results:"
303295 cat test-results/apisix.json
304-
296+
305297 - name : Upload test results
306298 if : always()
307299 uses : actions/upload-artifact@v4
308300 with :
309301 name : apisix-test-results
310302 path : test-results/apisix.json
311303 retention-days : 90
312-
304+
313305 - name : Commit test results to repository
314306 if : always() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/smoke_tests')
315307 run : |
316308 git config --global user.name 'github-actions[bot]'
317309 git config --global user.email 'github-actions[bot]@users.noreply.github.com'
318-
310+
319311 mkdir -p data/test-results
320312 cp test-results/apisix.json data/test-results/apisix.json
321-
313+
322314 git add data/test-results/apisix.json
323-
315+
324316 if ! git diff --staged --quiet; then
325317 git commit -m "Update Apache APISIX test results [skip ci]"
326318 for i in {1..5}; do
@@ -340,7 +332,7 @@ jobs:
340332 else
341333 echo "No changes to commit"
342334 fi
343-
335+
344336 - name : Create test summary
345337 if : always()
346338 run : |
0 commit comments