Skip to content

Commit

Permalink
Rename --test-types to --parallel-test-types parameters (apache#30424)
Browse files Browse the repository at this point in the history
The --test-type and --test-types parameters were very similar, but
they have enough difference to differentiate them even more:

The --test-type is specifically to run single test and it might
include not only the regular "test-types" but also allow for
cross-selection of tests from different other types (for example
--test-type Postgres will run tests for Postgres database and
they might come from Providers, Others, CLI etc.

Where --test-types was generally foreseen to be able to split
the tests into "sepearated" groups that could be run in
parallel.

The parameters have different defaults and even different choice
of test type that you could choose from (and --test-types is a
space-separated one to make it easier to pass it around in CI,
where rather than passing multiple (variable number) of parameters,
it's easier to pass a single, even space-separated list of tests
to run.

This change is good to show the difference between then parameters
and to stress that they are really quite different, also it makes
it easier to avoid confusion people might have especially that the
name was easy to have typo in.

In a way (but different than in the original issue it
Fixes: apache#30407
  • Loading branch information
potiuk authored Apr 4, 2023
1 parent 90ba6fe commit 2060643
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 49 deletions.
65 changes: 34 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
default-helm-version: ${{ steps.selective-checks.outputs.default-helm-version }}
default-kind-version: ${{ steps.selective-checks.outputs.default-kind-version }}
full-tests-needed: ${{ steps.selective-checks.outputs.full-tests-needed }}
test-types: ${{ steps.selective-checks.outputs.test-types }}
parallel-test-types: ${{ steps.selective-checks.output.parallel-test-types }}
postgres-exclude: ${{ steps.selective-checks.outputs.postgres-exclude }}
mysql-exclude: ${{ steps.selective-checks.outputs.mysql-exclude }}
mssql-exclude: ${{ steps.selective-checks.outputs.mssql-exclude }}
Expand Down Expand Up @@ -808,7 +808,7 @@ jobs:
needs: [build-info, wait-for-ci-images]
env:
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
TEST_TYPES: "Helm"
PARALLEL_TEST_TYPES: "Helm"
BACKEND: ""
DB_RESET: "false"
PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}"
Expand Down Expand Up @@ -872,7 +872,7 @@ jobs:
timeout-minutes: 130
name: >
Postgres${{matrix.postgres-version}},Py${{matrix.python-version}}:
${{needs.build-info.outputs.test-types}}
${{needs.build-info.output.parallel-test-types}}
runs-on: "${{needs.build-info.outputs.runs-on}}"
needs: [build-info, test-pytest-collection]
strategy:
Expand All @@ -883,7 +883,7 @@ jobs:
fail-fast: false
env:
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
TEST_TYPES: "${{needs.build-info.outputs.test-types}}"
PARALLEL_TEST_TYPES: "${{needs.build-info.output.parallel-test-types}}"
PR_LABELS: "${{needs.build-info.outputs.pull-request-labels}}"
FULL_TESTS_NEEDED: "${{needs.build-info.outputs.full-tests-needed}}"
DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}"
Expand All @@ -904,26 +904,26 @@ jobs:
persist-credentials: false
- name: "Prepare breeze & CI image: ${{matrix.python-version}}:${{env.IMAGE_TAG}}"
uses: ./.github/actions/prepare_breeze_and_image
- name: "Migration Tests: ${{matrix.python-version}}:${{needs.build-info.outputs.test-types}}"
- name: "Migration Tests: ${{matrix.python-version}}:${{needs.build-info.output.parallel-test-types}}"
uses: ./.github/actions/migration_tests
- name: "Tests: ${{matrix.python-version}}:${{needs.build-info.outputs.test-types}}"
- name: "Tests: ${{matrix.python-version}}:${{needs.build-info.output.parallel-test-types}}"
run: breeze testing tests --run-in-parallel
- name: "Tests ARM Pytest collection: ${{matrix.python-version}}"
run: breeze testing tests --run-in-parallel --collect-only --remove-arm-packages
- name: "Post Tests: ${{matrix.python-version}}:${{needs.build-info.outputs.test-types}}"
- name: "Post Tests: ${{matrix.python-version}}:${{needs.build-info.output.parallel-test-types}}"
uses: ./.github/actions/post_tests

tests-postgres-boto:
timeout-minutes: 130
name: >
LatestBotoPostgres${{needs.build-info.outputs.default-postgres-version}},
Py${{needs.build-info.outputs.default-python-version}}:
${{needs.build-info.outputs.test-types}}
${{needs.build-info.output.parallel-test-types}}
runs-on: "${{needs.build-info.outputs.runs-on}}"
needs: [build-info, test-pytest-collection]
env:
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
TEST_TYPES: "${{needs.build-info.outputs.test-types}}"
PARALLEL_TEST_TYPES: "${{needs.build-info.output.parallel-test-types}}"
PR_LABELS: "${{needs.build-info.outputs.pull-request-labels}}"
FULL_TESTS_NEEDED: "${{needs.build-info.outputs.full-tests-needed}}"
DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}"
Expand All @@ -950,17 +950,19 @@ jobs:
Prepare breeze & CI image: ${{needs.build-info.outputs.default-python-version}}:${{env.IMAGE_TAG}}
uses: ./.github/actions/prepare_breeze_and_image
- name: >
Tests: ${{needs.build-info.outputs.default-python-version}}:${{needs.build-info.outputs.test-types}}
Tests: ${{needs.build-info.outputs.default-python-version}}:
${{needs.build-info.output.parallel-test-types}}
run: breeze testing tests --run-in-parallel
- name: >
Post Tests: ${{needs.build-info.outputs.default-python-version}}:
${{needs.build-info.outputs.test-types}}
${{needs.build-info.output.parallel-test-types}}
uses: ./.github/actions/post_tests
tests-mysql:
timeout-minutes: 130
name: >
MySQL${{matrix.mysql-version}}, Py${{matrix.python-version}}: ${{needs.build-info.outputs.test-types}}
MySQL${{matrix.mysql-version}}, Py${{matrix.python-version}}:
${{needs.build-info.output.parallel-test-types}}
runs-on: "${{needs.build-info.outputs.runs-on}}"
needs: [build-info, test-pytest-collection]
strategy:
Expand All @@ -973,7 +975,7 @@ jobs:
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
PR_LABELS: "${{needs.build-info.outputs.pull-request-labels}}"
FULL_TESTS_NEEDED: "${{needs.build-info.outputs.full-tests-needed}}"
TEST_TYPES: "${{needs.build-info.outputs.test-types}}"
PARALLEL_TEST_TYPES: "${{needs.build-info.output.parallel-test-types}}"
DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}"
BACKEND: "mysql"
PYTHON_MAJOR_MINOR_VERSION: "${{matrix.python-version}}"
Expand All @@ -991,20 +993,21 @@ jobs:
persist-credentials: false
- name: "Prepare breeze & CI image: ${{matrix.python-version}}:${{env.IMAGE_TAG}}"
uses: ./.github/actions/prepare_breeze_and_image
- name: "Migration Tests: ${{matrix.python-version}}:${{needs.build-info.outputs.test-types}}"
- name: "Migration Tests: ${{matrix.python-version}}:${{needs.build-info.output.parallel-test-types}}"
uses: ./.github/actions/migration_tests
- name: "Tests: ${{matrix.python-version}}:${{needs.build-info.outputs.test-types}}"
- name: "Tests: ${{matrix.python-version}}:${{needs.build-info.output.parallel-test-types}}"
run: breeze testing tests --run-in-parallel
- name: "Tests ARM Pytest collection: ${{matrix.python-version}}"
if: env.MYSQL_VERSION != '5.7'
run: breeze testing tests --run-in-parallel --collect-only --remove-arm-packages
- name: "Post Tests: ${{matrix.python-version}}:${{needs.build-info.outputs.test-types}}"
- name: "Post Tests: ${{matrix.python-version}}:${{needs.build-info.output.parallel-test-types}}"
uses: ./.github/actions/post_tests

