diff --git a/airflow-ctl-tests/tests/airflowctl_tests/conftest.py b/airflow-ctl-tests/tests/airflowctl_tests/conftest.py index e5ccff6c51dd4..2c57c0ca120bc 100644 --- a/airflow-ctl-tests/tests/airflowctl_tests/conftest.py +++ b/airflow-ctl-tests/tests/airflowctl_tests/conftest.py @@ -263,14 +263,13 @@ def test_commands(login_command, date_param): # DAGs commands "dags list", "dags get --dag-id=example_bash_operator", + # Order of trigger and pause/unpause is important for test stability because state checked + f"dags trigger --dag-id=example_bash_operator --logical-date={date_param} --run-after={date_param}", "dags pause --dag-id=example_bash_operator", "dags unpause --dag-id=example_bash_operator", - "dags update --dag-id=example_bash_operator --is-paused=false", # DAG Run commands - f"dagrun trigger --dag-id=example_bash_operator --logical-date={date_param} --run-after={date_param}", + f'dagrun get --dag-id=example_bash_operator --dag-run-id="manual__{date_param}"', "dagrun list --dag-id example_bash_operator --state success --limit=1", - f"dagrun get --dag-id=example_bash_operator --dagrun-id=manual__{date_param}", - f"dagrun delete --dag-id=example_bash_operator --dagrun-id=manual__{date_param}", # Jobs commands "jobs list", # Pools commands diff --git a/airflow-ctl-tests/tests/airflowctl_tests/test_airflowctl_commands.py b/airflow-ctl-tests/tests/airflowctl_tests/test_airflowctl_commands.py index d17e646cb069d..83288657c57c0 100644 --- a/airflow-ctl-tests/tests/airflowctl_tests/test_airflowctl_commands.py +++ b/airflow-ctl-tests/tests/airflowctl_tests/test_airflowctl_commands.py @@ -62,14 +62,15 @@ def test_airflowctl_commands(login_command, login_output, test_commands): # This is a common error message that is thrown by client when something is wrong # Please ensure it is aligning with airflowctl.api.client.get_json_error - airflowctl_client_server_response_error = "Server error" - airflowctl_command_error = "command error: argument GROUP_OR_COMMAND: invalid choice" - if ( - airflowctl_client_server_response_error in stdout_result - or airflowctl_command_error in stdout_result - ): + error_strings = [ + "Server error", + "command error", + "unrecognized arguments", + "invalid choice", + ] + if any(error in stdout_result for error in error_strings): console.print(f"[red]❌ Output contained unexpected text for command '{command_from_config}'") - console.print(f"[red]Did not expect to find:\n{airflowctl_client_server_response_error}\n") + console.print("[red]Did not expect to find this error.\n") console.print(f"[red]But got:\n{stdout_result}\n") raise AssertionError(f"Output contained unexpected text\nOutput:\n{stdout_result}") console.print(f"[green]✅ Output did not contain unexpected text for command '{command_from_config}'")