@@ -65,21 +65,25 @@ var _ = Describe("ClusterServiceVersion", func() {
65
65
var (
66
66
ns corev1.Namespace
67
67
crd apiextensionsv1.CustomResourceDefinition
68
+ og operatorsv1.OperatorGroup
69
+ apiname string
70
+ apifullname string
68
71
)
69
72
70
73
BeforeEach (func () {
71
74
ns = corev1.Namespace {
72
75
ObjectMeta : metav1.ObjectMeta {
73
- Name : "test-namespace-1" ,
76
+ Name : genName ( "test-namespace-" ) ,
74
77
},
75
78
}
79
+
76
80
Eventually (func () error {
77
81
return ctx .Ctx ().Client ().Create (context .Background (), & ns )
78
82
}).Should (Succeed ())
79
83
80
- og : = operatorsv1.OperatorGroup {
84
+ og = operatorsv1.OperatorGroup {
81
85
ObjectMeta : metav1.ObjectMeta {
82
- Name : fmt .Sprintf ("%s-operatorgroup" , ns .GetName ()),
86
+ Name : genName ( fmt .Sprintf ("%s-operatorgroup- " , ns .GetName () )),
83
87
Namespace : ns .GetName (),
84
88
},
85
89
Spec : operatorsv1.OperatorGroupSpec {
@@ -90,9 +94,11 @@ var _ = Describe("ClusterServiceVersion", func() {
90
94
return ctx .Ctx ().Client ().Create (context .Background (), & og )
91
95
}).Should (Succeed ())
92
96
97
+ apiname = genName ("api" )
98
+ apifullname = apiname + "s.example.com"
93
99
crd = apiextensionsv1.CustomResourceDefinition {
94
100
ObjectMeta : metav1.ObjectMeta {
95
- Name : "tests.example.com" ,
101
+ Name : apifullname ,
96
102
Annotations : map [string ]string {
97
103
"operatorframework.io/installed-alongside-0" : fmt .Sprintf ("%s/associated-csv" , ns .GetName ()),
98
104
},
@@ -101,10 +107,10 @@ var _ = Describe("ClusterServiceVersion", func() {
101
107
Group : "example.com" ,
102
108
Scope : apiextensionsv1 .ClusterScoped ,
103
109
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 " ,
108
114
},
109
115
Versions : []apiextensionsv1.CustomResourceDefinitionVersion {{
110
116
Name : "v1" ,
@@ -125,11 +131,15 @@ var _ = Describe("ClusterServiceVersion", func() {
125
131
126
132
AfterEach (func () {
127
133
Eventually (func () error {
128
- return ctx .Ctx ().Client ().Delete (context .Background (), & ns )
134
+ return ctx .Ctx ().Client ().Delete (context .Background (), & crd )
129
135
}).Should (WithTransform (k8serrors .IsNotFound , BeTrue ()))
130
136
131
137
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 )
133
143
}).Should (WithTransform (k8serrors .IsNotFound , BeTrue ()))
134
144
})
135
145
@@ -142,7 +152,7 @@ var _ = Describe("ClusterServiceVersion", func() {
142
152
Spec : operatorsv1alpha1.ClusterServiceVersionSpec {
143
153
CustomResourceDefinitions : operatorsv1alpha1.CustomResourceDefinitions {
144
154
Owned : []operatorsv1alpha1.CRDDescription {{
145
- Name : "tests.example.com" ,
155
+ Name : apifullname ,
146
156
Version : "v1" ,
147
157
Kind : "Test" ,
148
158
}},
@@ -182,6 +192,10 @@ var _ = Describe("ClusterServiceVersion", func() {
182
192
Status : operatorsv1alpha1 .RequirementStatusReasonPresent ,
183
193
},
184
194
))
195
+
196
+ Eventually (func () error {
197
+ return ctx .Ctx ().Client ().Delete (context .Background (), & associated )
198
+ }).Should (Succeed ())
185
199
})
186
200
187
201
// Without this exception, upgrades can become blocked
@@ -196,7 +210,7 @@ var _ = Describe("ClusterServiceVersion", func() {
196
210
Spec : operatorsv1alpha1.ClusterServiceVersionSpec {
197
211
CustomResourceDefinitions : operatorsv1alpha1.CustomResourceDefinitions {
198
212
Owned : []operatorsv1alpha1.CRDDescription {{
199
- Name : "tests.example.com" ,
213
+ Name : apifullname ,
200
214
Version : "v1" ,
201
215
Kind : "Test" ,
202
216
}},
@@ -220,7 +234,7 @@ var _ = Describe("ClusterServiceVersion", func() {
220
234
Spec : operatorsv1alpha1.ClusterServiceVersionSpec {
221
235
CustomResourceDefinitions : operatorsv1alpha1.CustomResourceDefinitions {
222
236
Owned : []operatorsv1alpha1.CRDDescription {{
223
- Name : "tests.example.com" ,
237
+ Name : apifullname ,
224
238
Version : "v1" ,
225
239
Kind : "Test" ,
226
240
}},
@@ -240,6 +254,10 @@ var _ = Describe("ClusterServiceVersion", func() {
240
254
Eventually (func () error {
241
255
return ctx .Ctx ().Client ().Get (context .Background (), client .ObjectKeyFromObject (& unassociated ), & unassociated )
242
256
}).Should (WithTransform (k8serrors .IsNotFound , BeTrue ()))
257
+
258
+ Eventually (func () error {
259
+ return ctx .Ctx ().Client ().Delete (context .Background (), & associated )
260
+ }).Should (Succeed ())
243
261
})
244
262
245
263
It ("can satisfy an unassociated ClusterServiceVersion's non-ownership requirement" , func () {
@@ -251,7 +269,7 @@ var _ = Describe("ClusterServiceVersion", func() {
251
269
Spec : operatorsv1alpha1.ClusterServiceVersionSpec {
252
270
CustomResourceDefinitions : operatorsv1alpha1.CustomResourceDefinitions {
253
271
Required : []operatorsv1alpha1.CRDDescription {{
254
- Name : "tests.example.com" ,
272
+ Name : apifullname ,
255
273
Version : "v1" ,
256
274
Kind : "Test" ,
257
275
}},
@@ -291,6 +309,9 @@ var _ = Describe("ClusterServiceVersion", func() {
291
309
Status : operatorsv1alpha1 .RequirementStatusReasonPresent ,
292
310
},
293
311
))
312
+ Eventually (func () error {
313
+ return ctx .Ctx ().Client ().Delete (context .Background (), & unassociated )
314
+ }).Should (Succeed ())
294
315
})
295
316
296
317
When ("an unassociated ClusterServiceVersion in different namespace owns the same CRD" , func () {
@@ -301,12 +322,12 @@ var _ = Describe("ClusterServiceVersion", func() {
301
322
BeforeEach (func () {
302
323
ns = corev1.Namespace {
303
324
ObjectMeta : metav1.ObjectMeta {
304
- Name : "test-namespace-2" ,
325
+ Name : genName ( "test-namespace-2-" ) ,
305
326
},
306
327
}
307
328
Expect (ctx .Ctx ().Client ().Create (context .Background (), & ns )).To (Succeed ())
308
329
309
- og : = operatorsv1.OperatorGroup {
330
+ og = operatorsv1.OperatorGroup {
310
331
ObjectMeta : metav1.ObjectMeta {
311
332
Name : fmt .Sprintf ("%s-operatorgroup" , ns .GetName ()),
312
333
Namespace : ns .GetName (),
@@ -333,7 +354,7 @@ var _ = Describe("ClusterServiceVersion", func() {
333
354
Spec : operatorsv1alpha1.ClusterServiceVersionSpec {
334
355
CustomResourceDefinitions : operatorsv1alpha1.CustomResourceDefinitions {
335
356
Owned : []operatorsv1alpha1.CRDDescription {{
336
- Name : "tests.example.com" ,
357
+ Name : apifullname ,
337
358
Version : "v1" ,
338
359
Kind : "Test" ,
339
360
}},
@@ -357,7 +378,7 @@ var _ = Describe("ClusterServiceVersion", func() {
357
378
Spec : operatorsv1alpha1.ClusterServiceVersionSpec {
358
379
CustomResourceDefinitions : operatorsv1alpha1.CustomResourceDefinitions {
359
380
Owned : []operatorsv1alpha1.CRDDescription {{
360
- Name : "tests.example.com" ,
381
+ Name : apifullname ,
361
382
Version : "v1" ,
362
383
Kind : "Test" ,
363
384
}},
0 commit comments