Repository navigation
test: Start the controller package's API servers once - #848
Merged
Merged
Conversation
The controller package started an envtest API server for nearly every test, about 180 of them, and spent over half its time on their starts and stops. The tests on NSO's and the locations CRDs now share the package's two planes, started at first use and stopped by TestMain, as kubebuilder's suite_test.go shares one environment. A plane now outlives a test, so a name a scenario takes from its test's name ends in a number no other scenario holds, also under -count, and a test deletes the cluster-scoped objects it writes. Refs #837
The test timeout went to 20 minutes and then 25 because the controller package's envtest suite outgrew Go's default of 10. With its API servers started once, the package takes under 3 minutes in CI, so the flag and its comments go, and a hung test binary is stopped after 10 minutes. Refs #837
scotwells
approved these changes
Nov 3, 2026
This was referenced Nov 5, 2026
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.
The controller package's envtest tests started an API server for nearly every test, about 180 times, and the starts and stops took over half of the package's time (#837): 1062 s locally on
mainat202bbf0a, and 1131–1170 s in the required check against its 20-minute test timeout. The package already shares two API servers, the planes, between the projection tests. Every test on the same CRDs, NSO's and the locations', now uses them: they start at first use andTestMainstops them, as kubebuilder'ssuite_test.gostarts one environment for a package. The package now takes 155–161 s locally and 164 s in CI, against 1232 s onmain, sogo testtakes Go's default timeout of 10 minutes again.Changes
TestMainmove to the package's suite file.planesalso gives each server's configsuite_test.go,networkinterface_projection_test.gostartNetworkInterfaceEnvand the network service, repoint and connector lease tests use the first planenetworkinterfaceclaim_controller_test.go,networkservice_controller_test.go,connectoradvertisement_repoint_test.go,connector_lease_watch_test.goscenarioSuffix. It cuts the name to fit and adds a number that no other scenario in the test binary holds. It replaces 16 copies ofsanitizeName(strings.ToLower(t.Name()))and the repoint tests' own counternetworkinterface_controller_test.go,subnet_controller_test.gonetworkloadbalancercellintent_controller_test.goconnector_lease_watch_test.gogo testtakes Go's default timeout again. The package outgrew it, sod063dc42raised it to 20 minutes and #845 to 25. The flag and its comments go.github/workflows/ci.yaml,MakefileCorner cases
mainthe presence scenario cuts names at 48 characters, so on one server the restart tests' subtests would get the same namespaceTestScenarioSuffixesAreUniqueAndFit-count)-count=2sharedPlanessync.OnceValueskeeps the errorNot changed
TestEnsureDownstreamGatewayHTTPRoutesStatusFitsInstalledSchemarewrites the HTTPRoute CRD during the test, andTestDownstreamClientTrafficPolicyWithoutTheKindneeds Envoy Gateway's kinds to be absent. The other eight could share a third server and save about 30 s. But the five DNS tests run a manager over the whole server, with fixed names and hostnames indefault, so that is a separate change.Test plan
maintook 1062 s.-count=2 -shuffle=on, all tests pass exceptTestHTTPProxyReconcileInternalErrorGetsStableFixedMessage. That test uses only fake clients, and it fails the same way onmainunder-shuffle(2 of 8 seeds). The HTTPProxy programming tracker'srecordedmap is global to the package and keeps a key that another test programmed.main, 43 of 43. Each touched function's complexity is the same or lower, andgolangci-lintpasses.ci / Build and testfinishes with every package inside Go's default 10 minutes. Atd5594715it took 8 min 14 s, with the controller package at 186 s, and atbb7222fc5 min 31 s with it at 164 s. Onmainit takes 24 min 27 s.Refs #837