From de9dd82c5495b71a0271cc542e05e39fe1451489 Mon Sep 17 00:00:00 2001 From: Riaan Kleinhans Date: Fri, 18 Dec 2020 09:25:13 +1300 Subject: [PATCH] Extend APIService e2e testing of endpoints e2e test validates the following 3 extra endpoints - readApiregistrationV1APIServiceStatus - patchApiregistrationV1APIService - listApiregistrationV1APIService --- test/conformance/testdata/conformance.yaml | 2 +- test/e2e/apimachinery/aggregator.go | 47 +++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/test/conformance/testdata/conformance.yaml b/test/conformance/testdata/conformance.yaml index af99cf94677..4b182562255 100755 --- a/test/conformance/testdata/conformance.yaml +++ b/test/conformance/testdata/conformance.yaml @@ -659,7 +659,7 @@ API Server using the current Aggregator [Conformance]' description: Ensure that the sample-apiserver code from 1.17 and compiled against 1.17 will work on the current Aggregator/API-Server. - release: v1.17 + release: v1.17, v1.21 file: test/e2e/apimachinery/aggregator.go - testname: Custom Resource Definition Conversion Webhook, convert mixed version list codename: '[sig-api-machinery] CustomResourceConversionWebhook [Privileged:ClusterAdmin] diff --git a/test/e2e/apimachinery/aggregator.go b/test/e2e/apimachinery/aggregator.go index 927f35b95b9..a5afd256631 100644 --- a/test/e2e/apimachinery/aggregator.go +++ b/test/e2e/apimachinery/aggregator.go @@ -34,6 +34,7 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" unstructuredv1 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/discovery" @@ -90,7 +91,7 @@ var _ = SIGDescribe("Aggregator", func() { }) /* - Release: v1.17 + Release: v1.17, v1.21 Testname: aggregator-supports-the-sample-apiserver Description: Ensure that the sample-apiserver code from 1.17 and compiled against 1.17 will work on the current Aggregator/API-Server. @@ -99,6 +100,7 @@ var _ = SIGDescribe("Aggregator", func() { // Testing a 1.17 version of the sample-apiserver TestSampleAPIServer(f, aggrclient, imageutils.GetE2EImage(imageutils.APIServer)) }) + }) func cleanTest(client clientset.Interface, aggrclient *aggregatorclient.Clientset, namespace string) { @@ -491,6 +493,49 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl framework.Failf("failed to get back the correct flunders list %v from the dynamic client", unstructuredList) } + ginkgo.By("Read Status for v1alpha1.wardle.example.com") + statusContent, err := restClient.Get(). + AbsPath("/apis/apiregistration.k8s.io/v1/apiservices/v1alpha1.wardle.example.com/status"). + SetHeader("Accept", "application/json").DoRaw(context.TODO()) + framework.ExpectNoError(err, "No response for .../apiservices/v1alpha1.wardle.example.com/status. Error: %v", err) + + var jr *apiregistrationv1.APIService + err = json.Unmarshal([]byte(statusContent), &jr) + framework.ExpectNoError(err, "Failed to process statusContent: %v | err: %v ", string(statusContent), err) + framework.ExpectEqual(jr.Status.Conditions[0].Message, "all checks passed", "The Message returned was %v", jr.Status.Conditions[0].Message) + + ginkgo.By("kubectl patch apiservice v1alpha1.wardle.example.com -p '{\"spec\":{\"versionPriority\": 400}}'") + patchContent, err := restClient.Patch(types.MergePatchType). + AbsPath("/apis/apiregistration.k8s.io/v1/apiservices/v1alpha1.wardle.example.com"). + SetHeader("Accept", "application/json"). + Body([]byte(`{"spec":{"versionPriority": 400}}`)).DoRaw(context.TODO()) + + framework.ExpectNoError(err, "Patch failed for .../apiservices/v1alpha1.wardle.example.com. Error: %v", err) + err = json.Unmarshal([]byte(patchContent), &jr) + framework.ExpectNoError(err, "Failed to process patchContent: %v | err: %v ", string(patchContent), err) + framework.ExpectEqual(jr.Spec.VersionPriority, int32(400), "The VersionPriority returned was %d", jr.Spec.VersionPriority) + + ginkgo.By("List APIServices") + listApiservices, err := restClient.Get(). + AbsPath("/apis/apiregistration.k8s.io/v1/apiservices"). + SetHeader("Accept", "application/json").DoRaw(context.TODO()) + + framework.ExpectNoError(err, "No response for /apis/apiregistration.k8s.io/v1/apiservices Error: %v", err) + + var list *apiregistrationv1.APIServiceList + err = json.Unmarshal([]byte(listApiservices), &list) + framework.ExpectNoError(err, "Failed to process APIServiceList: %v | err: %v ", list, err) + + locatedWardle := false + for _, item := range list.Items { + if item.Name == "v1alpha1.wardle.example.com" { + framework.Logf("Found v1alpha1.wardle.example.com in APIServiceList") + locatedWardle = true + break + } + } + framework.ExpectEqual(locatedWardle, true, "Unable to find v1alpha1.wardle.example.com in APIServiceList") + // kubectl delete flunder test-flunder err = dynamicClient.Delete(context.TODO(), flunderName, metav1.DeleteOptions{}) validateErrorWithDebugInfo(f, err, pods, "deleting flunders(%v) using dynamic client", unstructuredList.Items)