From e0aa82a53b87a2459cbc02e10dd54bcee5e47440 Mon Sep 17 00:00:00 2001 From: gtempus Date: Tue, 28 Jun 2022 11:57:11 -0400 Subject: [PATCH] chore(test environment): Allow user to explicitly set motoserver s3 port. This is to help developers with port binding issues on macOS. Motoserver is set to use port 5000 by default. Monterey uses 5000 for Control Center purposes. As a result, running the test script will cause a `bind: address alread in use` error. GTC-1893 --- README.md | 2 ++ docker-compose.test.yml | 2 +- scripts/test | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ae3badff6..e405a03ca 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ High-performance Async REST API, in Python. FastAPI + GINO + Uvicorn (powered by ### Developing * Generate a DB Migration: `./scripts/migrate` (note `app/settings/prestart.sh` will run migrations automatically when running `/scripts/develop`) * Run tests: `./scripts/test` + * `--no_build` - don't rebuild the containers + * `--moto-port=` - explicitly sets the motoserver port (default `5000`) * Run specific tests: `./scripts/test tasks/test_vector_source_assets.py::test_vector_source_asset` * Debug memory usage of Batch jobs with memory_profiler: 1. Install memory_profiler in the job's Dockerfile diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 806c76834..e2c77555a 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -87,7 +87,7 @@ services: container_name: motoserver-s3 image: motoserver/moto:2.0.10 ports: - - 5000:5000 + - "${MOTO_PORT-5000}:5000" entrypoint: moto_server s3 -H 0.0.0.0 restart: on-failure diff --git a/scripts/test b/scripts/test index 2a760ecd3..1ef108f37 100755 --- a/scripts/test +++ b/scripts/test @@ -24,6 +24,12 @@ do SLOW=--with-slow-tests shift # past argument ;; + --moto-port=*) + # prevent port binding issues by explicitly setting the motoserver s3 port + # https://developer.apple.com/forums/thread/682332 + export MOTO_PORT="${key#*=}" + shift # past argument=value + ;; *) # unknown option POSITIONAL+=("$1") # save it in an array for later shift # past argument