The RAGFlow testing infrastructure provides a comprehensive validation suite covering the entire stack, from core document understanding logic to end-to-end browser interactions. The system utilizes pytest as the primary test runner and integrates with GitHub Actions for continuous integration against multiple backend configurations (Elasticsearch, Infinity, OpenSearch).
The test suite is categorized into several distinct layers based on the interface they target and their position in the request lifecycle.
| Category | Location | Purpose | Key Tools |
|---|---|---|---|
| SDK Tests | sdk/python/test/ | Validates the Python SDK client logic and its interaction with the server sdk/python/test/conftest.py22-86 | ragflow-sdk, pytest, hypothesis |
| HTTP API Tests | test/testcases/test_http_api/ | Tests the high-level RESTful API endpoints directly via requests test/testcases/test_http_api/common.py18-33 | requests, requests-toolbelt |
| Restful API Tests | test/testcases/restful_api/ | Comprehensive suite for API contracts, including OpenAI compatibility and Go-proxy parity test/testcases/restful_api/test_datasets.py30-49 | pytest, RestClient |
| Web API Tests | test/testcases/test_web_api/ | Internal API validation for endpoints used by the React web frontend test/testcases/test_web_api/test_file_app/test_file2document_routes_unit.py1-5 | pytest |
| Unit Tests | test/unit_test/ | Tests isolated business logic using stubs for heavy dependencies like LLM providers test/unit_test/api/apps/restful_apis/test_openai_stream_no_duplicate.py1-10 | pytest, monkeypatch |
| Playwright E2E | test/playwright/e2e/ | End-to-end browser-based testing for user flows. | Playwright, pytest-playwright |
| Benchmark | test/benchmark/ | Performance and retrieval accuracy testing test/benchmark/README.md1-5 | requests, auth.py |
Sources: test/testcases/test_http_api/common.py18-33 test/testcases/restful_api/test_datasets.py30-49 sdk/python/test/conftest.py22-86 test/benchmark/README.md1-5
The following diagram illustrates how different test types interact with the RAGFlow ecosystem, bridging natural language test definitions to code entities.
Testing Interface Architecture
Sources: test/testcases/test_http_api/common.py23-33 api/apps/restful_apis/openai_api.py34-51 test/testcases/restful_api/test_datasets.py69-76 sdk/python/test/conftest.py52-60
RAGFlow leverages pytest fixtures, markers, and environment variables to manage state and prioritize execution.
The infrastructure uses a level-based marking system in GitHub Actions to control test execution depth based on the trigger .github/workflows/sep-tests.yml43-47:
hypothesis test/testcases/test_http_api/test_dataset_management/test_update_dataset.py124-129The CI pipeline detects changes across Python, Go, and Web components to optimize execution .github/workflows/sep-tests.yml44-46 It also supports testing against different backend document engines by setting the DOC_ENGINE environment variable test/testcases/restful_api/test_datasets.py51-65
A significant portion of the testing infrastructure is dedicated to ensuring parity between the Python backend and the Go proxy layer. Tests utilize the IS_GO_PROXY flag to handle differences in error codes and field names test/testcases/restful_api/test_datasets.py30-32
Sources: .github/workflows/sep-tests.yml40-48 test/testcases/restful_api/test_datasets.py30-65 test/testcases/test_http_api/test_dataset_management/test_update_dataset.py91-129
Tests in test_http_api/common.py and restful_api/ provide helper functions that encapsulate the API contracts for major features:
create_dataset, list_datasets, update_dataset test/testcases/test_http_api/common.py37-49upload_documents, parse_documents, stop_parse_documents test/testcases/test_http_api/common.py75-149chat.completion payloads api/apps/restful_apis/openai_api.py107-142SDK to Backend Mapping
Sources: test/testcases/test_http_api/common.py24-33 sdk/python/test/test_frontend_api/test_dataset.py23-27 api/apps/restful_apis/openai_api.py97-106 sdk/python/test/conftest.py79-87
RAGFlow uses hypothesis to generate valid and invalid inputs for API testing, ensuring robustness against edge cases in naming and metadata test/testcases/test_http_api/test_dataset_management/test_update_dataset.py125-138
valid_names() test/testcases/test_http_api/test_dataset_management/test_update_dataset.py125-134enrich_chunks_with_document_metadata api/apps/restful_apis/openai_api.py58-85The repository uses lefthook to manage pre-commit hooks, ensuring that code style and basic linting are enforced before commits are pushed .github/workflows/sep-tests.yml136-150
Sources: test/testcases/test_http_api/test_dataset_management/test_update_dataset.py125-138 api/apps/restful_apis/openai_api.py58-85 .github/workflows/sep-tests.yml136-150
Refresh this wiki
This wiki was recently refreshed. Please wait 4 days to refresh again.