tests-mssql:
timeout-minutes: 130
name: >
MSSQL${{matrix.mssql-version}}, Py${{matrix.python-version}}: ${{needs.build-info.outputs.test-types}}
MSSQL${{matrix.mssql-version}}, Py${{matrix.python-version}}:
${{needs.build-info.output.parallel-test-types}}
runs-on: "${{needs.build-info.outputs.runs-on}}"
needs: [build-info, test-pytest-collection]
strategy:
Expand All @@ -1015,7 +1018,7 @@ jobs:
fail-fast: false
env:
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
TEST_TYPES: "${{needs.build-info.outputs.test-types}}"
PARALLEL_TEST_TYPES: "${{needs.build-info.output.parallel-test-types}}"
PR_LABELS: "${{needs.build-info.outputs.pull-request-labels}}"
FULL_TESTS_NEEDED: "${{needs.build-info.outputs.full-tests-needed}}"
DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}"
Expand All @@ -1036,17 +1039,17 @@ jobs:
persist-credentials: false
- name: "Prepare breeze & CI image: ${{matrix.python-version}}:${{env.IMAGE_TAG}}"
uses: ./.github/actions/prepare_breeze_and_image
- name: "Migration Tests: ${{matrix.python-version}}:${{needs.build-info.outputs.test-types}}"
- name: "Migration Tests: ${{matrix.python-version}}:${{needs.build-info.output.parallel-test-types}}"
uses: ./.github/actions/migration_tests
- name: "Tests: ${{matrix.python-version}}:${{needs.build-info.outputs.test-types}}"
- name: "Tests: ${{matrix.python-version}}:${{needs.build-info.output.parallel-test-types}}"
run: breeze testing tests --run-in-parallel
- name: "Post Tests: ${{matrix.python-version}}:${{needs.build-info.outputs.test-types}}"
- name: "Post Tests: ${{matrix.python-version}}:${{needs.build-info.output.parallel-test-types}}"
uses: ./.github/actions/post_tests

