@@ -52,6 +52,7 @@ import (
52
52
admissionapi "k8s.io/pod-security-admission/api"
53
53
samplev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1"
54
54
"k8s.io/utils/pointer"
55
+ "k8s.io/utils/strings/slices"
55
56
56
57
"github.com/onsi/ginkgo/v2"
57
58
"github.com/onsi/gomega"
@@ -560,7 +561,6 @@ func TestSampleAPIServer(ctx context.Context, f *framework.Framework, aggrclient
560
561
ginkgo .By ("Adding a label to the APIService" )
561
562
apiServiceClient := aggrclient .ApiregistrationV1 ().APIServices ()
562
563
apiServiceLabel := map [string ]string {"e2e-apiservice" : "patched" }
563
- apiServiceLabelSelector := labels .SelectorFromSet (apiServiceLabel ).String ()
564
564
apiServicePatch , err := json .Marshal (map [string ]interface {}{
565
565
"metadata" : map [string ]interface {}{
566
566
"labels" : apiServiceLabel ,
@@ -641,7 +641,7 @@ func TestSampleAPIServer(ctx context.Context, f *framework.Framework, aggrclient
641
641
framework .Logf ("Found updated apiService label for %q" , apiServiceName )
642
642
643
643
// kubectl delete flunder test-flunder
644
- ginkgo .By (fmt .Sprintf ("Delete APIService %q" , flunderName ))
644
+ ginkgo .By (fmt .Sprintf ("Delete flunders resource %q" , flunderName ))
645
645
err = dynamicClient .Delete (ctx , flunderName , metav1.DeleteOptions {})
646
646
validateErrorWithDebugInfo (ctx , f , err , pods , "deleting flunders(%v) using dynamic client" , unstructuredList .Items )
647
647
@@ -724,6 +724,7 @@ func TestSampleAPIServer(ctx context.Context, f *framework.Framework, aggrclient
724
724
}
725
725
framework .Logf ("Found patched status condition for %s" , wardle .ObjectMeta .Name )
726
726
727
+ apiServiceLabelSelector := labels .SelectorFromSet (updatedApiService .Labels ).String ()
727
728
ginkgo .By (fmt .Sprintf ("APIService deleteCollection with labelSelector: %q" , apiServiceLabelSelector ))
728
729
729
730
err = aggrclient .ApiregistrationV1 ().APIServices ().DeleteCollection (ctx ,
@@ -736,6 +737,24 @@ func TestSampleAPIServer(ctx context.Context, f *framework.Framework, aggrclient
736
737
framework .ExpectNoError (err , "failed to count the required APIServices" )
737
738
framework .Logf ("APIService %s has been deleted." , apiServiceName )
738
739
740
+ ginkgo .By ("Confirm that the group path of " + apiServiceName + " was removed from root paths" )
741
+ groupPath := "/apis/" + apiServiceGroupName
742
+ err = wait .PollUntilContextTimeout (ctx , apiServiceRetryPeriod , apiServiceRetryTimeout , true , func (ctx context.Context ) (done bool , err error ) {
743
+ rootPaths := metav1.RootPaths {}
744
+ statusContent , err = restClient .Get ().
745
+ AbsPath ("/" ).
746
+ SetHeader ("Accept" , "application/json" ).DoRaw (ctx )
747
+ if err != nil {
748
+ return false , err
749
+ }
750
+ err = json .Unmarshal (statusContent , & rootPaths )
751
+ if err != nil {
752
+ return false , err
753
+ }
754
+ return ! slices .Contains (rootPaths .Paths , groupPath ), nil
755
+ })
756
+ framework .ExpectNoError (err , "Expected to not find %s from root paths" , groupPath )
757
+
739
758
cleanupSampleAPIServer (ctx , client , aggrclient , n , apiServiceName )
740
759
}
741
760
0 commit comments