Skip to content

Commit 9c3c1a9

Browse files
committed
Revert "removing test_type check"
This reverts commit 516c17cf252b332be6d2d886d38c6a289cb9bbf1.
1 parent 791583b commit 9c3c1a9

7 files changed

Lines changed: 229 additions & 103 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,10 +1055,12 @@ ${{ hashFiles('.pre-commit-config.yaml') }}"
10551055
- name: "Test Offline SQL generation"
10561056
run: ./scripts/ci/testing/run_offline_sql_test.sh
10571057
- name: "Tests: ${{needs.build-info.outputs.test-types}}"
1058-
run: ./scripts/ci/testing/ci_run_airflow_testing.sh
1058+
run: breeze testing tests
1059+
--run-parallel-test
10591060
env:
10601061
PR_LABELS: "${{ needs.build-info.outputs.pull-request-labels }}"
10611062
IMAGE_TAG: ${{ env.IMAGE_TAG_FOR_THE_BUILD }}
1063+
TEST_TYPES: ${{needs.build-info.outputs.test-types}}
10621064
- name: "Upload airflow logs"
10631065
uses: actions/upload-artifact@v3
10641066
if: failure()
@@ -1126,10 +1128,12 @@ ${{ hashFiles('.pre-commit-config.yaml') }}"
11261128
- name: "Test downgrade"
11271129
run: ./scripts/ci/testing/run_downgrade_test.sh
11281130
- name: "Tests: ${{needs.build-info.outputs.test-types}}"
1129-
run: ./scripts/ci/testing/ci_run_airflow_testing.sh
1131+
run: breeze testing tests
1132+
--run-parallel-test
11301133
env:
11311134
PR_LABELS: "${{ needs.build-info.outputs.pull-request-labels }}"
11321135
IMAGE_TAG: ${{ env.IMAGE_TAG_FOR_THE_BUILD }}
1136+
TEST_TYPES: ${{needs.build-info.outputs.test-types}}
11331137
- name: "Upload airflow logs"
11341138
uses: actions/upload-artifact@v3
11351139
if: failure()
@@ -1197,10 +1201,12 @@ ${{ hashFiles('.pre-commit-config.yaml') }}"
11971201
- name: "Test downgrade"
11981202
run: ./scripts/ci/testing/run_downgrade_test.sh
11991203
- name: "Tests: ${{needs.build-info.outputs.test-types}}"
1200-
run: ./scripts/ci/testing/ci_run_airflow_testing.sh
1204+
run: breeze testing tests
1205+
--run-parallel-test
12011206
env:
12021207
PR_LABELS: "${{ needs.build-info.outputs.pull-request-labels }}"
12031208
IMAGE_TAG: ${{ env.IMAGE_TAG_FOR_THE_BUILD }}
1209+
TEST_TYPES: ${{needs.build-info.outputs.test-types}}
12041210
- name: "Upload airflow logs"
12051211
uses: actions/upload-artifact@v3
12061212
if: failure()
@@ -1266,10 +1272,12 @@ ${{ hashFiles('.pre-commit-config.yaml') }}"
12661272
- name: "Test downgrade"
12671273
run: ./scripts/ci/testing/run_downgrade_test.sh
12681274
- name: "Tests: ${{needs.build-info.outputs.test-types}}"
1269-
run: ./scripts/ci/testing/ci_run_airflow_testing.sh
1275+
run: breeze testing tests
1276+
--run-parallel-test
12701277
env:
12711278
PR_LABELS: "${{ needs.build-info.outputs.pull-request-labels }}"
12721279
IMAGE_TAG: ${{ env.IMAGE_TAG_FOR_THE_BUILD }}
1280+
TEST_TYPES: ${{needs.build-info.outputs.test-types}}
12731281
- name: "Upload airflow logs"
12741282
uses: actions/upload-artifact@v3
12751283
if: failure()

