You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2023/07/15 06:25:37 UTC
[airflow] branch main updated: Add a test to catch regressions in cli run time (#32612)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 7fa524deb3 Add a test to catch regressions in cli run time (#32612)
7fa524deb3 is described below
commit 7fa524deb3f62ee49228f1433c4f76667986f332
Author: Niko Oliveira <on...@amazon.com>
AuthorDate: Fri Jul 14 23:25:29 2023 -0700
Add a test to catch regressions in cli run time (#32612)
---
tests/cli/test_cli_parser.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/tests/cli/test_cli_parser.py b/tests/cli/test_cli_parser.py
index fbbb257982..935417b4b6 100644
--- a/tests/cli/test_cli_parser.py
+++ b/tests/cli/test_cli_parser.py
@@ -22,6 +22,7 @@ import argparse
import contextlib
import io
import re
+import timeit
from collections import Counter
from unittest.mock import patch
@@ -268,3 +269,13 @@ class TestCli:
f"--export-format: invalid choice: '{export_format}' "
"(choose from 'csv'), see help above.\n"
)
+
+ def test_cli_run_time(self):
+ setup_code = "import subprocess"
+ timing_code = 'subprocess.run(["airflow", "--help"])'
+ # Limit the number of samples otherwise the test will take a very long time
+ num_samples = 3
+ threshold = 3.5
+ timing_result = timeit.timeit(stmt=timing_code, number=num_samples, setup=setup_code) / num_samples
+ # Average run time of Airflow CLI should at least be within 3.5s
+ assert timing_result < threshold