test new validation test
All checks were successful
PR tests / build-and-smoke (pull_request) Successful in 54s
All checks were successful
PR tests / build-and-smoke (pull_request) Successful in 54s
This commit is contained in:
@@ -35,31 +35,38 @@ jobs:
|
||||
- name: Start container (background)
|
||||
run: |
|
||||
# do NOT bind the container port to the host to avoid port conflicts on the runner
|
||||
docker run -d --name semapform-test semapform-api:test-pr --port 8001:8001 sleep infinity
|
||||
docker run -d --name semapform-test semapform-api:test-pr sleep infinity
|
||||
|
||||
- name: Start server in container and smoke test HTTP (in-container)
|
||||
run: |
|
||||
# start the server inside the container
|
||||
docker exec -d semapform-test python api_service.py
|
||||
set -x
|
||||
# start the server inside the container (detached)
|
||||
docker exec -d semapform-test python api_service.py || true
|
||||
|
||||
# send a POST request to /api/validate-signature with signature="ST 250 U42 (15)"
|
||||
# show container status to aid debugging
|
||||
docker ps -a --filter name=semapform-test || true
|
||||
|
||||
# perform an in-container GET request (endpoint is a GET) and print attempts/logs
|
||||
docker exec semapform-test python - << 'PY'
|
||||
import time, urllib.request, sys
|
||||
url = 'http://127.0.0.1:8001/api/validate-signature?signature=ST%20250%20U42%20%2815%29'
|
||||
for _ in range(20):
|
||||
for i in range(20):
|
||||
try:
|
||||
req = urllib.request.Request(url, method='POST')
|
||||
r = urllib.request.urlopen(req, timeout=3)
|
||||
print('status', r.status)
|
||||
print(r.read().decode())
|
||||
if 200 <= r.status < 300:
|
||||
sys.exit(0)
|
||||
except Exception:
|
||||
with urllib.request.urlopen(url, timeout=3) as r:
|
||||
print('attempt', i, 'status', r.status)
|
||||
print(r.read().decode())
|
||||
if 200 <= r.status < 300:
|
||||
sys.exit(0)
|
||||
except Exception as e:
|
||||
print('attempt', i, 'failed:', e)
|
||||
time.sleep(1)
|
||||
print('failed')
|
||||
sys.exit(1)
|
||||
PY
|
||||
|
||||
# dump the last 200 lines of logs so this step has visible output
|
||||
docker logs semapform-test --tail 200 || true
|
||||
|
||||
- name: Cleanup container
|
||||
if: always()
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user