Tests(py): add local pytest runtime foundation#10498
Tests(py): add local pytest runtime foundation#10498nmanovic wants to merge 5 commits intov3-pr3-psycopgfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3bc10fb4fa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| docker_host = os.environ.get("DOCKER_HOST", "") | ||
| if docker_host.startswith("unix://"): | ||
| candidate = docker_host.removeprefix("unix://") | ||
| if os.path.exists(candidate): | ||
| return candidate |
There was a problem hiding this comment.
Honor non-unix Docker hosts for container discovery
The new container discovery path only treats DOCKER_HOST as valid when it starts with unix://, then falls back to hardcoded local socket paths; environments that use DOCKER_HOST=tcp://... (or a non-socket Docker context) will hit FileNotFoundError("Docker socket not found") even though normal docker commands could still work. Because session startup now depends on this discovery (running_containers() / project_containers_running()), local pytest runs fail early in those setups.
Useful? React with 👍 / 👎.
| if platform == "kube": | ||
| legacy_init.session_start(session) | ||
| if should_run_version_check: |
There was a problem hiding this comment.
Reject local-only --infra modes when platform is kube
pytest_sessionstart parses --infra, but for --platform=kube it unconditionally calls legacy_init.session_start(session) and never validates that the selected infra mode is supported. This means commands like --platform=kube --infra=down/up/restore-db are accepted but silently run the normal kube startup path instead of the requested lifecycle action, which is misleading and can trigger unintended test execution.
Useful? React with 👍 / 👎.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
b4f16b7 to
542d708
Compare
3bc10fb to
f2c8e67
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f2c8e676bf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| stack_ok, reason = project_stack_compatible( | ||
| project_name, | ||
| expected_db_port=project_cfg.host_db_port, | ||
| expected_redis_inmem_port=project_cfg.host_redis_inmem_port, | ||
| expected_redis_ondisk_port=project_cfg.host_redis_ondisk_port, |
There was a problem hiding this comment.
Check Traefik port before reusing an existing stack
project_stack_compatible() is only given DB/Redis expectations here, but startup URL selection is driven by CVAT_BASE_URL (from the expected HTTP port). In --infra=reuse and auto mode, a stack with mismatched Traefik host port can be treated as compatible, then wait_for_services() polls the wrong URL and startup times out instead of rejecting/recreating the stack. Include HTTP (and related service endpoint) port compatibility in this gate.
Useful? React with 👍 / 👎.
542d708 to
ce2c84a
Compare
f2c8e67 to
0a878d3
Compare
0a878d3 to
ce7a4fe
Compare
ce2c84a to
ad4fad2
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0a878d3976
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| group._addoption( | ||
| "--infra", | ||
| action="store", | ||
| default=RuntimeInfraConfig.get_default_infra_mode(), | ||
| choices=RuntimeInfraConfig.get_infra_modes(), |
There was a problem hiding this comment.
Preserve legacy lifecycle CLI flags in option parser
By only registering --infra here, pytest no longer accepts legacy flags like --start-services, --stop-services, --rebuild, and --keep-data. Existing repo automation still invokes those flags (for example, .github/workflows/schedule.yml runs pytest tests/python/ --stop-services on lines 149 and 153), so those jobs now fail at argument parsing before tests/teardown logic runs. Please keep temporary aliases to the new --infra modes or migrate all in-repo callers in the same change.
Useful? React with 👍 / 👎.
| expected = { | ||
| f"{project_name}_cvat_server_1", | ||
| f"{project_name}_cvat_db_1", | ||
| f"{project_name}_traefik_1", | ||
| } |
There was a problem hiding this comment.
Require worker containers before reusing local stack
This running-stack check only requires cvat_server, cvat_db, and traefik, and _run_local_lifecycle() uses it to skip start_services() in --infra=auto/reuse. If one or more worker containers are missing, the run is still treated as reusable, but background jobs (import/export/annotation/webhooks) will not be processed and related tests can hang or fail. Include required worker services in the readiness set (or always run docker compose up -d) before considering the stack reusable.
Useful? React with 👍 / 👎.
ad4fad2 to
3bb08ff
Compare
ce7a4fe to
29cef23
Compare
3bb08ff to
67036f5
Compare
29cef23 to
360c5ac
Compare
Summary
This is PR 5 in the split series.
Base:
v3-pr3-psycopgThis PR introduces the pytest-managed local runtime foundation while preserving the existing kube/minikube behavior through the legacy path.
Scope:
--infrashared.fixtures.initNon-goals for this PR:
Main changes
tests/python/conftest.pywith explicit runtime setuptests/python/infra/*foundation modules for runtime config, health checks, lifecycle helpers, version checks, and local instance managementtests/python/shared/fixtures/init.pyfor compatibility until the later kube PRValidation
Passed:
helm lint helm-charthelm template cvat helm-charthelm template smoke helm-chart --set cvat.opa.composeCompatibleServiceName=falsehelm template smoke helm-chart --set cvat.opa.composeCompatibleServiceName=false --set cvat.opa.probePath=/healthpy_compileblack --checkisort --checkpylinton touched files (10.00/10)pytest tests/python/ --collect-only--infra=up--infra=down--infra=restore-db--infra=build-images2178 passed, 20 skipped, 1 xfailed, 1 warning26:28412 testsOK (skipped=58)10:48Important note
During validation I trimmed an earlier version of this PR that introduced dynamic local ports too early. That caused broad REST expectation breakage because many test payloads still assume
http://localhost:8080.This PR now intentionally preserves the legacy fixed-port local contract. Dynamic runtime URL/port work will be introduced later, in the dedicated runtime-profile PR where the test data and expectations are updated together.