Skip to content

Commit bb3f979

Browse files
Merge pull request #29998 from anik120/OPRUN-3768
OPRUN-3768: Add OLMv1 Single/OwnNamespace tests
2 parents 848143e + 0b8d106 commit bb3f979

File tree

7 files changed

+431
-10
lines changed

7 files changed

+431
-10
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package operators
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"path/filepath"
7+
"time"
8+
9+
g "github.com/onsi/ginkgo/v2"
10+
o "github.com/onsi/gomega"
11+
"k8s.io/apimachinery/pkg/util/wait"
12+
13+
exutil "github.com/openshift/origin/test/extended/util"
14+
)
15+
16+
var _ = g.Describe("[sig-olmv1][OCPFeatureGate:NewOLMOwnSingleNamespace][Skipped:Disconnected] OLMv1 operator installation support for singleNamespace watch mode with quay-operator", g.Serial, func() {
17+
defer g.GinkgoRecover()
18+
19+
oc := exutil.NewCLI("openshift-operator-controller")
20+
21+
g.BeforeEach(func() {
22+
exutil.PreTestDump()
23+
})
24+
25+
g.AfterEach(func() {
26+
if g.CurrentSpecReport().Failed() {
27+
exutil.DumpPodLogsStartingWith("", oc)
28+
}
29+
})
30+
31+
g.It("should install a cluster extension successfully", func(ctx g.SpecContext) {
32+
runSingleOwnNamespaceTest(ctx, oc, "install-quay-operator-singlens.yaml", false)
33+
})
34+
})
35+
36+
var _ = g.Describe("[sig-olmv1][OCPFeatureGate:NewOLMOwnSingleNamespace][Skipped:Disconnected] OLMv1 operator installation support for ownNamespace watch mode with quay-operator", g.Serial, func() {
37+
defer g.GinkgoRecover()
38+
39+
oc := exutil.NewCLI("openshift-operator-controller")
40+
41+
g.BeforeEach(func() {
42+
exutil.PreTestDump()
43+
})
44+
45+
g.AfterEach(func() {
46+
if g.CurrentSpecReport().Failed() {
47+
exutil.DumpPodLogsStartingWith("", oc)
48+
}
49+
})
50+
51+
g.It("should install a cluster extension successfully", func(ctx g.SpecContext) {
52+
runSingleOwnNamespaceTest(ctx, oc, "install-quay-operator-ownns.yaml", false)
53+
})
54+
})
55+
56+
var _ = g.Describe("[sig-olmv1][OCPFeatureGate:NewOLMOwnSingleNamespace][Skipped:Disconnected] OLMv1 operator installation support for ownNamespace watch mode with an operator that does not support ownNamespace installation mode", func() {
57+
defer g.GinkgoRecover()
58+
59+
oc := exutil.NewCLI("openshift-operator-controller")
60+
61+
g.BeforeEach(func() {
62+
exutil.PreTestDump()
63+
})
64+
65+
g.AfterEach(func() {
66+
if g.CurrentSpecReport().Failed() {
67+
exutil.DumpPodLogsStartingWith("", oc)
68+
}
69+
})
70+
71+
g.It("should fail to install a cluster extension successfully", func(ctx g.SpecContext) {
72+
runSingleOwnNamespaceTest(ctx, oc, "install-openshift-pipelines-operator-ownns.yaml", true)
73+
})
74+
})
75+
76+
//TODO: Need to add two more tests before this feature is GA.
77+
78+
func runSingleOwnNamespaceTest(ctx g.SpecContext, oc *exutil.CLI, fileName string, expectFailure bool) {
79+
checkFeatureCapability(oc)
80+
81+
var (
82+
baseDir = exutil.FixturePath("testdata", "olmv1")
83+
ceFile = filepath.Join(baseDir, fileName)
84+
)
85+
86+
cleanup, unique := applyResourceFile(oc, "", "", "", ceFile)
87+
ceName := "install-test-ce-" + unique
88+
g.DeferCleanup(cleanup)
89+
90+
g.By("waiting for the ClusterExtention to be installed")
91+
var lastReason string
92+
err := wait.PollUntilContextTimeout(ctx, time.Second, 5*time.Minute, true,
93+
func(ctx context.Context) (bool, error) {
94+
b, err, s := waitForClusterExtensionReady(oc, ceName)
95+
if lastReason != s {
96+
g.GinkgoLogr.Info(fmt.Sprintf("waitForClusterExtensionReady: %q", s))
97+
lastReason = s
98+
}
99+
return b, err
100+
})
101+
if expectFailure {
102+
o.Expect(err).To(o.HaveOccurred())
103+
} else {
104+
o.Expect(lastReason).To(o.BeEmpty())
105+
o.Expect(err).NotTo(o.HaveOccurred())
106+
}
107+
}

test/extended/testdata/bindata.go

Lines changed: 188 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: install-test-ns-{UNIQUE}
5+
---
6+
apiVersion: v1
7+
kind: ServiceAccount
8+
metadata:
9+
name: install-test-sa-{UNIQUE}
10+
namespace: {NAMESPACE}
11+
---
12+
apiVersion: rbac.authorization.k8s.io/v1
13+
kind: ClusterRoleBinding
14+
metadata:
15+
name: install-test-crb-{UNIQUE}
16+
roleRef:
17+
apiGroup: rbac.authorization.k8s.io
18+
kind: ClusterRole
19+
name: cluster-admin
20+
subjects:
21+
- kind: ServiceAccount
22+
name: install-test-sa-{UNIQUE}
23+
namespace: {NAMESPACE}
24+
---
25+
apiVersion: olm.operatorframework.io/v1
26+
kind: ClusterExtension
27+
metadata:
28+
name: install-test-ce-{UNIQUE}
29+
annotations:
30+
olm.operatorframework.io/watch-namespace: install-test-ns-{UNIQUE}
31+
spec:
32+
namespace: {NAMESPACE}
33+
serviceAccount:
34+
name: install-test-sa-{UNIQUE}
35+
source:
36+
catalog:
37+
packageName: "openshift-pipelines-operator-rh"
38+
version: "1.17.1"
39+
selector: {}
40+
upgradeConstraintPolicy: CatalogProvided
41+
sourceType: Catalog

0 commit comments

Comments
 (0)