Skip to content

Commit

Permalink
Merge pull request #4081 from fabriziopandini/investigate-clusterresu…
Browse files Browse the repository at this point in the history
…ltset-flakes

🐛 Use a different object name for each ClusterResultSet test case
  • Loading branch information
k8s-ci-robot authored Jan 22, 2021
2 parents 23ab563 + 90dfe19 commit e851972
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions exp/addons/controllers/clusterresourceset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,23 @@ 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

var configmapName = "test-configmap"
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}}

Expand Down Expand Up @@ -99,7 +103,7 @@ metadata:

clusterResourceSetInstance := &addonsv1.ClusterResourceSet{
ObjectMeta: metav1.ObjectMeta{
Name: "test-clusterresourceset",
Name: clusterResourceSetName,
Namespace: defaultNamespaceName,
},
}
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -181,7 +185,7 @@ metadata:

clusterResourceSetInstance := &addonsv1.ClusterResourceSet{
ObjectMeta: metav1.ObjectMeta{
Name: "test-clusterresourceset",
Name: clusterResourceSetName,
Namespace: defaultNamespaceName,
},
Spec: addonsv1.ClusterResourceSetSpec{
Expand Down Expand Up @@ -243,7 +247,7 @@ metadata:

clusterResourceSetInstance := &addonsv1.ClusterResourceSet{
ObjectMeta: metav1.ObjectMeta{
Name: "test-clusterresourceset",
Name: clusterResourceSetName,
Namespace: defaultNamespaceName,
},
Spec: addonsv1.ClusterResourceSetSpec{
Expand Down Expand Up @@ -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 {
Expand All @@ -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{
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e851972

Please sign in to comment.