tests-sqlite:
timeout-minutes: 130
name: >
Sqlite Py${{matrix.python-version}}: ${{needs.build-info.outputs.test-types}}
Sqlite Py${{matrix.python-version}}: ${{needs.build-info.output.parallel-test-types}}
runs-on: "${{needs.build-info.outputs.runs-on}}"
needs: [build-info, test-pytest-collection]
strategy:
Expand All @@ -1057,7 +1060,7 @@ jobs:
if: needs.build-info.outputs.run-tests == 'true'
env:
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
TEST_TYPES: "${{needs.build-info.outputs.test-types}}"
PARALLEL_TEST_TYPES: "${{needs.build-info.output.parallel-test-types}}"
PR_LABELS: "${{needs.build-info.outputs.pull-request-labels}}"
PYTHON_MAJOR_MINOR_VERSION: "${{matrix.python-version}}"
FULL_TESTS_NEEDED: "${{needs.build-info.outputs.full-tests-needed}}"
Expand All @@ -1076,13 +1079,13 @@ jobs:
persist-credentials: false
- name: "Prepare breeze & CI image: ${{matrix.python-version}}:${{env.IMAGE_TAG}}"
uses: ./.github/actions/prepare_breeze_and_image
- name: "Migration Tests: ${{matrix.python-version}}:${{needs.build-info.outputs.test-types}}"
- name: "Migration Tests: ${{matrix.python-version}}:${{needs.build-info.output.parallel-test-types}}"
uses: ./.github/actions/migration_tests
- name: "Tests: ${{matrix.python-version}}:${{needs.build-info.outputs.test-types}}"
- name: "Tests: ${{matrix.python-version}}:${{needs.build-info.output.parallel-test-types}}"
run: breeze testing tests --run-in-parallel
- name: "Tests ARM Pytest collection: ${{matrix.python-version}}"
run: breeze testing tests --run-in-parallel --collect-only --remove-arm-packages
- name: "Post Tests: ${{matrix.python-version}}:${{needs.build-info.outputs.test-types}}"
- name: "Post Tests: ${{matrix.python-version}}:${{needs.build-info.output.parallel-test-types}}"
uses: ./.github/actions/post_tests

