diff --git a/test/e2e/apimachinery/OWNERS b/test/e2e/apimachinery/OWNERS new file mode 100644 index 00000000000..aca480c9f5b --- /dev/null +++ b/test/e2e/apimachinery/OWNERS @@ -0,0 +1,27 @@ +# See the OWNERS docs at https://go.k8s.io/owners + +approvers: +- lavalamp +- smarterclayton +- deads2k +- sttts +- liggitt +- caesarxuchao +reviewers: +- thockin +- lavalamp +- smarterclayton +- wojtek-t +- deads2k +- derekwaynecarr +- caesarxuchao +- cheftako +- mikedanese +- liggitt +- gmarek +- sttts +- ncdc +- logicalhan +- tallclair +labels: +- sig/api-machinery \ No newline at end of file diff --git a/test/e2e/apimachinery/namespace.go b/test/e2e/apimachinery/namespace.go index f77c2f1f47f..ba66c385c0f 100644 --- a/test/e2e/apimachinery/namespace.go +++ b/test/e2e/apimachinery/namespace.go @@ -17,6 +17,7 @@ limitations under the License. package apimachinery import ( + "encoding/json" "fmt" "strings" "sync" @@ -26,12 +27,14 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/apimachinery/pkg/util/uuid" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/kubernetes/test/e2e/framework" e2epod "k8s.io/kubernetes/test/e2e/framework/pod" imageutils "k8s.io/kubernetes/test/utils/image" "github.com/onsi/ginkgo" + "k8s.io/apimachinery/pkg/types" ) func extinguish(f *framework.Framework, totalNS int, maxAllowedAfterDel int, maxSeconds int) { @@ -246,4 +249,27 @@ var _ = SIGDescribe("Namespaces [Serial]", func() { ginkgo.It("should always delete fast (ALL of 100 namespaces in 150 seconds) [Feature:ComprehensiveNamespaceDraining]", func() { extinguish(f, 100, 0, 150) }) + ginkgo.It("should patch a Namespace", func() { + ginkgo.By("creating a Namespace") + namespaceName := "nspatchtest-" + string(uuid.NewUUID()) + ns, err := f.CreateNamespace(namespaceName, nil) + framework.ExpectNoError(err, "failed creating Namespace") + namespaceName = ns.ObjectMeta.Name + + ginkgo.By("patching the Namespace") + nspatch, err := json.Marshal(map[string]interface{}{ + "metadata": map[string]interface{}{ + "labels": map[string]string{"testLabel": "testValue"}, + }, + }) + framework.ExpectNoError(err, "failed to marshal JSON patch data") + _, err = f.ClientSet.CoreV1().Namespaces().Patch(namespaceName, types.StrategicMergePatchType, []byte(nspatch)) + framework.ExpectNoError(err, "failed to patch Namespace") + + ginkgo.By("get the Namespace and ensuring it has the label") + namespace, err := f.ClientSet.CoreV1().Namespaces().Get(namespaceName, metav1.GetOptions{}) + framework.ExpectNoError(err, "failed to get Namespace") + framework.ExpectEqual(namespace.ObjectMeta.Labels["testLabel"], "testValue", "namespace not patched") + }) + })