fix: write actual mock port to file for smoke test
This commit is contained in:
parent
dfedd80d0d
commit
abe3e28a49
2 changed files with 11 additions and 7 deletions
|
|
@ -32,7 +32,10 @@ steps:
|
||||||
image: python:3-alpine
|
image: python:3-alpine
|
||||||
commands:
|
commands:
|
||||||
- apk add --no-cache bash curl jq git coreutils
|
- apk add --no-cache bash curl jq git coreutils
|
||||||
- MOCK_FORGE_PORT=3001 python3 tests/mock-forgejo.py > /tmp/mock.log 2>&1 &
|
- MOCK_FORGE_PORT=3001 MOCK_FORGE_PORT_FILE=/tmp/mock-port python3 tests/mock-forgejo.py > /tmp/mock.log 2>&1 &
|
||||||
# Wait for mock to be ready (might be on a different port if 3001 is in use)
|
- MOCK_PID=$!
|
||||||
- for i in $(seq 1 30); do curl -sf http://localhost:$MOCK_FORGE_PORT/api/v1/version >/dev/null 2>&1 && break || sleep 1; done
|
# Wait for mock to be ready
|
||||||
- SMOKE_FORGE_URL=http://localhost:$MOCK_FORGE_PORT FORGE_URL=http://localhost:$MOCK_FORGE_PORT bash tests/smoke-init.sh
|
- for i in $(seq 1 30); do [ -f /tmp/mock-port ] && break || sleep 1; done
|
||||||
|
- MOCK_PORT=$(cat /tmp/mock-port 2>/dev/null || echo "3001")
|
||||||
|
- for i in $(seq 1 30); do curl -sf http://localhost:$MOCK_PORT/api/v1/version >/dev/null 2>&1 && break || sleep 1; done
|
||||||
|
- SMOKE_FORGE_URL=http://localhost:$MOCK_PORT FORGE_URL=http://localhost:$MOCK_PORT bash tests/smoke-init.sh
|
||||||
|
|
|
||||||
|
|
@ -719,9 +719,10 @@ def main():
|
||||||
base_port = int(os.environ.get("MOCK_FORGE_PORT", 3000))
|
base_port = int(os.environ.get("MOCK_FORGE_PORT", 3000))
|
||||||
port = find_free_port(base_port)
|
port = find_free_port(base_port)
|
||||||
|
|
||||||
# If we found a different port, update the environment variable
|
# Write actual port to a file for the test script to read
|
||||||
if port != base_port:
|
port_file = os.environ.get("MOCK_FORGE_PORT_FILE", "/tmp/mock-forgejo-port")
|
||||||
os.environ["MOCK_FORGE_PORT"] = str(port)
|
with open(port_file, "w") as f:
|
||||||
|
f.write(str(port))
|
||||||
|
|
||||||
server = ThreadingHTTPServer(("0.0.0.0", port), ForgejoHandler)
|
server = ThreadingHTTPServer(("0.0.0.0", port), ForgejoHandler)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue