From 90dfe193d044d31cdfaa5edc6df4baefd96061ec Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Tue, 19 Jan 2021 16:58:51 +0100 Subject: [PATCH] use different CRS for each test --- .../clusterresourceset_controller_test.go | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/exp/addons/controllers/clusterresourceset_controller_test.go b/exp/addons/controllers/clusterresourceset_controller_test.go index 48442d6fc6bd..d86ac91c8e84 100644 --- a/exp/addons/controllers/clusterresourceset_controller_test.go +++ b/exp/addons/controllers/clusterresourceset_controller_test.go @@ -34,12 +34,14 @@ import ( ) const ( - timeout = time.Second * 20 + timeout = time.Second * 10 defaultNamespaceName = "default" ) var _ = Describe("ClusterResourceSet Reconciler", func() { + var clusterResourceSetName string + var testCluster *clusterv1.Cluster var clusterName string @@ -47,6 +49,8 @@ var _ = Describe("ClusterResourceSet Reconciler", func() { var configmap2Name = "test-configmap2" BeforeEach(func() { + clusterResourceSetName = fmt.Sprintf("clusterresourceset-%s", util.RandomString(6)) + clusterName = fmt.Sprintf("cluster-%s", util.RandomString(6)) testCluster = &clusterv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: clusterName, Namespace: defaultNamespaceName}} @@ -99,7 +103,7 @@ metadata: clusterResourceSetInstance := &addonsv1.ClusterResourceSet{ ObjectMeta: metav1.ObjectMeta{ - Name: "test-clusterresourceset", + Name: clusterResourceSetName, Namespace: defaultNamespaceName, }, } @@ -129,7 +133,7 @@ metadata: By("Creating a ClusterResourceSet instance that has same labels as selector") clusterResourceSetInstance := &addonsv1.ClusterResourceSet{ ObjectMeta: metav1.ObjectMeta{ - Name: "test-clusterresourceset", + Name: clusterResourceSetName, Namespace: defaultNamespaceName, }, Spec: addonsv1.ClusterResourceSetSpec{ @@ -181,7 +185,7 @@ metadata: clusterResourceSetInstance := &addonsv1.ClusterResourceSet{ ObjectMeta: metav1.ObjectMeta{ - Name: "test-clusterresourceset", + Name: clusterResourceSetName, Namespace: defaultNamespaceName, }, Spec: addonsv1.ClusterResourceSetSpec{ @@ -243,7 +247,7 @@ metadata: clusterResourceSetInstance := &addonsv1.ClusterResourceSet{ ObjectMeta: metav1.ObjectMeta{ - Name: "test-clusterresourceset", + Name: clusterResourceSetName, Namespace: defaultNamespaceName, }, Spec: addonsv1.ClusterResourceSetSpec{ @@ -293,6 +297,15 @@ metadata: Data: map[string]string{}, } Expect(testEnv.Create(ctx, testConfigmap)).To(Succeed()) + cmKey := client.ObjectKey{ + Namespace: defaultNamespaceName, + Name: newCMName, + } + Eventually(func() bool { + m := &corev1.ConfigMap{} + err := testEnv.Get(ctx, cmKey, m) + return err == nil + }, timeout).Should(BeTrue()) // When the ConfigMap resource is created, CRS should get reconciled immediately. Eventually(func() bool { @@ -317,7 +330,7 @@ metadata: By("Creating a ClusterResourceSet instance that has same labels as selector") clusterResourceSetInstance2 := &addonsv1.ClusterResourceSet{ ObjectMeta: metav1.ObjectMeta{ - Name: "test-clusterresourceset", + Name: clusterResourceSetName, Namespace: defaultNamespaceName, }, Spec: addonsv1.ClusterResourceSetSpec{ @@ -396,7 +409,7 @@ metadata: labels := map[string]string{"foo": "bar"} clusterResourceSetInstance := &addonsv1.ClusterResourceSet{ ObjectMeta: metav1.ObjectMeta{ - Name: "test-clusterresourceset", + Name: clusterResourceSetName, Namespace: defaultNamespaceName, Finalizers: []string{addonsv1.ClusterResourceSetFinalizer}, DeletionTimestamp: &dt,