Make routes controller tests more robust when testing with multiple tenancies (#20743)

When executing the test with multiple tenancies the various mesh controllers remained running across multiple sub-tests. While the resourcetest.Client cleans up resources created with it, resources created by the controllers were not being cleaned up. This could result in subsequent sub tests encountering unexpected values and failing when they should pass.
pull/20751/head
Matt Keeler 2024-02-28 11:03:12 -05:00 committed by GitHub
parent 90d3a7c16d
commit 1a454b7b47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 227 additions and 226 deletions

View File

@ -42,7 +42,7 @@ type testResourceRef struct {
barServiceRef *pbresource.Reference
}
func (suite *controllerSuite) SetupTest() {
func (suite *controllerSuite) SetupSubTest() {
suite.ctx = testutil.TestContext(suite.T())
suite.tenancies = rtest.TestTenancies()
@ -1349,7 +1349,7 @@ func (suite *controllerSuite) TestController() {
func (suite *controllerSuite) TestController_Failover() {
for _, tenancy := range suite.tenancies {
suite.Run(suite.appendTenancyInfo(tenancy), func() {
computedRoutesID := rtest.Resource(pbmesh.ComputedRoutesType, "api").
WithTenancy(tenancy).
ID()
@ -1608,6 +1608,7 @@ func (suite *controllerSuite) TestController_Failover() {
lastVersion = requireNewComputedRoutesVersion(t, suite.client, computedRoutesID, lastVersion, expect)
})
})
}
}