RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
add pytest-durations to the test workflow (#19443)
maoyifeng7b37b25fcfd0
diff --git a/.github/workflows/sep-tests.yml b/.github/workflows/sep-tests.ymlindex 17b3b21732..99d3025936 100644--- a/.github/workflows/sep-tests.yml+++ b/.github/workflows/sep-tests.yml@@ -503,7 +503,7 @@ jobs:run: |set -euo pipefailuv sync --python 3.13 --group test --frozen- uv run pytest ragflow_deps/test_download_go_deps.py -q+ uv run pytest ragflow_deps/test_download_go_deps.py -q --durations=100- name: Build ragflow:nightlyrun: |@@ -836,7 +836,7 @@ jobs:exit 1fiecho "Start to run test sdk on Infinity"- source .venv/bin/activate && set -o pipefail; DOC_ENGINE=infinity pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} --junitxml=pytest-infinity-sdk.xml --cov=sdk/python/ragflow_sdk --cov-branch --cov-report=xml:coverage-infinity-sdk.xml test/testcases/test_sdk_api 2>&1 | tee infinity_sdk_test.log+ source .venv/bin/activate && set -o pipefail; DOC_ENGINE=infinity pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} --junitxml=pytest-infinity-sdk.xml --cov=sdk/python/ragflow_sdk --cov-branch --cov-report=xml:coverage-infinity-sdk.xml --durations=100 test/testcases/test_sdk_api 2>&1 | tee infinity_sdk_test.log- name: Run New RESTFUL api tests against Infinityif: env.API_PROXY_SCHEME != 'web'@@ -856,7 +856,7 @@ jobs:sudo docker logs ${RAGFLOW_CONTAINER}exit 1fi- source .venv/bin/activate && set -o pipefail; DOC_ENGINE=infinity pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/restful_api 2>&1 | tee infinity_restful_api_test.log+ source .venv/bin/activate && set -o pipefail; DOC_ENGINE=infinity pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} --durations=100 test/testcases/restful_api 2>&1 | tee infinity_restful_api_test.log- name: RAGFlow CLI retrieval test Infinityif: env.API_PROXY_SCHEME == 'python'@@ -1181,7 +1181,7 @@ jobs:run: |set -euo pipefailuv sync --python 3.13 --group test --frozen- uv run pytest ragflow_deps/test_download_go_deps.py -q+ uv run pytest ragflow_deps/test_download_go_deps.py -q --durations=100- name: Build ragflow:nightlyrun: |@@ -1514,7 +1514,7 @@ jobs:exit 1fiecho "Start to run test sdk on Elasticsearch"- source .venv/bin/activate && set -o pipefail; pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} --junitxml=pytest-es-sdk.xml --cov=sdk/python/ragflow_sdk --cov-branch --cov-report=xml:coverage-es-sdk.xml test/testcases/test_sdk_api 2>&1 | tee es_sdk_test.log+ source .venv/bin/activate && set -o pipefail; pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} --junitxml=pytest-es-sdk.xml --cov=sdk/python/ragflow_sdk --cov-branch --cov-report=xml:coverage-es-sdk.xml --durations=100 test/testcases/test_sdk_api 2>&1 | tee es_sdk_test.log- name: Run New RESTFUL api tests against Elasticsearchif: env.API_PROXY_SCHEME != 'web'@@ -1534,7 +1534,7 @@ jobs:sudo docker logs ${RAGFLOW_CONTAINER}exit 1fi- source .venv/bin/activate && set -o pipefail; pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/restful_api 2>&1 | tee es_restful_api_test.log+ source .venv/bin/activate && set -o pipefail; pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} --durations=100 test/testcases/restful_api 2>&1 | tee es_restful_api_test.log- name: RAGFlow CLI retrieval test Elasticsearchif: env.API_PROXY_SCHEME == 'python'diff --git a/run_tests.py b/run_tests.pyindex c15f9399ca..eea362d24c 100755--- a/run_tests.py+++ b/run_tests.py@@ -124,6 +124,7 @@ class TestRunner:self.markers = ""self.test_path = ""self.keyword = ""+ self.durations = 100# Python interpreter pathself.python = sys.executable@@ -153,6 +154,7 @@ OPTIONS:-v, --verbose Verbose output-t, --test FILE Run specific test file or directory-m, --markers MARKERS Run tests with specific markers (e.g., "unit", "integration")+ -d, --durations N Show the N slowest test durations (default: 100)EXAMPLES:# Run all tests@@ -227,6 +229,9 @@ EXAMPLES:if self.ignore_syntax_warning:cmd.extend(["-W", "ignore::SyntaxWarning"])+ # Add slow test durations report (top N slowest tests)+ cmd.extend(["--durations", str(self.durations)])+# Add default options from pyproject.toml if it existspyproject_path = self.project_root / "pyproject.toml"if pyproject_path.exists():@@ -256,6 +261,8 @@ EXAMPLES:self.print_info(f"Markers: {self.markers}")if self.keyword:self.print_info(f"Keyword: {self.keyword}")+ if self.durations:+ self.print_info(f"Durations: top {self.durations} slowest tests")print(f"\n{set_color(s='[EXECUTING]', color='blue')} {' '.join(cmd)}\n")@@ -302,6 +309,7 @@ Examples:python run_tests.py --test services/test_dialog_service.py # Run specific testpython run_tests.py --markers "unit" # Run only unit testspython run_tests.py --ignore # Run with "-W ignore::SyntaxWarning" option+ python run_tests.py --durations 50 # Show the 50 slowest tests""",)@@ -319,6 +327,8 @@ Examples:parser.add_argument("-m", "--markers", type=str, default="", help="Run tests with specific markers (e.g., 'unit', 'integration')")+ parser.add_argument("-d", "--durations", type=int, default=100, help="Show the N slowest test durations in the summary (0 to disable)")+try:args = parser.parse_args()@@ -330,6 +340,7 @@ Examples:self.ignore_syntax_warning = args.ignoreself.test_path = args.testself.keyword = args.keyword+ self.durations = args.durationsreturn True