test: expand unit test coverage for untested controllers#312
Open
test: expand unit test coverage for untested controllers#312
Conversation
Add unit tests for controllers that previously had zero test coverage: - followerchannel: validation tests (6 cases) - console: validation + GetConfig mapping tests (10 cases) - chaincode/install: CCAAS package generation tests (3 cases) - chaincode/deploy: resource naming tests (8 cases) - mainchannel: validation tests (10 cases) with ConfigValidator refactor Extend existing CA controller tests with regression tests for issue #214: - TestGetDNSNames: DNS name extraction from mixed host/IP lists (6 cases) - TestGetIPAddresses: IP extraction with localhost always included (5 cases) - TestDoesCertNeedsToBeRenewed: certificate renewal detection (6 cases) Total: 54 new test cases across 7 files. All tests pass with `go test ./controllers/... -short`. Signed-off-by: David Viejo <dviejo@kungfusoftware.es>
6184890 to
cd1bd43
Compare
…n suite Add defer GinkgoRecover() to the manager start goroutine so Ginkgo reports the actual error instead of panicking the entire test process. Disable the metrics server in tests (BindAddress: "0") to prevent port 8080 conflicts when another process is already listening. Signed-off-by: David Viejo <dviejo@kungfusoftware.es>
Signed-off-by: David Viejo <dviejo@kungfusoftware.es>
…lowerchannel Register mainchannel, followerchannel, and chaincode (install/approve/commit) reconcilers in the integration test suite so they are active during CI runs. Add a full channel lifecycle integration test that: 1. Creates two CAs (orderer org + peer org) 2. Enrolls admin identities and stores them in Kubernetes Secrets 3. Creates an orderer node and a peer, waits for RunningStatus 4. Creates a FabricMainChannel with etcdraft consensus 5. Creates a FabricFollowerChannel to join the peer to the channel 6. Verifies the peer has joined the channel via Fabric SDK Signed-off-by: David Viejo <dviejo@kungfusoftware.es>
…cle test The mainchannel controller expects identity secrets to contain YAML-encoded structs with nested cert.pem and key.pem fields, not raw PEM values at the secret key level. Signed-off-by: David Viejo <dviejo@kungfusoftware.es>
…work) The channel lifecycle test fails because the mainchannel controller connects to the orderer admin port via NodePort from the test process. In the CI KIND cluster, this connection is refused because the orderer admin service isn't reachable via NodePort from the host. Keep the reconciler registrations in suite_test.go so the controllers are active during existing integration tests. The unit tests for mainchannel/followerchannel validation remain. Signed-off-by: David Viejo <dviejo@kungfusoftware.es>
Add the channel lifecycle integration test back with fixes: - Use TLSCACert (root CA) instead of TlsCert (leaf) for peer org - Use YAML-encoded identity struct format for admin secrets - Full lifecycle: CA → Orderer + Peer → MainChannel → FollowerChannel Locally validated on k3d: existing CA/peer/orderer tests pass when run inside Docker on the k3d network. The channel lifecycle test needs a clean cluster without stale Helm releases. Signed-off-by: David Viejo <dviejo@kungfusoftware.es>
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.
Summary
ConfigValidatorin the mainchannel controller (same pattern used by CA, peer, and ordnode controllers)New test files
followerchannel_controller_test.goTestValidateFollowerChannelConfigconsole_controller_test.goTestValidateConsoleConfig,TestGetConfigchaincode_install_controller_test.goTestGenerateChaincodePackage,TestGenerateChaincodePackageEdgeCaseschaincode_deploy_controller_test.goTestResourceNaming,TestResourceNamingConsistency, etc.mainchannel_controller_test.goTestValidateMainChannelConfigExtended test files
ca_dns_ip_test.goTestGetDNSNames,TestGetIPAddresses,TestDoesCertNeedsToBeRenewedIssue coverage
Test plan
go test ./controllers/... -short -count=1— all unit tests passgo vet ./controllers/...— clean