Update e2e tests#400
Closed
nikatza wants to merge 24 commits into
Closed
Conversation
9393d5b to
2e3e8bb
Compare
envtest and fake gNMI server
ad16ab5 to
d46ae90
Compare
envtest and fake gNMI servere2e tests
c3069ef to
e6a30bf
Compare
Integration tests validate the full reconciliation pipeline from Kubernetes CRD to gNMI JSON output. Uses envtest with an in-process gNMI server that accumulates state, allowing tests to run in seconds without real network infrastructure. Tests auto-discover from testdata/<provider>/ directories, enabling multi-provider coverage. Each test uses txtar format: K8s YAML resources followed by expected gNMI JSON state. Resources are created sequentially, waiting for readiness conditions before proceeding to handle dependencies between resources. JSON comparison uses normalizeJSON() to sort arrays recursively, avoiding flaky tests from non-deterministic field ordering in gNMI responses. Cleanup removes finalizers in two passes before deletion. This prevents controllers from re-reconciling during teardown, which would cause conflicts with the test's expected clean state. Add WithBindAddress option to allow binding to 0.0.0.0 for container deployments. The server defaults to 127.0.0.1 for safe in-process tests, but when running as a standalone server in a pod, it needs to listen on all interfaces. Signed-off-by: Pujol <enric.pujol@sap.com>
Explain test architecture, txtar format, and how to add new tests. Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Tests three interface types: Loopback, Physical L3 with BFD, Aggregate L2 with vPC. Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
OSPF and PIM require interfaces to be configured first. Test files include the interface dependency. Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Tests BGP router + peer configuration with loopback interface and BGPConfig. Resources packed together since BGPPeer requires BGP to exist first. Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
Signed-off-by: Pujol <enric.pujol@sap.com>
e6a30bf to
7390aa7
Compare
Merging this branch will not change overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
Contributor
Author
|
Closing this PR as it is replaced by smaller ones. |
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.
E2e tests update
Update tests to validate the full reconciliation pipeline from Kubernetes CRD to gNMI JSON output.
Rationale
Unit tests verify individual functions but miss the gaps between layers: CRD validation, controller logic, provider field mapping, and gNMI path construction. For example, a controller passing the wrong value to a provider.
The current e2e tests cover this but rely on Kind clusters with a full operator installation. This PR refactors both test modes to share the same testdata-driven approach:
Test Format
Each test is a txtar file in
test/e2e/testdata/<provider>/:Resources are created sequentially, waiting for
Configured(orReadyif the former does not exist) condition before proceeding. This handles dependencies between resources (e.g., BGPPeer requires BGP).Usage
Key Changes
TestEnvironmentinterface intestutil/— both modes implement the same contracttest/e2e/testdata/<provider>/*.txtPreloadGNMIState()for setting initial device state before reconciliationstate/preloadtxtar section for tests that need pre-existing gNMI state