diff --git a/test/e2e/apimachinery/crd_watch.go b/test/e2e/apimachinery/crd_watch.go index be08b2a00b1..ecee88f5d18 100644 --- a/test/e2e/apimachinery/crd_watch.go +++ b/test/e2e/apimachinery/crd_watch.go @@ -26,6 +26,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/dynamic" "k8s.io/kubernetes/test/e2e/framework" @@ -99,6 +100,18 @@ var _ = SIGDescribe("CustomResourceDefinition Watch", func() { expectEvent(watchB, watch.Added, testCrB) expectNoEvent(watchA, watch.Added, testCrB) + ginkgo.By("Modifying first CR") + err = patchCustomResource(noxuResourceClient, watchCRNameA) + framework.ExpectNoError(err, "failed to patch custom resource: %s", watchCRNameA) + expectEvent(watchA, watch.Modified, nil) + expectNoEvent(watchB, watch.Modified, nil) + + ginkgo.By("Modifying second CR") + err = patchCustomResource(noxuResourceClient, watchCRNameB) + framework.ExpectNoError(err, "failed to patch custom resource: %s", watchCRNameB) + expectEvent(watchB, watch.Modified, nil) + expectNoEvent(watchA, watch.Modified, nil) + ginkgo.By("Deleting first CR") err = deleteCustomResource(noxuResourceClient, watchCRNameA) framework.ExpectNoError(err, "failed to delete custom resource: %s", watchCRNameA) @@ -152,6 +165,15 @@ func instantiateCustomResource(instanceToCreate *unstructured.Unstructured, clie return createdInstance, nil } +func patchCustomResource(client dynamic.ResourceInterface, name string) error { + _, err := client.Patch( + name, + types.JSONPatchType, + []byte(`[{ "op": "add", "path": "/dummy", "value": "test" }]`), + metav1.PatchOptions{}) + return err +} + func deleteCustomResource(client dynamic.ResourceInterface, name string) error { return client.Delete(name, &metav1.DeleteOptions{}) } diff --git a/test/e2e/apimachinery/custom_resource_definition.go b/test/e2e/apimachinery/custom_resource_definition.go index 11a9cd2ea3e..6be793b0ce8 100644 --- a/test/e2e/apimachinery/custom_resource_definition.go +++ b/test/e2e/apimachinery/custom_resource_definition.go @@ -37,7 +37,7 @@ import ( var _ = SIGDescribe("CustomResourceDefinition resources", func() { - f := framework.NewDefaultFramework("custom-resource-definition") + framework.NewDefaultFramework("custom-resource-definition") ginkgo.Context("Simple CustomResourceDefinition", func() { /* @@ -55,7 +55,7 @@ var _ = SIGDescribe("CustomResourceDefinition resources", func() { randomDefinition := fixtures.NewRandomNameV1CustomResourceDefinition(v1.ClusterScoped) // Create CRD and waits for the resource to be recognized and available. - randomDefinition, err = fixtures.CreateNewV1CustomResourceDefinition(randomDefinition, apiExtensionClient, f.DynamicClient) + randomDefinition, err = fixtures.CreateNewV1CustomResourceDefinitionWatchUnsafe(randomDefinition, apiExtensionClient) framework.ExpectNoError(err, "creating CustomResourceDefinition") defer func() { @@ -84,14 +84,14 @@ var _ = SIGDescribe("CustomResourceDefinition resources", func() { for i := 0; i < testListSize; i++ { crd := fixtures.NewRandomNameV1CustomResourceDefinition(v1.ClusterScoped) crd.Labels = map[string]string{"e2e-list-test-uuid": testUUID} - crd, err = fixtures.CreateNewV1CustomResourceDefinition(crd, apiExtensionClient, f.DynamicClient) + crd, err = fixtures.CreateNewV1CustomResourceDefinitionWatchUnsafe(crd, apiExtensionClient) framework.ExpectNoError(err, "creating CustomResourceDefinition") crds[i] = crd } // Create a crd w/o the label to ensure the label selector matching works correctly crd := fixtures.NewRandomNameV1CustomResourceDefinition(v1.ClusterScoped) - crd, err = fixtures.CreateNewV1CustomResourceDefinition(crd, apiExtensionClient, f.DynamicClient) + crd, err = fixtures.CreateNewV1CustomResourceDefinitionWatchUnsafe(crd, apiExtensionClient) framework.ExpectNoError(err, "creating CustomResourceDefinition") defer func() { err = fixtures.DeleteV1CustomResourceDefinition(crd, apiExtensionClient) @@ -140,7 +140,7 @@ var _ = SIGDescribe("CustomResourceDefinition resources", func() { // Create CRD and waits for the resource to be recognized and available. crd := fixtures.NewRandomNameV1CustomResourceDefinition(v1.ClusterScoped) - crd, err = fixtures.CreateNewV1CustomResourceDefinition(crd, apiExtensionClient, f.DynamicClient) + crd, err = fixtures.CreateNewV1CustomResourceDefinitionWatchUnsafe(crd, apiExtensionClient) framework.ExpectNoError(err, "creating CustomResourceDefinition") defer func() { err = fixtures.DeleteV1CustomResourceDefinition(crd, apiExtensionClient)