This repository has been archived by the owner on Sep 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
/
olm.go
653 lines (570 loc) · 24.6 KB
/
olm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
package operators
import (
"fmt"
"os/exec"
"regexp"
g "github.com/onsi/ginkgo"
o "github.com/onsi/gomega"
"path/filepath"
"strings"
"time"
exutil "github.com/openshift/openshift-tests/test/extended/util"
"k8s.io/apimachinery/pkg/util/wait"
e2e "k8s.io/kubernetes/test/e2e/framework"
)
var _ = g.Describe("[sig-operators] OLM should", func() {
defer g.GinkgoRecover()
var oc = exutil.NewCLIWithoutNamespace("default")
operators := "operators.coreos.com"
providedAPIs := []struct {
fromAPIService bool
group string
version string
plural string
}{
{
fromAPIService: true,
group: "packages." + operators,
version: "v1",
plural: "packagemanifests",
},
{
group: operators,
version: "v1",
plural: "operatorgroups",
},
{
group: operators,
version: "v1alpha1",
plural: "clusterserviceversions",
},
{
group: operators,
version: "v1alpha1",
plural: "catalogsources",
},
{
group: operators,
version: "v1alpha1",
plural: "installplans",
},
{
group: operators,
version: "v1alpha1",
plural: "subscriptions",
},
}
for i := range providedAPIs {
api := providedAPIs[i]
g.It(fmt.Sprintf("Author:jiazha-High-36803-OLM is installed with %s at version %s", api.plural, api.version), func() {
if api.fromAPIService {
// Ensure spec.version matches expected
raw, err := oc.AsAdmin().Run("get").Args("apiservices", fmt.Sprintf("%s.%s", api.version, api.group), "-o=jsonpath={.spec.version}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(raw).To(o.Equal(api.version))
} else {
// Ensure expected version exists in spec.versions and is both served and stored
raw, err := oc.AsAdmin().Run("get").Args("crds", fmt.Sprintf("%s.%s", api.plural, api.group), fmt.Sprintf("-o=jsonpath={.spec.versions[?(@.name==\"%s\")]}", api.version)).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(raw).To(o.ContainSubstring("\"served\":true"))
o.Expect(raw).To(o.ContainSubstring("\"storage\":true"))
}
})
}
// author: [email protected]
g.It("Author:bandrade-High-24061-have imagePullPolicy:IfNotPresent on thier deployments", func() {
deploymentResource := []string{"catalog-operator", "olm-operator", "packageserver"}
for _, v := range deploymentResource {
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("-n", "openshift-operator-lifecycle-manager", "deployment", v, "-o=jsonpath={.spec.template.spec.containers[*].imagePullPolicy}").Output()
e2e.Logf("%s.imagePullPolicy:%s", v, msg)
if err != nil {
e2e.Failf("Unable to get %s, error:%v", msg, err)
}
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.Equal("IfNotPresent"))
}
})
// author: [email protected]
g.It("Author:bandrade-High-24829-Report Upgradeable in OLM ClusterOperators status [Serial]", func() {
olmCOs := []string{"operator-lifecycle-manager", "operator-lifecycle-manager-catalog", "operator-lifecycle-manager-packageserver"}
for _, co := range olmCOs {
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("co", co, "-o=jsonpath={range .status.conditions[*]}{.type}{' '}{.status}").Output()
if err != nil {
e2e.Failf("Unable to get co %s status, error:%v", msg, err)
}
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).To(o.ContainSubstring("Upgradeable True"))
}
})
// author: [email protected]
g.It("Author:tbuskey-High-27589-do not use ipv4 addresses in CatalogSources generated by marketplace", func() {
re := regexp.MustCompile(`(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}`)
olmErrs := 0
olmNames := []string{""}
olmNamespace := "openshift-marketplace"
olmJpath := "-o=jsonpath={range .items[*]}{@.metadata.name}{','}{@.spec.address}{'\\n'}"
msg, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("catalogsource", "-n", olmNamespace, olmJpath).Output()
if err != nil {
e2e.Failf("Unable to get pod -n %v %v.", olmNamespace, olmJpath)
}
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(msg).NotTo(o.ContainSubstring("No resources found"))
// msg = fmt.Sprintf("%v\ntest,1.1.1.1\n", msg)
lines := strings.Split(msg, "\n")
for _, line := range lines {
if len(line) <= 0 {
continue
}
name := strings.Split(line, ",")
cscAddr := strings.Split(name[1], ":")[0]
if re.MatchString(cscAddr) {
olmErrs++
olmNames = append(olmNames, name[0])
}
}
if olmErrs > 0 {
e2e.Failf("%v ipv4 addresses found in these OLM components: %v", olmErrs, olmNames)
}
})
})
var _ = g.Describe("[sig-operators] OLM for an end user use", func() {
defer g.GinkgoRecover()
var oc = exutil.NewCLI("olm", exutil.KubeConfigPath())
// author: [email protected]
g.It("ConnectedOnly-Author:jiazha-Critical-23440-can subscribe to the etcd operator [Serial]", func() {
exutil.SkipARM64(oc)
buildPruningBaseDir := exutil.FixturePath("testdata", "olm")
etcdCluster := filepath.Join(buildPruningBaseDir, "etcd-cluster.yaml")
subTemplate := filepath.Join(buildPruningBaseDir, "olm-subscription.yaml")
oc.SetupProject()
dr := make(describerResrouce)
itName := g.CurrentGinkgoTestDescription().TestText
dr.addIr(itName)
g.By("Cluster-admin start to subscribe to etcd operator")
sub := subscriptionDescription{
subName: "sub-23440",
namespace: "openshift-operators",
catalogSourceName: "community-operators",
catalogSourceNamespace: "openshift-marketplace",
channel: "clusterwide-alpha",
ipApproval: "Automatic",
operatorPackage: "etcd",
singleNamespace: false,
template: subTemplate,
}
defer sub.delete(itName, dr)
sub.createWithoutCheck(oc, itName, dr)
g.By("try to get installPlan and CSV of the sub")
var installedPlan string
errIP := wait.Poll(10*time.Second, 150*time.Second, func() (bool, error) {
output := getResource(oc, asAdmin, withoutNamespace, "installplan", "-n", "openshift-operators", "-o=jsonpath={.items[*].metadata.name}")
ips := strings.Fields(output)
if len(ips) == 0 {
e2e.Logf("no ip is found, and try next")
return false, nil
}
for _, ip := range ips {
subNames := getResource(oc, asAdmin, withoutNamespace, "installplan", ip, "-n", "openshift-operators", "-o=jsonpath={.metadata.ownerReferences[*].name}")
if strings.Contains(subNames, sub.subName) {
e2e.Logf("found installplan and try to get csv")
installedPlan = ip
return true, nil
}
}
return false, nil
})
exutil.AssertWaitPollNoErr(errIP, fmt.Sprintf("the ip of openshift-operators does not belong to sub %s", sub.subName))
installedCSVs := getResource(oc, asAdmin, withoutNamespace, "installplan", installedPlan, "-n", "openshift-operators", "-o=jsonpath={.spec.clusterServiceVersionNames[*]}")
o.Expect(installedCSVs).NotTo(o.BeEmpty())
sub.installedCSV = strings.Fields(installedCSVs)[0]
dr.getIr(itName).add(newResource(oc, "csv", sub.installedCSV, requireNS, sub.namespace))
defer sub.getCSV().delete(itName, dr)
newCheck("expect", asAdmin, true, compare, "Succeeded", ok, []string{"csv", sub.installedCSV, "-n", "openshift-operators", "-o=jsonpath={.status.phase}"}).check(oc)
g.By("Switch to common user to create the resources provided by the operator")
etcdClusterName := "example-etcd-cluster"
configFile, err := oc.Run("process").Args("-f", etcdCluster, "-p", fmt.Sprintf("NAME=%s", etcdClusterName), fmt.Sprintf("NAMESPACE=%s", oc.Namespace())).OutputToFile("config.json")
o.Expect(err).NotTo(o.HaveOccurred())
defer func() {
_, err := oc.Run("delete").Args("etcdcluster", etcdClusterName, "-n", oc.Namespace()).Output()
o.Expect(err).NotTo(o.HaveOccurred())
}()
err = oc.Run("create").Args("-f", configFile).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
newCheck("expect", false, true, compare, "Running", ok, []string{"etcdCluster", etcdClusterName, "-n", oc.Namespace(), "-o=jsonpath={.status.phase}"}).check(oc)
})
})
var _ = g.Describe("[sig-operators] OLM for an end user handle within a namespace", func() {
defer g.GinkgoRecover()
var (
oc = exutil.NewCLI("olm-a-"+getRandomString(), exutil.KubeConfigPath())
dr = make(describerResrouce)
)
g.BeforeEach(func() {
itName := g.CurrentGinkgoTestDescription().TestText
dr.addIr(itName)
})
g.AfterEach(func() {})
// It will cover test case: OCP-24870, author: [email protected]
g.It("ConnectedOnly-Author:kuiwang-High-24870-can not create csv without operator group", func() {
exutil.SkipARM64(oc)
var (
itName = g.CurrentGinkgoTestDescription().TestText
buildPruningBaseDir = exutil.FixturePath("testdata", "olm")
ogSingleTemplate = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml")
subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml")
og = operatorGroupDescription{
name: "og-singlenamespace",
namespace: "",
template: ogSingleTemplate,
}
sub = subscriptionDescription{
subName: "mta-operator",
namespace: "",
channel: "alpha",
ipApproval: "Automatic",
operatorPackage: "mta-operator",
catalogSourceName: "community-operators",
catalogSourceNamespace: "openshift-marketplace",
startingCSV: "",
currentCSV: "",
installedCSV: "",
template: subTemplate,
singleNamespace: true,
}
)
oc.SetupProject() //project and its resource are deleted automatically when out of It, so no need derfer or AfterEach
og.namespace = oc.Namespace()
sub.namespace = oc.Namespace()
g.By("Create csv with failure because of no operator group")
sub.currentCSV = "windup-operator.0.0.5"
sub.createWithoutCheck(oc, itName, dr)
newCheck("present", asUser, withNamespace, notPresent, "", ok, []string{"csv", sub.currentCSV}).check(oc)
sub.delete(itName, dr)
g.By("Create opertor group and then csv is created with success")
og.create(oc, itName, dr)
sub.create(oc, itName, dr)
newCheck("expect", asUser, withNamespace, compare, "Succeeded"+"InstallSucceeded", ok, []string{"csv", sub.installedCSV, "-o=jsonpath={.status.phase}{.status.reason}"}).check(oc)
})
// It will cover part of test case: OCP-25855, author: [email protected]
g.It("ConnectedOnly-Author:kuiwang-High-25855-Add the channel field to subscription_sync_count", func() {
exutil.SkipARM64(oc)
var (
itName = g.CurrentGinkgoTestDescription().TestText
buildPruningBaseDir = exutil.FixturePath("testdata", "olm")
ogSingleTemplate = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml")
subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml")
og = operatorGroupDescription{
name: "og-singlenamespace",
namespace: "",
template: ogSingleTemplate,
}
sub = subscriptionDescription{
subName: "mta-operator",
namespace: "",
channel: "alpha",
ipApproval: "Automatic",
operatorPackage: "mta-operator",
catalogSourceName: "community-operators",
catalogSourceNamespace: "openshift-marketplace",
startingCSV: "",
currentCSV: "",
installedCSV: "",
template: subTemplate,
singleNamespace: true,
}
)
oc.SetupProject() //project and its resource are deleted automatically when out of It, so no need derfer or AfterEach
og.namespace = oc.Namespace()
sub.namespace = oc.Namespace()
g.By("Create og")
og.create(oc, itName, dr)
g.By("Create operator")
sub.create(oc, itName, dr)
newCheck("expect", asUser, withNamespace, compare, "Succeeded", ok, []string{"csv", sub.installedCSV, "-o=jsonpath={.status.phase}"}).check(oc)
g.By("get information of catalog operator pod")
output := getResource(oc, asAdmin, withoutNamespace, "pods", "-l", "app=catalog-operator", "-n", "openshift-operator-lifecycle-manager", "-o=jsonpath={.items[0].metadata.name}{\" \"}{.items[0].status.podIP}{\":\"}{.items[0].spec.containers[0].ports[?(@.name==\"metrics\")].containerPort}")
o.Expect(output).NotTo(o.BeEmpty())
infoCatalogOperator := strings.Fields(output)
g.By("check the subscription_sync_total")
err := wait.Poll(10*time.Second, 120*time.Second, func() (bool, error) {
subscriptionSyncTotal, _ := exec.Command("bash", "-c", "oc exec -c catalog-operator "+infoCatalogOperator[0]+" -n openshift-operator-lifecycle-manager -- curl -s -k -H 'Authorization: Bearer $(oc create token prometheus-k8s -n openshift-monitoring)' https://"+infoCatalogOperator[1]+"/metrics").Output()
if !strings.Contains(string(subscriptionSyncTotal), sub.installedCSV) {
e2e.Logf("the metric is not counted and try next round")
return false, nil
}
return true, nil
})
exutil.AssertWaitPollNoErr(err, fmt.Sprintf("csv %s is not included in metric", sub.installedCSV))
})
})
var _ = g.Describe("[sig-operators] OLM for an end user handle to support", func() {
defer g.GinkgoRecover()
var (
oc = exutil.NewCLI("olm-cm-"+getRandomString(), exutil.KubeConfigPath())
buildPruningBaseDir = exutil.FixturePath("testdata", "olm")
cmNcTemplate = filepath.Join(buildPruningBaseDir, "cm-namespaceconfig.yaml")
catsrcCmTemplate = filepath.Join(buildPruningBaseDir, "catalogsource-configmap.yaml")
ogAllTemplate = filepath.Join(buildPruningBaseDir, "og-allns.yaml")
ogMultiTemplate = filepath.Join(buildPruningBaseDir, "og-multins.yaml")
subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml")
dr = make(describerResrouce)
cmNc = configMapDescription{
name: "cm-community-namespaceconfig-operators",
namespace: "", //must be set in iT
template: cmNcTemplate,
}
catsrcNc = catalogSourceDescription{
name: "catsrc-community-namespaceconfig-operators",
namespace: "", //must be set in iT
displayName: "Community namespaceconfig Operators",
publisher: "Community",
sourceType: "configmap",
address: "cm-community-namespaceconfig-operators",
template: catsrcCmTemplate,
}
subNc = subscriptionDescription{
subName: "namespace-configuration-operator",
namespace: "", //must be set in iT
channel: "alpha",
ipApproval: "Automatic",
operatorPackage: "namespace-configuration-operator",
catalogSourceName: "catsrc-community-namespaceconfig-operators",
catalogSourceNamespace: "", //must be set in iT
startingCSV: "",
currentCSV: "namespace-configuration-operator.v0.1.0", //it matches to that in cm, so set it.
installedCSV: "",
template: subTemplate,
singleNamespace: true,
}
)
g.BeforeEach(func() {
itName := g.CurrentGinkgoTestDescription().TestText
dr.addIr(itName)
})
g.AfterEach(func() {})
// It will cover part of test case: OCP-22226, author: [email protected]
g.It("ConnectedOnly-Author:kuiwang-High-22226-the csv without support AllNamespaces fails for og with allnamespace", func() {
var (
itName = g.CurrentGinkgoTestDescription().TestText
og = operatorGroupDescription{
name: "og-allnamespace",
namespace: "",
template: ogAllTemplate,
}
cm = cmNc
catsrc = catsrcNc
sub = subNc
)
//oc.TeardownProject()
oc.SetupProject() //project and its resource are deleted automatically when out of It, so no need derfer or AfterEach
cm.namespace = oc.Namespace()
catsrc.namespace = oc.Namespace()
sub.namespace = oc.Namespace()
sub.catalogSourceNamespace = catsrc.namespace
og.namespace = oc.Namespace()
g.By("Create cm")
cm.create(oc, itName, dr)
g.By("Create catalog source")
catsrc.create(oc, itName, dr)
g.By("Create og")
og.create(oc, itName, dr)
g.By("Create sub")
sub.create(oc, itName, dr)
newCheck("expect", asAdmin, withoutNamespace, contain, "AllNamespaces InstallModeType not supported", ok, []string{"csv", sub.installedCSV, "-n", sub.namespace, "-o=jsonpath={.status.message}"}).check(oc)
})
// It will cover part of test case: OCP-22226, author: [email protected]
g.It("ConnectedOnly-Author:kuiwang-High-22226-the csv without support MultiNamespace fails for og with MultiNamespace", func() {
var (
itName = g.CurrentGinkgoTestDescription().TestText
og = operatorGroupDescription{
name: "og-multinamespace",
namespace: "",
multinslabel: "olmtestmultins",
template: ogMultiTemplate,
}
p1 = projectDescription{
name: "olm-enduser-multins-csv-1-fail",
targetNamespace: "",
}
p2 = projectDescription{
name: "olm-enduser-multins-csv-2-fail",
targetNamespace: "",
}
cm = cmNc
catsrc = catsrcNc
sub = subNc
)
defer p1.delete(oc)
defer p2.delete(oc)
//oc.TeardownProject()
oc.SetupProject() //project and its resource are deleted automatically when out of It, so no need derfer or AfterEach
cm.namespace = oc.Namespace()
catsrc.namespace = oc.Namespace()
sub.namespace = oc.Namespace()
sub.catalogSourceNamespace = catsrc.namespace
og.namespace = oc.Namespace()
p1.targetNamespace = oc.Namespace()
p2.targetNamespace = oc.Namespace()
g.By("Create new project")
p1.create(oc, itName, dr)
p1.label(oc, "olmtestmultins")
p2.create(oc, itName, dr)
p2.label(oc, "olmtestmultins")
g.By("Create cm")
cm.create(oc, itName, dr)
g.By("Create catalog source")
catsrc.create(oc, itName, dr)
g.By("Create og")
og.create(oc, itName, dr)
g.By("Create sub")
sub.create(oc, itName, dr)
newCheck("expect", asAdmin, withoutNamespace, contain, "MultiNamespace InstallModeType not supported", ok, []string{"csv", sub.installedCSV, "-n", sub.namespace, "-o=jsonpath={.status.message}"}).check(oc)
})
})
var _ = g.Describe("[sig-operators] OLM for an end user handle within all namespace", func() {
defer g.GinkgoRecover()
var (
oc = exutil.NewCLI("olm-all-"+getRandomString(), exutil.KubeConfigPath())
buildPruningBaseDir = exutil.FixturePath("testdata", "olm")
subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml")
dr = make(describerResrouce)
)
g.BeforeEach(func() {
itName := g.CurrentGinkgoTestDescription().TestText
dr.addIr(itName)
})
g.AfterEach(func() {
itName := g.CurrentGinkgoTestDescription().TestText
dr.getIr(itName).cleanup()
dr.rmIr(itName)
})
// It will cover test case: OCP-25679, OCP-21418(acutally it covers OCP-25679), author: [email protected]
g.It("ConnectedOnly-Author:kuiwang-High-25679-Medium-21418-Cluster resource created and deleted correctly", func() {
var (
itName = g.CurrentGinkgoTestDescription().TestText
sub = subscriptionDescription{
subName: "keda",
namespace: "openshift-operators",
channel: "alpha",
ipApproval: "Automatic",
operatorPackage: "keda",
catalogSourceName: "community-operators",
catalogSourceNamespace: "openshift-marketplace",
startingCSV: "", //get it from package based on currentCSV if ipApproval is Automatic
currentCSV: "",
installedCSV: "",
template: subTemplate,
singleNamespace: false,
}
crdName = "kedacontrollers.keda.sh"
crName = "KedaController"
podLabelName = "keda"
cl = checkList{}
)
// OCP-25679, OCP-21418
g.By("Create operator targeted at all namespace")
sub.create(oc, itName, dr)
// OCP-25679, OCP-21418
g.By("Check the cluster resource rolebinding, role and service account exists")
clusterResources := strings.Fields(getResource(oc, asAdmin, withoutNamespace, "clusterrolebinding",
fmt.Sprintf("--selector=olm.owner=%s", sub.installedCSV), "-o=jsonpath={.items[0].metadata.name}{\" \"}{.items[0].roleRef.name}{\" \"}{.items[0].subjects[0].name}"))
o.Expect(clusterResources).NotTo(o.BeEmpty())
cl.add(newCheck("present", asAdmin, withoutNamespace, present, "", ok, []string{"clusterrole", clusterResources[1]}))
cl.add(newCheck("present", asAdmin, withoutNamespace, present, "", ok, []string{"sa", clusterResources[2], "-n", sub.namespace}))
// OCP-21418
g.By("Check the pods of the operator is running")
cl.add(newCheck("expect", asAdmin, withoutNamespace, contain, "Running", ok, []string{"pod", fmt.Sprintf("--selector=name=%s", podLabelName), "-n", sub.namespace, "-o=jsonpath={.items[*].status.phase}"}))
// OCP-21418
g.By("Check no resource of new crd")
cl.add(newCheck("present", asAdmin, withNamespace, notPresent, "", ok, []string{crName}))
//do check parallelly
cl.check(oc)
cl.empty()
// OCP-25679, OCP-21418
g.By("Delete the operator")
sub.delete(itName, dr)
sub.getCSV().delete(itName, dr)
// OCP-25679, OCP-21418
g.By("Check the cluster resource rolebinding, role and service account do not exist")
cl.add(newCheck("present", asAdmin, withoutNamespace, notPresent, "", ok, []string{"clusterrolebinding", clusterResources[0]}))
cl.add(newCheck("present", asAdmin, withoutNamespace, notPresent, "", ok, []string{"clusterrole", clusterResources[1]}))
cl.add(newCheck("present", asAdmin, withoutNamespace, notPresent, "", ok, []string{"sa", clusterResources[2], "-n", sub.namespace}))
// OCP-21418
g.By("Check the CRD still exists")
cl.add(newCheck("present", asAdmin, withoutNamespace, present, "", ok, []string{"crd", crdName}))
// OCP-21418
g.By("Check the pods of the operator is deleted")
cl.add(newCheck("expect", asAdmin, withoutNamespace, compare, "", ok, []string{"pod", fmt.Sprintf("--selector=name=%s", podLabelName), "-n", sub.namespace, "-o=jsonpath={.items[*].status.phase}"}))
cl.check(oc)
})
// It will cover test case: OCP-25783, author: [email protected]
g.It("ConnectedOnly-Author:kuiwang-High-25783-Subscriptions are not getting processed taking very long to get processed [Serial]", func() {
exutil.SkipARM64(oc)
var (
itName = g.CurrentGinkgoTestDescription().TestText
buildPruningBaseDir = exutil.FixturePath("testdata", "olm")
catsrcImageTemplate = filepath.Join(buildPruningBaseDir, "catalogsource-image.yaml")
subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml")
subkeda = subscriptionDescription{
subName: "keda",
namespace: "openshift-operators",
channel: "alpha",
ipApproval: "Automatic",
operatorPackage: "keda",
catalogSourceName: "community-operators",
catalogSourceNamespace: "openshift-marketplace",
startingCSV: "", //get it from package based on currentCSV if ipApproval is Automatic
currentCSV: "",
installedCSV: "",
template: subTemplate,
singleNamespace: false,
}
csvkeda = csvDescription{
name: "",
namespace: "openshift-operators",
}
catsrc = catalogSourceDescription{
name: "catsrc-25783-operator",
namespace: "openshift-marketplace",
displayName: "Test Catsrc 25783 Operators",
publisher: "Red Hat",
sourceType: "grpc",
address: "quay.io/olmqe/olm-api:v21",
template: catsrcImageTemplate,
}
subCockroachdb = subscriptionDescription{
subName: "cockroachdb33241",
namespace: "openshift-operators",
channel: "stable-5.x",
ipApproval: "Automatic",
operatorPackage: "cockroachdb",
catalogSourceName: catsrc.name,
catalogSourceNamespace: catsrc.namespace,
startingCSV: "", //get it from package based on currentCSV if ipApproval is Automatic
currentCSV: "",
installedCSV: "",
template: subTemplate,
singleNamespace: false,
}
csvCockroachdb = csvDescription{
name: "",
namespace: "openshift-operators",
}
)
g.By("create catsrc")
catsrc.create(oc, itName, dr)
defer catsrc.delete(itName, dr)
g.By("create operator keda")
defer subkeda.delete(itName, dr)
subkeda.create(oc, itName, dr)
csvkeda.name = subkeda.installedCSV
defer csvkeda.delete(itName, dr)
newCheck("expect", asAdmin, withoutNamespace, compare, "Succeeded", ok, []string{"csv", subkeda.installedCSV, "-n", subkeda.namespace, "-o=jsonpath={.status.phase}"}).check(oc)
g.By("create operator Cockroachdb")
defer subCockroachdb.delete(itName, dr)
subCockroachdb.create(oc, itName, dr)
csvCockroachdb.name = subCockroachdb.installedCSV
defer csvCockroachdb.delete(itName, dr)
newCheck("expect", asAdmin, withoutNamespace, compare, "Succeeded", ok, []string{"csv", subCockroachdb.installedCSV, "-n", subCockroachdb.namespace, "-o=jsonpath={.status.phase}"}).check(oc)
})
})