Skip to content

Commit

Permalink
moto: Upgrade, change default port to 50000, allow services other tha…
Browse files Browse the repository at this point in the history
…n S3
  • Loading branch information
dmannarino committed Jan 28, 2024
1 parent 396f065 commit 0f4aafa
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ High-performance Async REST API, in Python. FastAPI + GINO + Uvicorn (powered by
* 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=<port_number>` - explicitly sets the motoserver port (default `5000`)
* `--moto-port=<port_number>` - explicitly sets the motoserver port (default `50000`)
* Run specific tests: `./scripts/test tasks/test_vector_source_assets.py::test_vector_source_asset`
* Each development branch app instance gets its isolated database in AWS dev account that's cloned from `geostore` database. This database is named with the branch suffix (like `geostore_<branch_name>`). If a PR includes a database migration, once the change is merged to higher environments, the `geostore` database needs to also be updated with the migration. This can be done by manually replacing the existing database by a copy of a cleaned up version of the branch database (see `./prestart.sh` script for cloning command).
* Debug memory usage of Batch jobs with memory_profiler:
Expand Down
33 changes: 17 additions & 16 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ services:
- DB_HOST=test_database_12
- DATABASE=_test
- DB_USER=gfw
- DB_PASSWORD=postgres # pragma: allowlist secret
- DB_PASSWORD=postgres # pragma: allowlist secret
- DB_PORT=5432
- DB_HOST_RO=test_database_12
- DATABASE_RO=_test
- DB_USER_RO=gfw_readonly
- DB_PASSWORD_RO=readonly # pragma: allowlist secret
- DB_PASSWORD_RO=readonly # pragma: allowlist secret
- DB_PORT_RO=5432
- LOG_LEVEL=debug
- AWS_ACCESS_KEY_ID=testing # pragma: allowlist secret
- AWS_SECRET_ACCESS_KEY=testing # pragma: allowlist secret
- AWS_SECURITY_TOKEN=testing # pragma: allowlist secret
- AWS_SESSION_TOKEN=testing # pragma: allowlist secret
- AWS_ACCESS_KEY_ID=testing # pragma: allowlist secret
- AWS_SECRET_ACCESS_KEY=testing # pragma: allowlist secret
- AWS_SECURITY_TOKEN=testing # pragma: allowlist secret
- AWS_SESSION_TOKEN=testing # pragma: allowlist secret
- POLL_WAIT_TIME=1
- ROOT=$PWD
- POSTGRESQL_CLIENT_JOB_DEFINITION=postgres_client_jd
Expand All @@ -54,21 +54,20 @@ services:
- PIXETL_MAX_MEM=3800
- MAX_MEM=3800
- API_URL=http://app_test:9000
- S3_ENTRYPOINT_URL=http://motoserver-s3:5000
- S3_ENTRYPOINT_URL=http://motoserver:50000
- SERVICE_ACCOUNT_TOKEN=testing
- RASTER_ANALYSIS_LAMBDA_NAME=test_raster_analysis
- RW_API_URL=https://staging-api.resourcewatch.org
- API_GATEWAY_ID=test
- API_GATEWAY_INTERNAL_USAGE_PLAN=test
- API_GATEWAY_EXTERNAL_USAGE_PLAN=test
- API_GATEWAY_STAGE_NAME=test
# - AWS_GCS_KEY_SECRET_ARN=testing
# - AWS_SECRETSMANAGER_URL=http://motoserver-secretsmanager:5001
- AWS_GCS_KEY_SECRET_ARN=testing
- AWS_SECRETSMANAGER_URL=http://motoserver:50000
entrypoint: wait_for_postgres.sh pytest --timeout 480 -vv --cov-report term --cov=app
depends_on:
- test_database_12
- motoserver-s3
# - motoserver-secretsmanager
- motoserver

test_database_12:
container_name: gfw-data-api-test-database-12
Expand All @@ -85,12 +84,14 @@ services:
command: ["postgres", "-c", "log_statement=all"]
restart: on-failure

motoserver-s3:
container_name: motoserver-s3
image: motoserver/moto:4.0.11
motoserver:
container_name: motoserver
image: motoserver/moto
ports:
- "${MOTO_PORT-5000}:5000"
entrypoint: moto_server s3 -H 0.0.0.0
- "${MOTO_PORT-50000}:50000"
environment:
- MOTO_PORT=50000
entrypoint: moto_server -H 0.0.0.0
restart: on-failure

volumes:
Expand Down
6 changes: 3 additions & 3 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,17 @@ def add_job_definition(self, job_definition_name, docker_image, mount_tmp=False)
"environment": [
{"name": "AWS_ACCESS_KEY_ID", "value": "testing"},
{"name": "AWS_SECRET_ACCESS_KEY", "value": "testing"},
{"name": "ENDPOINT_URL", "value": "http://motoserver-s3:5000"},
{"name": "ENDPOINT_URL", "value": "http://motoserver:50000"},
{"name": "DEBUG", "value": "1"},
{"name": "TILE_CACHE", "value": TILE_CACHE_BUCKET},
{"name": "DATA_LAKE", "value": DATA_LAKE_BUCKET},
{"name": "AWS_HTTPS", "value": "NO"},
{"name": "AWS_S3_ENDPOINT", "value": "motoserver-s3:5000"},
{"name": "AWS_S3_ENDPOINT", "value": "motoserver:50000"},
{"name": "AWS_VIRTUAL_HOSTING", "value": "FALSE"},
{"name": "GDAL_DISABLE_READDIR_ON_OPEN", "value": "YES"},
{
"name": "AWS_SECRETSMANAGER_URL",
"value": "http://motoserver-secretsmanager:5001",
"value": "http://motoserver:50000",
},
],
"volumes": [
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/aws/config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[default]
s3 =
endpoint_url = http://motoserver-s3:5000
endpoint_url = http://motoserver:50000

[plugins]
endpoint = awscli_plugin_endpoint

0 comments on commit 0f4aafa

Please sign in to comment.