From 2e095474c31fd6def407cdcacf5e928b21e8c24b Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Wed, 24 Aug 2022 13:22:03 +0200 Subject: [PATCH 1/5] chore(ci): enforce parallel workers to 3 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3977ee8e7a7..a36de6a5487 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ unit-test: poetry run pytest tests/unit e2e-test: - poetry run pytest -rP -n auto --dist loadfile -o log_cli=true tests/e2e + poetry run pytest -n 3 --dist loadfile -o log_cli=true tests/e2e coverage-html: poetry run pytest -m "not perf" --ignore tests/e2e --cov=aws_lambda_powertools --cov-report=html From d2d2abf7e3843aac8a388266a405bb3447fcdd89 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Wed, 24 Aug 2022 13:23:07 +0200 Subject: [PATCH 2/5] chore(ci): lift matrix strategy limit --- .github/workflows/run-e2e-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-e2e-tests.yml b/.github/workflows/run-e2e-tests.yml index 6386e9f05e3..5b1372d54aa 100644 --- a/.github/workflows/run-e2e-tests.yml +++ b/.github/workflows/run-e2e-tests.yml @@ -21,8 +21,8 @@ jobs: strategy: matrix: # Maintenance: disabled until we discover concurrency lock issue with multiple versions and tmp - # version: ["3.7", "3.8", "3.9"] - version: ["3.7"] + version: ["3.7", "3.8", "3.9"] + # version: ["3.7"] steps: - name: "Checkout" uses: actions/checkout@v3 From 060bb6cf1665fa41d2adeda7e9c1be09438256a7 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Wed, 24 Aug 2022 14:13:24 +0200 Subject: [PATCH 3/5] fix(ci): dynamically calculate workers based on infra jobs --- Makefile | 2 +- parallel_run_e2e.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 parallel_run_e2e.py diff --git a/Makefile b/Makefile index a36de6a5487..7a212738c53 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ unit-test: poetry run pytest tests/unit e2e-test: - poetry run pytest -n 3 --dist loadfile -o log_cli=true tests/e2e + python parallel_run_e2e.py coverage-html: poetry run pytest -m "not perf" --ignore tests/e2e --cov=aws_lambda_powertools --cov-report=html diff --git a/parallel_run_e2e.py b/parallel_run_e2e.py new file mode 100755 index 00000000000..b9603701e5e --- /dev/null +++ b/parallel_run_e2e.py @@ -0,0 +1,16 @@ +""" Calculate how many parallel workers are needed to complete E2E infrastructure jobs across available CPU Cores """ +import subprocess +from pathlib import Path + + +def main(): + features = Path("tests/e2e").rglob("infrastructure.py") + workers = len(list(features)) - 1 + + command = f"poetry run pytest -n {workers} --dist loadfile -o log_cli=true tests/e2e" + print(f"Running E2E tests with: {command}") + subprocess.run(command.split(), shell=False) + + +if __name__ == "__main__": + main() From 0669a027ef0bb90dbaa70a5e62fa0392a1e00fc0 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Wed, 24 Aug 2022 14:38:01 +0200 Subject: [PATCH 4/5] chore(ci): add tox to repro future parallel issues --- tox.ini | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tox.ini diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000000..3d514ec0b7b --- /dev/null +++ b/tox.ini @@ -0,0 +1,11 @@ +[tox] +envlist = py37,py38,py39 + +[testenv] +deps = + filelock + pytest-xdist + pydantic + email-validator + +commands = python parallel_run_e2e.py From fc1e87c8ec333bedcf28de23176e66e17df3b5eb Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Wed, 24 Aug 2022 15:29:48 +0200 Subject: [PATCH 5/5] chore: add notes on how to run tox --- tox.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tox.ini b/tox.ini index 3d514ec0b7b..286b1c10ab0 100644 --- a/tox.ini +++ b/tox.ini @@ -9,3 +9,7 @@ deps = email-validator commands = python parallel_run_e2e.py + +; If you ever encounter another parallel lock across interpreters +; pip install tox tox-poetry +; tox -p --parallel-live \ No newline at end of file