Provision the E2E NetBox with docker compose - #2565
Open
ideaship wants to merge 1 commit into
Open
Conversation
9 tasks
berendt
force-pushed
the
sonic-e2e-v2-compose
branch
from
August 5, 2026 15:10
df1acf4 to
29058cc
Compare
ideaship
force-pushed
the
sonic-e2e-v2-compose
branch
from
August 5, 2026 19:51
29058cc to
0299da7
Compare
berendt
force-pushed
the
sonic-e2e-v2-compose
branch
from
August 6, 2026 10:56
0299da7 to
be5399c
Compare
ideaship
marked this pull request as ready for review
August 6, 2026 11:13
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In tests/e2e/sonic_golden_test.sh the
pipenv run pip install --quiet '.[ansible]'step will run on every invocation and can be both slow and mutate the developer environment unexpectedly; consider moving this into a dedicated setup step (e.g. a make target or CI job bootstrap) and failing fast if the extra is missing instead of installing it during the test run.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In tests/e2e/sonic_golden_test.sh the `pipenv run pip install --quiet '.[ansible]'` step will run on every invocation and can be both slow and mutate the developer environment unexpectedly; consider moving this into a dedicated setup step (e.g. a make target or CI job bootstrap) and failing fast if the extra is missing instead of installing it during the test run.
## Individual Comments
### Comment 1
<location path="Makefile" line_range="8-13" />
<code_context>
+# Full cycle: start the NetBox compose stack (an existing stack is reused
+# and left in place), seed, generate, compare against tests/e2e/golden/.
+sonic-e2e:
+ NETBOX_MANAGER_DIR=$(NETBOX_MANAGER_DIR) tests/e2e/sonic_golden_test.sh
+
+# Regenerate the golden files after an intentional generator change,
+# then review and commit the diff.
+sonic-e2e-regen:
+ NETBOX_MANAGER_DIR=$(NETBOX_MANAGER_DIR) tests/e2e/sonic_golden_test.sh --regenerate
+
+# Start the NetBox stack and leave it running for debugging. Export a
</code_context>
<issue_to_address>
**suggestion:** Quote NETBOX_MANAGER_DIR when exporting to avoid issues with spaces in the path
As written, these targets will fail if `NETBOX_MANAGER_DIR` contains spaces or shell-special characters because the variable expansion isn’t quoted. Please update the invocations to quote the assignment, e.g. `NETBOX_MANAGER_DIR="$(NETBOX_MANAGER_DIR)" tests/e2e/sonic_golden_test.sh` (or use `env NETBOX_MANAGER_DIR="$(NETBOX_MANAGER_DIR)" ...`) so directories with spaces work correctly.
Suggested implementation:
```
sonic-e2e:
NETBOX_MANAGER_DIR="$(NETBOX_MANAGER_DIR)" tests/e2e/sonic_golden_test.sh
```
```
sonic-e2e-regen:
NETBOX_MANAGER_DIR="$(NETBOX_MANAGER_DIR)" tests/e2e/sonic_golden_test.sh --regenerate
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Comment on lines
+8
to
+13
| NETBOX_MANAGER_DIR=$(NETBOX_MANAGER_DIR) tests/e2e/sonic_golden_test.sh | ||
|
|
||
| # Regenerate the golden files after an intentional generator change, | ||
| # then review and commit the diff. | ||
| sonic-e2e-regen: | ||
| NETBOX_MANAGER_DIR=$(NETBOX_MANAGER_DIR) tests/e2e/sonic_golden_test.sh --regenerate |
There was a problem hiding this comment.
suggestion: Quote NETBOX_MANAGER_DIR when exporting to avoid issues with spaces in the path
As written, these targets will fail if NETBOX_MANAGER_DIR contains spaces or shell-special characters because the variable expansion isn’t quoted. Please update the invocations to quote the assignment, e.g. NETBOX_MANAGER_DIR="$(NETBOX_MANAGER_DIR)" tests/e2e/sonic_golden_test.sh (or use env NETBOX_MANAGER_DIR="$(NETBOX_MANAGER_DIR)" ...) so directories with spaces work correctly.
Suggested implementation:
sonic-e2e:
NETBOX_MANAGER_DIR="$(NETBOX_MANAGER_DIR)" tests/e2e/sonic_golden_test.sh
sonic-e2e-regen:
NETBOX_MANAGER_DIR="$(NETBOX_MANAGER_DIR)" tests/e2e/sonic_golden_test.sh --regenerate
ideaship
marked this pull request as draft
August 6, 2026 12:09
ideaship
force-pushed
the
sonic-e2e-v2-compose
branch
from
August 6, 2026 12:10
be5399c to
a75a30d
Compare
Add the infrastructure side of the SONiC config-generation E2E golden test: tests/e2e/compose.yaml, tests/e2e/deploy_netbox.sh and tests/e2e/sonic_golden_test.sh, plus the Makefile target and .gitignore entry that drive them. compose.yaml defines three services (NetBox, its Postgres database and Redis) -- no Kubernetes, so there is no kind/kubectl dependency and no cluster bring-up latency. NetBox is configured entirely through the environment variables its own baked-in configuration.py already reads; nothing is templated or mounted over it. API_TOKEN_PEPPERS is deliberately left unset so that a plain v1 API token can be minted for the test run instead of the peppered v2 format. NETBOX_PORT is the only variable interpolated into the compose file, because compose re-interpolates the whole file on every subcommand (up, ps, down, ...): keeping the rest of the configuration in the container environment avoids re-resolving values on each invocation. deploy_netbox.sh brings the stack up, waits for the healthchecks and mints/prints the API token. sonic_golden_test.sh is the harness entrypoint: it provisions NetBox via deploy_netbox.sh, then seeds it by installing netbox-manager into a dedicated venv (so its package pins never mutate this project's venv) and running it against the fixtures under tests/e2e/scenario/ -- netbox-manager's own bundled example/ data is not used. Concurrent seeding is disabled by default (SEED_PARALLEL=1) because seeding files in the same numeric group take KEY SHARE locks on shared parent dcim_device rows and can deadlock; the script documents the observed error and the condition that still causes it (200-fabric.yml cabling both leaves to a shared spine). Finally it runs sync_sonic() via generate.py and compares the result against tests/e2e/golden/. make sonic-e2e wires the above together; make sonic-e2e-regen adds --regenerate to rewrite the goldens. --regenerate refuses to run against a reused stack (CREATED_STACK==0) unless ALLOW_WARM_REGEN=1 is set: applying the fixtures as an UPDATE over whatever is already in a reused database can produce goldens a fresh stack -- the only kind CI ever uses -- would not reproduce, and nothing would otherwise say so. sonic_golden_test.sh also now accepts --allow-coverage-loss and forwards it to tests.e2e.compare, so an intentional fixture removal can get a green regen without editing the script by hand. Phase 3 installs requirements.ansible.txt rather than the project's ".[ansible]" extra. The conductor import chain needs ansible-core, which the unit tests stub out in conftest.py, so a venv that runs the unit suite does not necessarily satisfy it. Installing the extra would also reinstall the project on every run, replacing an editable install with a wheel built from the checkout -- and it is not needed for currency either, since generate.py runs as python -m from the repo root and therefore imports osism from the working tree, not site-packages. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Roger Luethi <luethi@osism.tech>
ideaship
force-pushed
the
sonic-e2e-v2-compose
branch
from
August 6, 2026 12:19
a75a30d to
8b78556
Compare
ideaship
marked this pull request as ready for review
August 6, 2026 12:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the series tracked in #2562, which explains the ordering and what each PR covers. Based on the preceding PR in the stack, so review only the top commits here.
The infrastructure:
compose.yaml(Postgres, Valkey, NetBox),deploy_netbox.shto bring it up and mint an API token,
sonic_golden_test.shas the harnessentry point, and the
make sonic-e2e*targets.Two decisions worth knowing while reading it:
Only
NETBOX_PORTis interpolated into the compose file. Composere-interpolates the whole file on every subcommand, not just
up, so${VAR:?}guards would breakdown,psandlogstoo. The rest of theconfiguration lives in the container environment instead.
Seeding runs serially by default (
SEED_PARALLEL=1). Concurrent seedingdeadlocks intermittently on PostgreSQL
KEY SHARErow locks on shared parentdcim_devicerows — object disjointness says nothing about lock contention.The escape hatch is kept for anyone who wants to retry it.
The Ansible pins are installed at run time, not the
.[ansible]extra. Theconductor import chain needs
ansible-core, which the unit tests stub out inconftest.py— so a venv that passes the unit suite does not necessarilysatisfy that import. Installing the extra would also reinstall the project on
every run, replacing a developer's editable install with a wheel built from the
checkout. It is not needed for currency either:
generate.pyruns aspython -mfrom the repo root, soosismis imported from the working treerather than site-packages. Installing
requirements.ansible.txtdirectly avoidsboth, and is 1.4s rather than 8.9s when already satisfied.
Still nothing to run: the fixtures and goldens arrive in the next PR.