Skip to content

Commit db89297

Browse files
committed
chore: document
1 parent fddbf05 commit db89297

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Diff for: parallel_run_e2e.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def main():
88
features = Path("tests/e2e").rglob("infrastructure.py")
99
workers = len(list(features)) - 1
1010

11-
command = f"poetry run pytest -n {workers} --dist loadgroup -o log_cli=true tests/e2e"
11+
command = f"poetry run pytest -n {workers} -o log_cli=true tests/e2e"
1212
result = subprocess.run(command.split(), shell=False)
1313
sys.exit(result.returncode)
1414

Diff for: tests/e2e/conftest.py

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
from xdist.scheduler import LoadGroupScheduling
23

34
from tests.e2e.utils.infrastructure import call_once
45
from tests.e2e.utils.lambda_layer.powertools_layer import LocalLambdaPowertoolsLayer
@@ -27,3 +28,11 @@ def lambda_layer_build(tmp_path_factory: pytest.TempPathFactory, worker_id: str)
2728
tmp_path_factory=tmp_path_factory,
2829
worker_id=worker_id,
2930
)
31+
32+
33+
# Hook to use the xdist_group to decide how to schedule tests among the different workers.
34+
# Each test needs to be marked with @pytest.mark.xdist_group(name=...). This way, all
35+
# the tests on each directory will be scheduled on the same worker, thus sharing the
36+
# infrastructure.
37+
def pytest_xdist_make_scheduler(config, log):
38+
return LoadGroupScheduling(config, log)

Diff for: tests/e2e/utils/functions.py

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ def f(fname: str, farn: str, fargs: str):
1313
with ThreadPoolExecutor() as executor:
1414
running_tasks: List[Future] = []
1515
for arn in lambdas_arn:
16+
# Sleep 0.5, 1, 1.5, ... seconds between each invocation. This way
17+
# we can guarantee that lambdas are executed in parallel, but they are
18+
# called in the same "order" as they are passed in.
1619
time.sleep(0.5 * len(running_tasks))
1720
running_tasks.append(executor.submit(f, function_name, arn, arguments))
1821

0 commit comments

Comments
 (0)