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)
|
- name: Start container (background)
|
||||||
run: |
|
run: |
|
||||||
# do NOT bind the container port to the host to avoid port conflicts on the runner
|
# 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)
|
- name: Start server in container and smoke test HTTP (in-container)
|
||||||
run: |
|
run: |
|
||||||
# start the server inside the container
|
set -x
|
||||||
docker exec -d semapform-test python api_service.py
|
# 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'
|
docker exec semapform-test python - << 'PY'
|
||||||
import time, urllib.request, sys
|
import time, urllib.request, sys
|
||||||
url = 'http://127.0.0.1:8001/api/validate-signature?signature=ST%20250%20U42%20%2815%29'
|
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:
|
try:
|
||||||
req = urllib.request.Request(url, method='POST')
|
with urllib.request.urlopen(url, timeout=3) as r:
|
||||||
r = urllib.request.urlopen(req, timeout=3)
|
print('attempt', i, 'status', r.status)
|
||||||
print('status', r.status)
|
print(r.read().decode())
|
||||||
print(r.read().decode())
|
if 200 <= r.status < 300:
|
||||||
if 200 <= r.status < 300:
|
sys.exit(0)
|
||||||
sys.exit(0)
|
except Exception as e:
|
||||||
except Exception:
|
print('attempt', i, 'failed:', e)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print('failed')
|
print('failed')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
PY
|
PY
|
||||||
|
|
||||||
|
# dump the last 200 lines of logs so this step has visible output
|
||||||
|
docker logs semapform-test --tail 200 || true
|
||||||
|
|
||||||
- name: Cleanup container
|
- name: Cleanup container
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user