dev/breeze/src/airflow_breeze/commands/ci_image_commands.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ def run_build(ci_image_params: BuildCiParams) -> None:
260260
@option_verify
261261
@option_wait_for_image
262262
@option_image_tag_for_pulling
263-
@option_include_success_outputs
264263
@option_tag_as_latest
265264
@click.argument('extra_pytest_args', nargs=-1, type=click.UNPROCESSED)
266265
def pull(

dev/breeze/src/airflow_breeze/commands/testing_commands.py

Lines changed: 93 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@
4040
option_github_repository,
4141
option_image_name,
4242
option_image_tag_for_running,
43+
option_include_success_outputs,
4344
option_integration,
4445
option_mount_sources,
4546
option_mssql_version,
4647
option_mysql_version,
48+
option_parallelism,
4749
option_postgres_version,
4850
option_python,
51+
option_run_parallel_test,
52+
option_skip_cleanup,
4953
option_verbose,
5054
)
5155
from airflow_breeze.utils.console import get_console, message_type_from_return_code
@@ -55,6 +59,7 @@
5559
get_env_variables_for_docker_commands,
5660
perform_environment_checks,
5761
)
62+
from airflow_breeze.utils.parallel import check_async_run_results, run_with_pool
5863
from airflow_breeze.utils.run_tests import run_docker_compose_tests
5964
from airflow_breeze.utils.run_utils import RunCommandResult, run_command
6065