tests-integration-postgres:
Expand All @@ -1092,7 +1095,7 @@ jobs:
needs: [build-info, test-pytest-collection]
env:
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
TEST_TYPES: "${{needs.build-info.outputs.test-types}}"
PARALLEL_TEST_TYPES: "${{needs.build-info.output.parallel-test-types}}"
PR_LABELS: "${{needs.build-info.outputs.pull-request-labels}}"
FULL_TESTS_NEEDED: "${{needs.build-info.outputs.full-tests-needed}}"
DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}"
Expand Down Expand Up @@ -1142,7 +1145,7 @@ jobs:
- name: "Integration Tests Postgres: all-testable"
run: breeze testing integration-tests --integration all-testable
if: needs.build-info.outputs.runs-on == 'self-hosted'
- name: "Post Tests: ${{matrix.python-version}}:${{needs.build-info.outputs.test-types}}"
- name: "Post Tests: ${{matrix.python-version}}:${{needs.build-info.output.parallel-test-types}}"
uses: ./.github/actions/post_tests

tests-integration-mysql:
Expand All @@ -1152,7 +1155,7 @@ jobs:
needs: [build-info, test-pytest-collection]
env:
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
TEST_TYPES: "${{needs.build-info.outputs.test-types}}"
PARALLEL_TEST_TYPES: "${{needs.build-info.output.parallel-test-types}}"
PR_LABELS: "${{needs.build-info.outputs.pull-request-labels}}"
FULL_TESTS_NEEDED: "${{needs.build-info.outputs.full-tests-needed}}"
DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}"
Expand Down Expand Up @@ -1180,7 +1183,7 @@ jobs:
- name: "Integration Tests MySQL: all-testable"
run: breeze testing integration-tests --integration all-testable
if: needs.build-info.outputs.runs-on == 'self-hosted'
- name: "Post Tests: ${{matrix.python-version}}:${{needs.build-info.outputs.test-types}}"
- name: "Post Tests: ${{matrix.python-version}}:${{needs.build-info.output.parallel-test-types}}"
uses: ./.github/actions/post_tests
if: needs.build-info.outputs.runs-on == 'self-hosted'

Expand All @@ -1193,7 +1196,7 @@ jobs:
needs: [build-info, test-pytest-collection]
env:
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
TEST_TYPES: "Quarantined"
PARALLEL_TEST_TYPES: "Quarantined"
PR_LABELS: "${{needs.build-info.outputs.pull-request-labels}}"
PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}"
DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}"
Expand Down
4 changes: 2 additions & 2 deletions BREEZE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -788,13 +788,13 @@ For example this will only run provider tests for airbyte and http providers:
You can also run parallel tests with ``--run-in-parallel`` flag - by default it will run all tests types
in parallel, but you can specify the test type that you want to run with space separated list of test
types passed to ``--test-types`` flag.
types passed to ``--parallel-test-types`` flag.

For example this will run API and WWW tests in parallel:

.. code-block:: bash
breeze testing tests --test-types "API WWW" --run-in-parallel
breeze testing tests --parallel-test-types "API WWW" --run-in-parallel
There are few special types of tests that you can run:

