mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-11-10 13:24:05 +08:00
add pytest-durations to the test workflow (#19443)
This commit is contained in:
1 parent
65fdc85fba
commit
7b37b25fcf
2 files changed
+17
-6
No files matched your search
@@ -503,7 +503,7 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
uv 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:nightly
|
||||
run: |
|
||||
@@ -836,7 +836,7 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
echo "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 Infinity
|
||||
if: env.API_PROXY_SCHEME != 'web'
|
||||
@@ -856,7 +856,7 @@ jobs:
|
||||
sudo docker logs ${RAGFLOW_CONTAINER}
|
||||
exit 1
|
||||
fi
|
||||
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 Infinity
|
||||
if: env.API_PROXY_SCHEME == 'python'
|
||||
@@ -1181,7 +1181,7 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
uv 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:nightly
|
||||
run: |
|
||||
@@ -1514,7 +1514,7 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
echo "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 Elasticsearch
|
||||
if: env.API_PROXY_SCHEME != 'web'
|
||||
@@ -1534,7 +1534,7 @@ jobs:
|
||||
sudo docker logs ${RAGFLOW_CONTAINER}
|
||||
exit 1
|
||||
fi
|
||||
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 Elasticsearch
|
||||
if: env.API_PROXY_SCHEME == 'python'
|
||||
|
||||
@@ -124,6 +124,7 @@ class TestRunner:
|
||||
self.markers = ""
|
||||
self.test_path = ""
|
||||
self.keyword = ""
|
||||
self.durations = 100
|
||||
|
||||
# Python interpreter path
|
||||
self.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 exists
|
||||
pyproject_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 test
|
||||
python run_tests.py --markers "unit" # Run only unit tests
|
||||
python 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.ignore
|
||||
self.test_path = args.test
|
||||
self.keyword = args.keyword
|
||||
self.durations = args.durations
|
||||
|
||||
return True
|
||||
|
||||
|
||||
Reference in new issue
Block a user