Skip to content

Commit e50fa36

Browse files
use unique name for each test (#2541)
Signed-off-by: akihikokuroda <[email protected]>
1 parent 989690f commit e50fa36

File tree

1 file changed

+39
-18
lines changed

1 file changed

+39
-18
lines changed

test/e2e/csv_e2e_test.go

+39-18
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,25 @@ var _ = Describe("ClusterServiceVersion", func() {
6565
var (
6666
ns corev1.Namespace
6767
crd apiextensionsv1.CustomResourceDefinition
68+
og operatorsv1.OperatorGroup
69+
apiname string
70+
apifullname string
6871
)
6972

7073
BeforeEach(func() {
7174
ns = corev1.Namespace{
7275
ObjectMeta: metav1.ObjectMeta{
73-
Name: "test-namespace-1",
76+
Name: genName("test-namespace-"),
7477
},
7578
}
79+
7680
Eventually(func() error {
7781
return ctx.Ctx().Client().Create(context.Background(), &ns)
7882
}).Should(Succeed())
7983

80-
og := operatorsv1.OperatorGroup{
84+
og = operatorsv1.OperatorGroup{
8185
ObjectMeta: metav1.ObjectMeta{
82-
Name: fmt.Sprintf("%s-operatorgroup", ns.GetName()),
86+
Name: genName(fmt.Sprintf("%s-operatorgroup-", ns.GetName())),
8387
Namespace: ns.GetName(),
8488
},
8589
Spec: operatorsv1.OperatorGroupSpec{
@@ -90,9 +94,11 @@ var _ = Describe("ClusterServiceVersion", func() {
9094
return ctx.Ctx().Client().Create(context.Background(), &og)
9195
}).Should(Succeed())
9296

97+
apiname = genName("api")
98+
apifullname = apiname + "s.example.com"
9399
crd = apiextensionsv1.CustomResourceDefinition{
94100
ObjectMeta: metav1.ObjectMeta{
95-
Name: "tests.example.com",
101+
Name: apifullname,
96102
Annotations: map[string]string{
97103
"operatorframework.io/installed-alongside-0": fmt.Sprintf("%s/associated-csv", ns.GetName()),
98104
},
@@ -101,10 +107,10 @@ var _ = Describe("ClusterServiceVersion", func() {
101107
Group: "example.com",
102108
Scope: apiextensionsv1.ClusterScoped,
103109
Names: apiextensionsv1.CustomResourceDefinitionNames{
104-
Plural: "tests",
105-
Singular: "test",
106-
Kind: "Test",
107-
ListKind: "TestList",
110+
Plural: apiname + "s",
111+
Singular: apiname,
112+
Kind: strings.Title(apiname),
113+
ListKind: strings.Title(apiname) + "List",
108114
},
109115
Versions: []apiextensionsv1.CustomResourceDefinitionVersion{{
110116
Name: "v1",
@@ -125,11 +131,15 @@ var _ = Describe("ClusterServiceVersion", func() {
125131

126132
AfterEach(func() {
127133
Eventually(func() error {
128-
return ctx.Ctx().Client().Delete(context.Background(), &ns)
134+
return ctx.Ctx().Client().Delete(context.Background(), &crd)
129135
}).Should(WithTransform(k8serrors.IsNotFound, BeTrue()))
130136

131137
Eventually(func() error {
132-
return ctx.Ctx().Client().Delete(context.Background(), &crd)
138+
return ctx.Ctx().Client().Delete(context.Background(), &og)
139+
}).Should(WithTransform(k8serrors.IsNotFound, BeTrue()))
140+
141+
Eventually(func() error {
142+
return ctx.Ctx().Client().Delete(context.Background(), &ns)
133143
}).Should(WithTransform(k8serrors.IsNotFound, BeTrue()))
134144
})
135145

@@ -142,7 +152,7 @@ var _ = Describe("ClusterServiceVersion", func() {
142152
Spec: operatorsv1alpha1.ClusterServiceVersionSpec{
143153
CustomResourceDefinitions: operatorsv1alpha1.CustomResourceDefinitions{
144154
Owned: []operatorsv1alpha1.CRDDescription{{
145-
Name: "tests.example.com",
155+
Name: apifullname,
146156
Version: "v1",
147157
Kind: "Test",
148158
}},
@@ -182,6 +192,10 @@ var _ = Describe("ClusterServiceVersion", func() {
182192
Status: operatorsv1alpha1.RequirementStatusReasonPresent,
183193
},
184194
))
195+
196+
Eventually(func() error {
197+
return ctx.Ctx().Client().Delete(context.Background(), &associated)
198+
}).Should(Succeed())
185199
})
186200

187201
// Without this exception, upgrades can become blocked
@@ -196,7 +210,7 @@ var _ = Describe("ClusterServiceVersion", func() {
196210
Spec: operatorsv1alpha1.ClusterServiceVersionSpec{
197211
CustomResourceDefinitions: operatorsv1alpha1.CustomResourceDefinitions{
198212
Owned: []operatorsv1alpha1.CRDDescription{{
199-
Name: "tests.example.com",
213+
Name: apifullname,
200214
Version: "v1",
201215
Kind: "Test",
202216
}},
@@ -220,7 +234,7 @@ var _ = Describe("ClusterServiceVersion", func() {
220234
Spec: operatorsv1alpha1.ClusterServiceVersionSpec{
221235
CustomResourceDefinitions: operatorsv1alpha1.CustomResourceDefinitions{
222236
Owned: []operatorsv1alpha1.CRDDescription{{
223-
Name: "tests.example.com",
237+
Name: apifullname,
224238
Version: "v1",
225239
Kind: "Test",
226240
}},
@@ -240,6 +254,10 @@ var _ = Describe("ClusterServiceVersion", func() {
240254
Eventually(func() error {
241255
return ctx.Ctx().Client().Get(context.Background(), client.ObjectKeyFromObject(&unassociated), &unassociated)
242256
}).Should(WithTransform(k8serrors.IsNotFound, BeTrue()))
257+
258+
Eventually(func() error {
259+
return ctx.Ctx().Client().Delete(context.Background(), &associated)
260+
}).Should(Succeed())
243261
})
244262

245263
It("can satisfy an unassociated ClusterServiceVersion's non-ownership requirement", func() {
@@ -251,7 +269,7 @@ var _ = Describe("ClusterServiceVersion", func() {
251269
Spec: operatorsv1alpha1.ClusterServiceVersionSpec{
252270
CustomResourceDefinitions: operatorsv1alpha1.CustomResourceDefinitions{
253271
Required: []operatorsv1alpha1.CRDDescription{{
254-
Name: "tests.example.com",
272+
Name: apifullname,
255273
Version: "v1",
256274
Kind: "Test",
257275
}},
@@ -291,6 +309,9 @@ var _ = Describe("ClusterServiceVersion", func() {
291309
Status: operatorsv1alpha1.RequirementStatusReasonPresent,
292310
},
293311
))
312+
Eventually(func() error {
313+
return ctx.Ctx().Client().Delete(context.Background(), &unassociated)
314+
}).Should(Succeed())
294315
})
295316

296317
When("an unassociated ClusterServiceVersion in different namespace owns the same CRD", func() {
@@ -301,12 +322,12 @@ var _ = Describe("ClusterServiceVersion", func() {
301322
BeforeEach(func() {
302323
ns = corev1.Namespace{
303324
ObjectMeta: metav1.ObjectMeta{
304-
Name: "test-namespace-2",
325+
Name: genName("test-namespace-2-"),
305326
},
306327
}
307328
Expect(ctx.Ctx().Client().Create(context.Background(), &ns)).To(Succeed())
308329

309-
og := operatorsv1.OperatorGroup{
330+
og = operatorsv1.OperatorGroup{
310331
ObjectMeta: metav1.ObjectMeta{
311332
Name: fmt.Sprintf("%s-operatorgroup", ns.GetName()),
312333
Namespace: ns.GetName(),
@@ -333,7 +354,7 @@ var _ = Describe("ClusterServiceVersion", func() {
333354
Spec: operatorsv1alpha1.ClusterServiceVersionSpec{
334355
CustomResourceDefinitions: operatorsv1alpha1.CustomResourceDefinitions{
335356
Owned: []operatorsv1alpha1.CRDDescription{{
336-
Name: "tests.example.com",
357+
Name: apifullname,
337358
Version: "v1",
338359
Kind: "Test",
339360
}},
@@ -357,7 +378,7 @@ var _ = Describe("ClusterServiceVersion", func() {
357378
Spec: operatorsv1alpha1.ClusterServiceVersionSpec{
358379
CustomResourceDefinitions: operatorsv1alpha1.CustomResourceDefinitions{
359380
Owned: []operatorsv1alpha1.CRDDescription{{
360-
Name: "tests.example.com",
381+
Name: apifullname,
361382
Version: "v1",
362383
Kind: "Test",
363384
}},

0 commit comments

Comments
 (0)