@@ -189,6 +194,68 @@ def run_with_progress(
189194
return result
190195

191196

197+
def run_tests(
198+
env_variables: Dict[str, str], dry_run: bool, verbose: bool, test_type: str, extra_pytest_args: Tuple
199+
) -> Tuple[int, str]:
200+
env_variables['TEST_TYPE'] = test_type
201+
perform_environment_checks(verbose=verbose)
202+
cmd = ['docker-compose', 'run', '--service-ports', '--rm', 'airflow']
203+
cmd.extend(list(extra_pytest_args))
204+
test_result = run_command(
205+
cmd,
206+
verbose=verbose,
207+
dry_run=dry_run,
208+
env=env_variables,
209+
)
210+
return (
211+
test_result.returncode,
212+
f"Running tests {test_type}",
213+
)
214+
215+
216+
def run_tests_in_parallel(
217+
env_variables: Dict[str, str],
218+
test_type_list: List[str],
219+
include_success_outputs: bool,
220+
skip_cleanup: bool,
221+
parallelism: int,
222+
dry_run: bool,
223+
verbose: bool,
224+
extra_pytest_args: Tuple,
225+
):
226+
"""Run tests in parallel"""
227+
with ci_group(f"Running tests for the type {test_type_list}"):
228+
# get_console().print(
229+
# f"\n[info]Running tests with parallelism = {parallelism} "
230+
# f"for the test type: {test_type_list}[/]"
231+
# )
232+
all_params = [f"Tests {test_type}" for test_type in test_type_list]
233+
with run_with_pool(
234+
parallelism=parallelism,
235+
all_params=all_params,
236+
) as (pool, outputs):
237+
results = [
238+
pool.apply_async(
239+
run_tests,
240+
kwds={
241+
"env_variables": env_variables,
242+
"dry_run": dry_run,
243+
"verbose": verbose,
244+
"test_type": test_type,
245+
"extra_pytest_args": extra_pytest_args,
246+
},
247+
)
248+
for test_type in test_type_list
249+
]
250+
check_async_run_results(
251+
results=results,
252+
success="All tests run correctly",
253+
outputs=outputs,
254+
include_success_outputs=include_success_outputs,
255+
skip_cleanup=skip_cleanup,
256+
)
257+
258+
192259
@testing.command(
193260
name='tests',
194261
help="Run the specified unit test targets.",
@@ -218,6 +285,7 @@ def run_with_progress(
218285
"tests should be run - for example --test-type \"Providers[airbyte,http]\"",
219286
default="All",
220287
type=NotVerifiedBetterChoice(ALLOWED_TEST_TYPE_CHOICES),
288+
envvar='TEST_TYPES',
221289
)
222290
@click.option(
223291
"--test-timeout",
@@ -226,6 +294,10 @@ def run_with_progress(
226294
show_default=True,
227295
)
228296
@option_db_reset
297+
@option_run_parallel_test
298+
@option_parallelism
299+
@option_include_success_outputs
300+
@option_skip_cleanup
229301
@click.argument('extra_pytest_args', nargs=-1, type=click.UNPROCESSED)
230302
def tests(
231303
dry_run: bool,
@@ -241,8 +313,12 @@ def tests(
241313
test_type: str,
242314
test_timeout: str,
243315
db_reset: bool,
244-
image_tag: str | None,
316+
run_parallel_test: bool,
317+
parallelism: int,
318+
image_tag: Optional[str],
245319
mount_sources: str,
320+
skip_cleanup: bool,
321+
include_success_outputs: bool,
246322
):
247323
exec_shell_params = ShellParams(
248324
verbose=verbose,
@@ -257,10 +333,11 @@ def tests(
257333
)
258334
env_variables = get_env_variables_for_docker_commands(exec_shell_params)
259335
env_variables['RUN_TESTS'] = "true"
260-
env_variables["TEST_TYPE"] = test_type
261-
if "[" in test_type and not test_type.startswith("Providers"):
262-
get_console().print("[error]Only 'Providers' test type can specify actual tests with \\[\\][/]")
263-
sys.exit(1)
336+
if test_type:
337+
env_variables["TEST_TYPE"] = test_type
338+
if "[" in test_type and not test_type.startswith("Providers"):
339+
get_console().print("[error]Only 'Providers' test type can specify actual tests with \\[\\][/]")
340+
sys.exit(1)
264341
if test_timeout:
265342
env_variables["TEST_TIMEOUT"] = test_timeout
266343
if integration:
@@ -292,6 +369,17 @@ def tests(
292369
verbose=verbose,
293370
dry_run=dry_run,
294371
)
372+
elif run_parallel_test:
373+
run_tests_in_parallel(
374+
env_variables=env_variables,
375+
test_type_list=ALLOWED_TEST_TYPE_CHOICES,
376+
include_success_outputs=include_success_outputs,
377+
skip_cleanup=skip_cleanup,
378+
parallelism=parallelism,
379+
dry_run=dry_run,
380+
verbose=verbose,
381+
extra_pytest_args=extra_pytest_args if extra_pytest_args is not None else (),
382+
)
295383
else:
296384
result = run_command(cmd, verbose=verbose, dry_run=dry_run, env=env_variables, check=False)
297385
sys.exit(result.returncode)

dev/breeze/src/airflow_breeze/global_constants.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,10 @@ class SelectiveUnitTestTypes(Enum):
9191

9292
ALLOWED_TEST_TYPE_CHOICES = [
9393
"All",
94-
"Always",
9594
*all_selective_test_types(),
9695
"Helm",
9796
"Postgres",
9897
"MySQL",
99-
"Integration",
100-
"Other",
10198
"Quarantine",
10299
]
103100

dev/breeze/src/airflow_breeze/utils/common_options.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,12 @@ def _set_default_from_parent(ctx: click.core.Context, option: click.core.Option,
428428
is_flag=True,
429429
envvar='RUN_IN_PARALLEL',
430430
)
431+
option_run_parallel_test = click.option(
432+
'--run-parallel-test',
433+
help="Run the operation in parallel on all of Test types",
434+
is_flag=True,
435+
envvar='RUN_PARALLEL_TEST',
436+
)
431437
option_parallelism = click.option(
432438
'--parallelism',
433439
help="Maximum number of processes to use while running the operation in parallel.",

images/breeze/output-commands-hash.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ ci:resource-check:0fb929ac3496dbbe97acfe99e35accd7
1111
ci:selective-check:d4e3c250cd6f2b0040fbe6557fa423f6
1212
ci:31566cdcdde216086f559215223b2378
1313
ci-image:build:d39a25675e6b74af9bbb1fc2582aacc5
14-
ci-image:pull:8aca8679e6030ad0d6e59216af40c0b3
14+
ci-image:pull:fdde25906ad4c666db606201be44c240
1515
ci-image:verify:a2daeaa820c0baca31da2737929b38b9
16-
ci-image:b1c7a3c6dfa72b127fac559dcfdbb0d3
16+
ci-image:310bac16f2c61789453569a4f7901595
1717
cleanup:9bf46a1dfd9db4fe13a1c233ad1bb96b
1818
compile-www-assets:23675c1862d0968cbff6ab6f1d93d488
1919
exec:89b81bc34d45b0fe6653a6db5482258c
@@ -53,5 +53,5 @@ static-checks:425cd78507278494e345fb7648260c24
5353
stop:8ebd8a42f1003495d37b884de5ac7ce6
5454
testing:docker-compose-tests:3e07be65e30219930d3c62a593dd8c6a
5555
testing:helm-tests:403231f0a94b261f9c7aae8aea03ec50
56-
testing:tests:32deda30f3899e8ae6e241238f990d68
57-
testing:e747ece268ba502c106924eb2f46c550
56+
testing:tests:418233cc2313a34da99fb41a841fe0cf
57+
testing:416c94fc5fce116f7f79d296484dfa1b

0 commit comments

Comments
 (0)