fix(fastapi): increase recursion limit during tests

The default recursion limit used by Docker's archlinux:base-devel
Python package becomes problematic in some cases when running tests
against our FastAPI application using starlette.testclient.TestClient
(aliased to fastapi.testclient.TestClient). starlette ends up with
test failures because it exceeds the recursion limit, but this only
happens when using the `TestClient`. When the ASGI servers are run,
this is not an issue and so in that case, the recursion limit has
not been touched.

This change uses a `TEST_RECURSION_LIMIT` environment variable to
modify the recursion limit of the FastAPI application. This variable
is, by default, only supplied when running pytests in Docker, but
can be force-supplied by the user.

TEST_RECURSION_LIMIT=10000 has been added to `.env` and `.gitlab-ci.yml`.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-10-23 20:06:00 -07:00
parent 5fb75b9614
commit 94d494866f
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
4 changed files with 20 additions and 0 deletions

View file

@ -216,6 +216,7 @@ services:
init: true
environment:
- AUR_CONFIG=conf/config
- TEST_RECURSION_LIMIT=${TEST_RECURSION_LIMIT}
entrypoint: /docker/test-mysql-entrypoint.sh
command: /docker/scripts/run-pytests.sh clean
stdin_open: true
@ -241,6 +242,7 @@ services:
init: true
environment:
- AUR_CONFIG=conf/config.sqlite
- TEST_RECURSION_LIMIT=${TEST_RECURSION_LIMIT}
entrypoint: /docker/test-sqlite-entrypoint.sh
command: setup-sqlite.sh run-pytests.sh clean
stdin_open: true
@ -262,6 +264,7 @@ services:
init: true
environment:
- AUR_CONFIG=conf/config
- TEST_RECURSION_LIMIT=${TEST_RECURSION_LIMIT}
entrypoint: /docker/tests-entrypoint.sh
command: setup-sqlite.sh run-tests.sh
stdin_open: true