Expand Down
20 changes: 10 additions & 10 deletions dev/breeze/src/airflow_breeze/commands/testing_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def _run_tests_in_pool(

def run_tests_in_parallel(
exec_shell_params: ShellParams,
test_types_list: list[str],
parallel_test_types_list: list[str],
extra_pytest_args: tuple,
db_reset: bool,
full_tests_needed: bool,
Expand All @@ -276,7 +276,7 @@ def run_tests_in_parallel(
memory_available = psutil.virtual_memory()
if memory_available.available < LOW_MEMORY_CONDITION and exec_shell_params.backend in ["mssql", "mysql"]:
# Run heavy tests sequentially
heavy_test_types_to_run = {"Core", "Providers"} & set(test_types_list)
heavy_test_types_to_run = {"Core", "Providers"} & set(parallel_test_types_list)
if heavy_test_types_to_run:
# some of those are requested
get_console().print(
Expand All @@ -286,9 +286,9 @@ def run_tests_in_parallel(
)
tests_to_run_sequentially = []
for heavy_test_type in heavy_test_types_to_run:
for test_type in test_types_list:
for test_type in parallel_test_types_list:
if test_type.startswith(heavy_test_type):
test_types_list.remove(test_type)
parallel_test_types_list.remove(test_type)
tests_to_run_sequentially.append(test_type)
_run_tests_in_pool(
tests_to_run=tests_to_run_sequentially,
Expand All @@ -302,7 +302,7 @@ def run_tests_in_parallel(
skip_cleanup=skip_cleanup,
)
_run_tests_in_pool(
tests_to_run=test_types_list,
tests_to_run=parallel_test_types_list,
parallelism=parallelism,
exec_shell_params=exec_shell_params,
extra_pytest_args=extra_pytest_args,
Expand Down Expand Up @@ -351,11 +351,11 @@ def run_tests_in_parallel(
@option_debug_resources
@option_include_success_outputs
@click.option(
"--test-types",
"--parallel-test-types",
help="Space separated list of test types used for testing in parallel.",
default=" ".join(all_selective_test_types()) + " PlainAsserts",
show_default=True,
envvar="TEST_TYPES",
envvar="PARALLEL_TEST_TYPES",
)
@click.option(
"--full-tests-needed",
Expand Down Expand Up @@ -400,7 +400,7 @@ def command_for_tests(
skip_cleanup: bool,
debug_resources: bool,
include_success_outputs: bool,
test_types: str,
parallel_test_types: str,
full_tests_needed: bool,
mount_sources: str,
extra_pytest_args: tuple,
Expand Down Expand Up @@ -429,11 +429,11 @@ def command_for_tests(
cleanup_python_generated_files()
perform_environment_checks()
if run_in_parallel:
test_list = test_types.split(" ")
test_list = parallel_test_types.split(" ")
test_list.sort(key=lambda x: x in ["Providers", "WWW"], reverse=True)
run_tests_in_parallel(
exec_shell_params=exec_shell_params,
test_types_list=test_list,
parallel_test_types_list=test_list,
extra_pytest_args=extra_pytest_args,
db_reset=db_reset,
# Allow to pass information on whether to use full tests in the parallel execution mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"options": [
"--run-in-parallel",
"--parallelism",
"--test-types",
"--parallel-test-types",
"--skip-cleanup",
"--debug-resources",
"--include-success-outputs",
Expand Down
4 changes: 2 additions & 2 deletions dev/breeze/src/airflow_breeze/utils/selective_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def run_www_tests(self) -> bool:

@cached_property
def run_amazon_tests(self) -> bool:
return "amazon" in self.test_types or "Providers" in self.test_types.split(" ")
return "amazon" in self.parallel_test_types or "Providers" in self.parallel_test_types.split(" ")

@cached_property
def run_kubernetes_tests(self) -> bool:
Expand Down Expand Up @@ -560,7 +560,7 @@ def _get_test_types_to_run(self) -> list[str]:
return sorted_candidate_test_types

@cached_property
def test_types(self) -> str:
def parallel_test_types(self) -> str:
if not self.run_tests:
return ""
if self.full_tests_needed:
Expand Down
4 changes: 2 additions & 2 deletions images/breeze/output-commands-hash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ stop:e5aa686b4e53707ced4039d8414d5cd6
testing:docker-compose-tests:b86c044b24138af0659a05ed6331576c
testing:helm-tests:94a442e7f3f63b34c4831a84d165690a
testing:integration-tests:225ddb6243cce5fc64f4824b87adfd98
testing:tests:953ce65d99acee99014061b2fab7b8a3
testing:bc492ec01c4de953f28a66d0e8f50bc9
testing:tests:86441445a2b521e8d5aee04d74978451
testing:68efcf0731170e4ba2029121a5209e3a
Loading

0 comments on commit 2060643

Please sign in to comment.