From 06346de0bbf58ad862b4ec6ec0bc197e8b2527ae Mon Sep 17 00:00:00 2001 From: Stephen Heywood Date: Mon, 15 Aug 2022 10:14:33 +1200 Subject: [PATCH] Create e2e test for endpoint: replaceCoreV1Namespace --- test/e2e/apimachinery/namespace.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/e2e/apimachinery/namespace.go b/test/e2e/apimachinery/namespace.go index 76ab40bd25b..6c2c6894616 100644 --- a/test/e2e/apimachinery/namespace.go +++ b/test/e2e/apimachinery/namespace.go @@ -355,6 +355,26 @@ var _ = SIGDescribe("Namespaces [Serial]", func() { framework.ExpectEqual(statusUpdated.Status.Conditions[len(statusUpdated.Status.Conditions)-1].Message, "Updated by an e2e test", "The Message returned was %v", statusUpdated.Status.Conditions[0].Message) framework.Logf("Status.Condition: %#v", statusUpdated.Status.Conditions[len(statusUpdated.Status.Conditions)-1]) }) + + ginkgo.It("should apply an update to a Namespace", func() { + var err error + var updatedNamespace *v1.Namespace + ns := f.Namespace.Name + cs := f.ClientSet + + ginkgo.By(fmt.Sprintf("Updating Namespace %q", ns)) + err = retry.RetryOnConflict(retry.DefaultRetry, func() error { + updatedNamespace, err = cs.CoreV1().Namespaces().Get(context.TODO(), ns, metav1.GetOptions{}) + framework.ExpectNoError(err, "Unable to get Namespace %q", ns) + + updatedNamespace.Labels[ns] = "updated" + updatedNamespace, err = cs.CoreV1().Namespaces().Update(context.TODO(), updatedNamespace, metav1.UpdateOptions{}) + return err + }) + framework.ExpectNoError(err, "failed to update Namespace: %q", ns) + framework.ExpectEqual(updatedNamespace.ObjectMeta.Labels[ns], "updated", "Failed to update namespace %q. Current Labels: %#v", ns, updatedNamespace.Labels) + framework.Logf("Namespace %q now has labels, %#v", ns, updatedNamespace.Labels) + }) }) func unstructuredToNamespace(obj *unstructured.Unstructured) (*v1.Namespace, error) {