docs: add integration testing with Testcontainers guide#9363
Conversation
Adds a how-to guide for `infrahub-testcontainers`, covering installation, the `TestInfrahubDocker` pytest base class, available fixtures, SDK connection setup, environment variable reference, cluster deployment, and CI usage. Converts the testing-framework sidebar entry from a flat doc to a category so both pages are discoverable. Fixes #9362. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. This PR adds a new documentation page for Testcontainers integration testing, updates spelling exceptions, and restructures the sidebar into a collapsible category—all documentation and configuration changes with no source code impact, so the risk of breaking any functionality is extremely low.
Re-trigger cubic
Replace placeholder examples with patterns sourced from real opsmill projects (infrahub-demo-service-catalog, devnet-live-2025, infrahub-solution-ai-dc, infrahub-sdk-python): - Switch primary class to TestInfrahubDockerClient (from infrahub_sdk.testing.docker) - Fix auth to username/password (admin/infrahub) instead of token - Add schema loading pattern using SchemaFile + wait_until_converged - Add GitRepo repository setup pattern - Add conftest.py fixture setup (root_dir, schema_dir, data_dir) - Update fixtures table to include client/client_sync - Add conftest/Conftest to Vale spelling exceptions Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Links to infrahub-demo-dc, infrahub-demo-service-catalog, and devnet-live-2025 as public reference implementations. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Shadow auto-approve: would auto-approve. The changes are limited to documentation (new testcontainers guide, developer guide update, sidebar restructuring) and adding spelling exceptions, with no modifications to source code, tests, or critical configuration, making the risk of breakage extremely low.
Re-trigger cubic
Covers using breakpoint() + pytest -s to pause test execution and inspect the live Infrahub instance, plus a fixture override pattern for keeping containers up after a test failure. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="docs/docs/testing-framework/testcontainers.mdx">
<violation number="1" location="docs/docs/testing-framework/testcontainers.mdx:224">
P2: Wrap `infrahub_compose.start()` with the same try/except error handling as the real fixture, so startup failures during debugging capture and display container logs.</violation>
</file>
Shadow auto-approve: would not auto-approve because issues were found.
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
| ```python | ||
| @pytest.fixture(scope="class") | ||
| def infrahub_app(self, request, infrahub_compose): | ||
| infrahub_compose.start() |
There was a problem hiding this comment.
P2: Wrap infrahub_compose.start() with the same try/except error handling as the real fixture, so startup failures during debugging capture and display container logs.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/docs/testing-framework/testcontainers.mdx, line 224:
<comment>Wrap `infrahub_compose.start()` with the same try/except error handling as the real fixture, so startup failures during debugging capture and display container logs.</comment>
<file context>
@@ -176,6 +176,60 @@ pytest tests/ --deployment-type cluster
+```python
+@pytest.fixture(scope="class")
+def infrahub_app(self, request, infrahub_compose):
+ infrahub_compose.start()
+ yield infrahub_compose.get_services_port()
+ # containers are NOT stopped — remember to clean up manually
</file context>
| infrahub_compose.start() | |
| try: | |
| infrahub_compose.start() | |
| except Exception as exc: | |
| stdout, stderr = infrahub_compose.get_logs() | |
| raise Exception(f"Failed to start docker compose:\nStdout:\n{stdout}\nStderr:\n{stderr}") from exc |
The Testcontainers guide targets external Python developers writing pytest integration tests against a Dockerized Infrahub — distinct from the in-repo YAML test framework that runs inside the proposed-change CI pipeline. Move it next to the Developer Guide so it sits with the other SDK/CLI-flavored resources, and restore Testing Framework as a flat doc under Branches & Change Control. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Shadow auto-approve: would not auto-approve. Auto-approval blocked by 1 unresolved issue from previous reviews.
Re-trigger cubic
Summary
docs/docs/testing-framework/testcontainers.mdx— a how-to guide for theinfrahub-testcontainerspackage covering installation, theTestInfrahubDockerpytest base class and its fixtures, SDK connection setup, environment variable reference, cluster deployment, and a GitHub Actions CI exampleTesting Frameworksidebar entry from a flat doc to a collapsible category with the new page as a spoke (hub link → overview, spoke → new testcontainers page)Gunicorn,Testcontainers, andtestcontainersto.vale/styles/spelling-exceptions.txtCloses #9362
Reviewer attention
infrahubctl schema load(confirmed intasks/infra_ops.py) andInfrahubClient(config=Config(...))(confirmed inbackend/tests/integration/git/test_git_repository.py). Please verify theConfigconstructor parameter names match the current SDK version.INFRAHUB_TESTING_INITIAL_ADMIN_TOKEN) are sourced frompython_testcontainers/infrahub_testcontainers/container.py— correct at time of writing but worth a quick check if the package has been updated recently.Test plan
uv run invoke docs.lint— 0 errors (20 pre-existing warnings, none in new file)cd docs && npm run build— build passes🤖 Generated with Claude Code
Summary by cubic
Adds a Testcontainers integration testing guide for
infrahub-testcontainers, with real-world examples and a debugging workflow. Moves the guide to Development Resources, links it from the Developer Guide, and updates spelling exceptions.docs/docs/development-resources/testcontainers.mdx— install,TestInfrahubDockerClientasync/sync clients, schema load +wait_until_converged,GitRepo,conftest.py, env vars, cluster mode, CI, debugging withbreakpoint()+pytest -s, and real-world examples.valespelling exceptions (e.g.,conftest,Testcontainers,breakpoint,pdb,stdin)Written for commit 71873b2. Summary will update on new commits. Review in cubic