Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Use a different object name for each ClusterResultSet test case #4081

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Comment on lines -102 to +106
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use generate name instead?

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