Techdebt: Parallelize more tests (#5464)

This commit is contained in:
Bert Blommers 2022-09-15 12:27:07 +00:00 committed by GitHub
parent d3a5d7ab11
commit bb540f6342
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 6 deletions

View File

@ -121,6 +121,7 @@ jobs:
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]

View File

@ -6,12 +6,12 @@ TEST_NAMES = "*"
ifeq ($(TEST_SERVER_MODE), true)
# exclude test_kinesisvideoarchivedmedia
# because testing with moto_server is difficult with data-endpoint
TEST_EXCLUDE := -k 'not (test_kinesisvideoarchivedmedia or test_awslambda or test_batch or test_ec2 or test_sqs)'
TEST_EXCLUDE := --ignore tests/test_kinesisvideoarchivedmedia --ignore tests/test_awslambda --ignore tests/test_batch --ignore tests/test_ec2 --ignore tests/test_sqs
# Parallel tests will be run separate
PARALLEL_TESTS := ./tests/test_awslambda ./tests/test_batch ./tests/test_ec2 ./tests/test_sqs
else
TEST_EXCLUDE :=
PARALLEL_TESTS := ./tests/test_core
TEST_EXCLUDE := --ignore tests/test_batch --ignore tests/test_ec2 --ignore tests/test_sqs
PARALLEL_TESTS := ./tests/test_batch ./tests/test_ec2 ./tests/test_sqs
endif
init:
@ -35,7 +35,7 @@ test-only:
rm -f .coverage
rm -rf cover
pytest -sv --cov=moto --cov-report xml ./tests/ $(TEST_EXCLUDE)
MOTO_CALL_RESET_API=false pytest -n 4 $(PARALLEL_TESTS)
MOTO_CALL_RESET_API=false pytest --cov=moto --cov-report xml --cov-append -n 4 $(PARALLEL_TESTS)
test: lint test-only

View File

@ -40,7 +40,7 @@ To verify whether your tests pass in ServerMode, you can run the following comma
Parallel tests
^^^^^^^^^^^^^^^^^^^^^
To speed up our CI, the ServerMode tests for the `awslambda`, `batch`, `ec2` and `sqs` services will run in parallel.
To speed up our CI, the tests for the `awslambda`, `batch`, `ec2` and `sqs` services will run in parallel.
This means the following:
- Make sure you use unique names for functions/queues/etc

View File

@ -1,9 +1,10 @@
from ..test_batch import _get_clients, _setup
import sure # noqa # pylint: disable=unused-import
from moto import mock_iam, mock_ec2, mock_ecs, mock_logs
from moto import mock_iam, mock_ec2, mock_ecs, mock_logs, settings
from moto import mock_batch_simple
from uuid import uuid4
from unittest import SkipTest
# Copy of test_batch/test_batch_jobs
@ -16,6 +17,9 @@ from uuid import uuid4
@mock_iam
@mock_batch_simple
def test_submit_job_by_name():
if settings.TEST_SERVER_MODE:
raise SkipTest("No point in testing batch_simple in ServerMode")
ec2_client, iam_client, _, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)