Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

perf(api): run controller unit tests in parallel (#43750)

Stephen Zhouda5ce5e4f63a
diff --git a/.github/workflows/api-tests.yml b/.github/workflows/api-tests.yml
index 153cfe16ff9..580eb1aea07 100644
--- a/.github/workflows/api-tests.yml
+++ b/.github/workflows/api-tests.yml
@@ -177,10 +177,12 @@ jobs:
run: uv sync --project api --dev
- name: Run Controller Tests
- # Controller tests register Flask routes at import time, so keep them out of xdist.
+ # Workers have separate Flask registries; keep collection separate from the other unit suites.
run: |
uv run --project api pytest \
+ -p no:benchmark \
--timeout "${PYTEST_TIMEOUT:-20}" \
+ -n auto \
-o 'addopts=-p no:opik -p no:langsmith_plugin --cov=./api --cov-branch --import-mode=importlib' \
--cov-report= \
--junitxml=test-results/controllers.xml \
diff --git a/Makefile b/Makefile
index 99f2b195bb7..9cc5057d325 100644
--- a/Makefile
+++ b/Makefile
@@ -113,7 +113,7 @@ test:
api/providers/vdb/*/tests/unit_tests \
api/providers/trace/*/tests/unit_tests \
--ignore=api/tests/unit_tests/controllers; \
- uv run --project api --dev pytest --timeout "$${PYTEST_TIMEOUT:-20}" --cov-append \
+ uv run --project api --dev pytest -p no:benchmark --timeout "$${PYTEST_TIMEOUT:-20}" -n auto --cov-append \
api/tests/unit_tests/controllers; \
fi
@echo "✅ Unit tests complete"
@@ -131,7 +131,7 @@ test-all:
api/providers/vdb/*/tests/unit_tests \
api/providers/trace/*/tests/unit_tests \
--ignore=api/tests/unit_tests/controllers; \
- uv run --project api --dev pytest --timeout "$${PYTEST_TIMEOUT:-20}" --cov-append \
+ uv run --project api --dev pytest -p no:benchmark --timeout "$${PYTEST_TIMEOUT:-20}" -n auto --cov-append \
api/tests/unit_tests/controllers; \
echo "Running backend integration tests"; \
uv run --project api --dev pytest -p no:benchmark --start-middleware -n auto \
diff --git a/api/tests/unit_tests/controllers/service_api/app/test_completion.py b/api/tests/unit_tests/controllers/service_api/app/test_completion.py
index 12f05078ba9..1042fab9f05 100644
--- a/api/tests/unit_tests/controllers/service_api/app/test_completion.py
+++ b/api/tests/unit_tests/controllers/service_api/app/test_completion.py
@@ -630,6 +630,7 @@ class TestChatApiController:
(DeploymentEdition.CLOUD, CloudPlan.PROFESSIONAL, str(uuid.uuid4())),
(DeploymentEdition.CLOUD, CloudPlan.SANDBOX, None),
],
+ ids=["community-version", "enterprise-version", "cloud-paid-version", "cloud-default-version"],
)
def test_allows_default_or_entitled_workflow_version_execution(
self,