@@ -37,6 +37,7 @@ import (
37
37
"k8s.io/apimachinery/pkg/runtime/schema"
38
38
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
39
39
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
40
+ "k8s.io/apimachinery/pkg/util/sets"
40
41
discoveryendpoint "k8s.io/apiserver/pkg/endpoints/discovery/aggregated"
41
42
genericfeatures "k8s.io/apiserver/pkg/features"
42
43
utilfeature "k8s.io/apiserver/pkg/util/feature"
@@ -241,21 +242,27 @@ func TestAggregatedAPIServiceDiscovery(t *testing.T) {
241
242
242
243
// For each groupversion served by our resourcemanager, create an APIService
243
244
// object connected to our fake APIServer
245
+ var groupVersions []metav1.GroupVersion
244
246
for _ , versionInfo := range basicTestGroup .Versions {
245
247
groupVersion := metav1.GroupVersion {
246
248
Group : basicTestGroup .Name ,
247
249
Version : versionInfo .Version ,
248
250
}
249
251
250
252
require .NoError (t , registerAPIService (ctx , client , groupVersion , service ))
251
- defer func () {
252
- require .NoError (t , unregisterAPIService (ctx , client , groupVersion ))
253
- }()
253
+ groupVersions = append (groupVersions , groupVersion )
254
254
}
255
255
256
256
// Keep repeatedly fetching document from aggregator.
257
257
// Check to see if it contains our service within a reasonable amount of time
258
258
require .NoError (t , WaitForGroups (ctx , client , basicTestGroupWithFixup ))
259
+ require .NoError (t , WaitForRootPaths (t , ctx , client , sets .NewString ("/apis/" + basicTestGroup .Name ), nil ))
260
+
261
+ // Unregister and ensure the group gets dropped from root paths
262
+ for _ , groupVersion := range groupVersions {
263
+ require .NoError (t , unregisterAPIService (ctx , client , groupVersion ))
264
+ }
265
+ require .NoError (t , WaitForRootPaths (t , ctx , client , nil , sets .NewString ("/apis/" + basicTestGroup .Name )))
259
266
}
260
267
261
268
func runTestCases (t * testing.T , cases []testCase ) {
0 commit comments