test: unblock docker fixtures on macOS hosts

- per_app_allocation: move host port from 8001 to 28001. OrbStack reserves
  8001 on macOS for vcom-tunnel which makes 'Bind: port already allocated'
  the default failure mode.
- dirty_ttin_ttou: pin BASE_URL to 127.0.0.1 instead of 'localhost'. macOS
  resolves 'localhost' to ::1 first; Docker Desktop / OrbStack only forward
  host ports on IPv4 so the IPv6 attempt resets and the test fixture treats
  the service as unhealthy.
- dirty_ttin_ttou: add setproctitle to the test image. The TTIN/TTOU tests
  count workers via 'pgrep -f dirty-worker', which only matches once
  gunicorn's util._setproctitle has actually renamed the processes.
This commit is contained in:
Benoit Chesneau 2026-05-04 09:47:38 +02:00
parent 68843c8893
commit 54d38afddf
5 changed files with 12 additions and 7 deletions

View File

@ -6,9 +6,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
WORKDIR /app
# Install gunicorn from source
# Install gunicorn from source. setproctitle is required so dirty-arbiter
# and dirty-worker processes get distinguishable names that the tests use
# to count workers via pgrep.
COPY . /gunicorn-src/
RUN pip install --no-cache-dir /gunicorn-src/
RUN pip install --no-cache-dir /gunicorn-src/ setproctitle
# Copy test app
COPY tests/docker/dirty_ttin_ttou/app.py /app/

View File

@ -21,7 +21,10 @@ pytestmark = [
# Directory containing this test file
TEST_DIR = Path(__file__).parent
COMPOSE_FILE = TEST_DIR / "docker-compose.yml"
BASE_URL = "http://localhost:18000"
# Use 127.0.0.1 (not "localhost") so we always hit IPv4. Docker Desktop /
# OrbStack on macOS map host ports to IPv4 only, and ``localhost`` resolves
# to ``::1`` on this host, which yields connection-reset noise.
BASE_URL = "http://127.0.0.1:18000"
@pytest.fixture(scope="module")

View File

@ -58,5 +58,5 @@ pytest test_per_app_e2e.py::TestPerAppAllocation::test_config_limited_app_uses_o
## Notes
- Tests run on port 8001 to avoid conflicts with the existing dirty_arbiter tests on 8000
- Tests run on port 28001 to avoid conflicts with the existing dirty_arbiter tests on 8000 and with macOS Docker alternatives that often reserve port 8001 (e.g., OrbStack's vcom-tunnel)
- The container uses a keep-alive wrapper to allow testing worker crash scenarios

View File

@ -4,7 +4,7 @@ services:
context: ../../..
dockerfile: tests/docker/per_app_allocation/Dockerfile
ports:
- "8001:8000"
- "28001:8000"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/status"]
interval: 1s

View File

@ -39,7 +39,7 @@ class DockerContainer:
self.name = name
self.build = build
self.container_id = None
self.base_url = "http://127.0.0.1:8001"
self.base_url = "http://127.0.0.1:28001"
def __enter__(self):
# Build if requested
@ -64,7 +64,7 @@ class DockerContainer:
[
"docker", "run", "-d",
"--name", self.name,
"-p", "8001:8000",
"-p", "28001:8000",
"per_app_allocation-gunicorn",
"sh", "-c",
"gunicorn app:application -c gunicorn_conf.py & "