Skip to content

Commit 6d988f9

Browse files
committed
UPSTREAM: <carry>: Update does-not-exist and simple install to work in a disconnected environment
Signed-off-by: Todd Short <[email protected]>
1 parent 10fea86 commit 6d988f9

File tree

3 files changed

+192
-39
lines changed

3 files changed

+192
-39
lines changed

openshift/tests-extension/.openshift-tests-extension/openshift_payload_olmv1.json

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@
475475
"environmentSelector": {}
476476
},
477477
{
478-
"name": "[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 operator installation should install a cluster extension",
478+
"name": "[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 operator installation should install an openshift catalog cluster extension",
479479
"labels": {},
480480
"resources": {
481481
"isolation": {}
@@ -485,8 +485,24 @@
485485
"environmentSelector": {}
486486
},
487487
{
488-
"name": "[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 operator installation should fail to install a non-existing cluster extension",
489-
"labels": {},
488+
"name": "[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 operator installation should install a cluster extension",
489+
"originalName": "[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 operator installation should install a cluster extension",
490+
"labels": {
491+
"original-name:[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 operator installation should install a cluster extension": {}
492+
},
493+
"resources": {
494+
"isolation": {}
495+
},
496+
"source": "openshift:payload:olmv1",
497+
"lifecycle": "blocking",
498+
"environmentSelector": {}
499+
},
500+
{
501+
"name": "[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 operator installation should fail to install a non-existing cluster extension",
502+
"originalName": "[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 operator installation should fail to install a non-existing cluster extension",
503+
"labels": {
504+
"original-name:[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 operator installation should fail to install a non-existing cluster extension": {}
505+
},
490506
"resources": {
491507
"isolation": {}
492508
},

openshift/tests-extension/pkg/bindata/operator/operator.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openshift/tests-extension/test/olmv1.go

Lines changed: 168 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
//nolint:staticcheck // ST1001: dot-imports for readability
1111
. "github.com/onsi/gomega"
1212

13+
"github.com/openshift/origin/test/extended/util/image"
1314
corev1 "k8s.io/api/core/v1"
1415
apiextclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
1516
"k8s.io/apimachinery/pkg/api/meta"
@@ -19,6 +20,8 @@ import (
1920

2021
olmv1 "github.com/operator-framework/operator-controller/api/v1"
2122

23+
catalogdata "github.com/openshift/operator-framework-operator-controller/openshift/tests-extension/pkg/bindata/catalog"
24+
operatordata "github.com/openshift/operator-framework-operator-controller/openshift/tests-extension/pkg/bindata/operator"
2225
"github.com/openshift/operator-framework-operator-controller/openshift/tests-extension/pkg/env"
2326
"github.com/openshift/operator-framework-operator-controller/openshift/tests-extension/pkg/helpers"
2427
)
@@ -71,6 +74,8 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 CRDs", func() {
7174
})
7275
})
7376

77+
// Keeping this test as skip:disconnected, so we can attempt to install a "real" operator, rather than a generated one
78+
// There is an equivalent in-cluster positive test below
7479
var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 operator installation", func() {
7580
var (
7681
namespace string
@@ -102,7 +107,7 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1
102107
}
103108
})
104109

105-
It("should install a cluster extension", func(ctx SpecContext) {
110+
It("should install an openshift catalog cluster extension", func(ctx SpecContext) {
106111
if !env.Get().IsOpenShift {
107112
Skip("Requires OCP Catalogs: not OpenShift")
108113
}
@@ -117,38 +122,170 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1
117122
By("waiting for the quay-operator ClusterExtension to be installed")
118123
helpers.ExpectClusterExtensionToBeInstalled(ctx, name)
119124
})
125+
})
120126

121-
It("should fail to install a non-existing cluster extension", func(ctx SpecContext) {
122-
By("ensuring no ClusterExtension and CRD for non-existing operator")
123-
helpers.EnsureCleanupClusterExtension(context.Background(), "does-not-exist", "") // No CRD expected for non-existing operator
127+
var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 operator installation", func() {
128+
var unique, nsName, ccName, rbName, opName string
129+
BeforeEach(func(ctx SpecContext) {
130+
helpers.RequireOLMv1CapabilityOnOpenshift()
131+
unique = rand.String(8)
132+
nsName = "install-test-ns-" + unique
133+
ccName = "install-test-cc-" + unique
134+
rbName = "install-test-rb-" + unique
135+
opName = "install-test-op-" + unique
124136

125-
By("applying the ClusterExtension resource")
126-
name, cleanup := helpers.CreateClusterExtension("does-not-exist", "99.99.99", namespace, "")
127-
DeferCleanup(cleanup)
137+
By(fmt.Sprintf("setting a unique value: %q", unique))
138+
139+
testVersion := env.Get().OpenShiftVersion
140+
replacements := map[string]string{
141+
"{{ TEST-BUNDLE }}": opName,
142+
"{{ NAMESPACE }}": nsName,
143+
"{{ VERSION }}": testVersion,
144+
145+
// Using the shell image provided by origin as the controller image.
146+
// The image is mirrored into disconnected environments for testing.
147+
"{{ TEST-CONTROLLER }}": image.ShellImage(),
148+
}
149+
150+
By("creating a new Namespace")
151+
nsCleanup := createNamespace(nsName)
152+
DeferCleanup(nsCleanup)
153+
154+
// The builder (and deployer) service accounts are created by OpenShift itself which injects them in the NS.
155+
By(fmt.Sprintf("waiting for builder serviceaccount in %s", nsName))
156+
helpers.ExpectServiceAccountExists(ctx, "builder", nsName)
157+
158+
By(fmt.Sprintf("waiting for deployer serviceaccount in %s", nsName))
159+
helpers.ExpectServiceAccountExists(ctx, "deployer", nsName)
160+
161+
By("applying image-puller RoleBinding")
162+
rbCleanup := createImagePullerRoleBinding(rbName, nsName)
163+
DeferCleanup(rbCleanup)
164+
165+
By("creating the operator BuildConfig")
166+
bcCleanup := createBuildConfig(opName, nsName)
167+
DeferCleanup(bcCleanup)
168+
169+
By("creating the operator ImageStream")
170+
isCleanup := createImageStream(opName, nsName)
171+
DeferCleanup(isCleanup)
172+
173+
By("creating the operator tarball")
174+
fileOperator, fileCleanup := createTempTarBall(replacements, operatordata.AssetNames, operatordata.Asset)
175+
DeferCleanup(fileCleanup)
176+
By(fmt.Sprintf("created operator tarball %q", fileOperator))
177+
178+
By("starting the operator build via RAW URL")
179+
opArgs := []string{
180+
"create",
181+
"--raw",
182+
fmt.Sprintf(
183+
"/apis/build.openshift.io/v1/namespaces/%s/buildconfigs/%s/instantiatebinary?name=%s&namespace=%s",
184+
nsName, opName, opName, nsName,
185+
),
186+
"-f",
187+
fileOperator,
188+
}
189+
buildOperator := startBuild(opArgs...)
190+
191+
By(fmt.Sprintf("waiting for the build %q to finish", buildOperator.Name))
192+
waitForBuildToFinish(ctx, buildOperator.Name, nsName)
193+
194+
By("creating the catalog BuildConfig")
195+
bcCleanup = createBuildConfig(ccName, nsName)
196+
DeferCleanup(bcCleanup)
197+
198+
By("creating the catalog ImageStream")
199+
isCleanup = createImageStream(ccName, nsName)
200+
DeferCleanup(isCleanup)
201+
202+
By("creating the catalog tarball")
203+
fileCatalog, fileCleanup := createTempTarBall(replacements, catalogdata.AssetNames, catalogdata.Asset)
204+
DeferCleanup(fileCleanup)
205+
By(fmt.Sprintf("created catalog tarball %q", fileCatalog))
206+
207+
By("starting the catalog build via RAW URL")
208+
catalogArgs := []string{
209+
"create",
210+
"--raw",
211+
fmt.Sprintf(
212+
"/apis/build.openshift.io/v1/namespaces/%s/buildconfigs/%s/instantiatebinary?name=%s&namespace=%s",
213+
nsName, ccName, ccName, nsName,
214+
),
215+
"-f",
216+
fileCatalog,
217+
}
218+
buildCatalog := startBuild(catalogArgs...)
219+
220+
By(fmt.Sprintf("waiting for the build %q to finish", buildCatalog.Name))
221+
waitForBuildToFinish(ctx, buildCatalog.Name, nsName)
128222

129-
By("waiting for the ClusterExtension to exist")
130-
ce := &olmv1.ClusterExtension{}
131-
Eventually(func() error {
132-
return env.Get().K8sClient.Get(ctx, client.ObjectKey{Name: name}, ce)
133-
}).WithTimeout(5 * time.Minute).WithPolling(1 * time.Second).Should(Succeed())
134-
135-
By("waiting up to 2 minutes for ClusterExtension to report failure")
136-
Eventually(func(g Gomega) {
137-
k8sClient := env.Get().K8sClient
138-
err := k8sClient.Get(ctx, client.ObjectKey{Name: name}, ce)
139-
g.Expect(err).ToNot(HaveOccurred())
140-
141-
progressing := meta.FindStatusCondition(ce.Status.Conditions, olmv1.TypeProgressing)
142-
g.Expect(progressing).ToNot(BeNil())
143-
g.Expect(progressing.Status).To(Equal(metav1.ConditionTrue))
144-
g.Expect(progressing.Reason).To(Equal("Retrying"))
145-
g.Expect(progressing.Message).To(ContainSubstring(`no bundles found`))
146-
147-
installed := meta.FindStatusCondition(ce.Status.Conditions, olmv1.TypeInstalled)
148-
g.Expect(installed).ToNot(BeNil())
149-
g.Expect(installed.Status).To(Equal(metav1.ConditionFalse))
150-
g.Expect(installed.Reason).To(Equal("Failed"))
151-
g.Expect(installed.Message).To(Equal("No bundle installed"))
152-
}).WithTimeout(5 * time.Minute).WithPolling(1 * time.Second).Should(Succeed())
223+
By("creating the ClusterCatalog")
224+
ccCleanup := createClusterCatalog(ccName, nsName)
225+
DeferCleanup(ccCleanup)
153226
})
227+
228+
AfterEach(func(ctx SpecContext) {
229+
if CurrentSpecReport().Failed() {
230+
By("dumping for debugging")
231+
helpers.DescribeAllClusterCatalogs(context.Background())
232+
helpers.DescribeAllClusterExtensions(context.Background(), nsName)
233+
}
234+
})
235+
236+
It("should install a cluster extension",
237+
Label("original-name:[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 operator installation should install a cluster extension"), func(ctx SpecContext) {
238+
if !env.Get().IsOpenShift {
239+
Skip("Requires OCP Catalogs: not OpenShift")
240+
}
241+
242+
By("ensuring no ClusterExtension and CRD for the operator")
243+
helpers.EnsureCleanupClusterExtension(context.Background(), opName, "")
244+
245+
By("applying the ClusterExtension resource")
246+
name, cleanup := helpers.CreateClusterExtension(opName, "", nsName, unique, helpers.WithCatalogNameSelector(ccName))
247+
DeferCleanup(cleanup)
248+
249+
By("waiting for the ClusterExtension to be installed")
250+
helpers.ExpectClusterExtensionToBeInstalled(ctx, name)
251+
})
252+
253+
It("should fail to install a non-existing cluster extension",
254+
Label("original-name:[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 operator installation should fail to install a non-existing cluster extension"), func(ctx SpecContext) {
255+
if !env.Get().IsOpenShift {
256+
Skip("Requires OCP APIs: not OpenShift")
257+
}
258+
259+
By("ensuring no ClusterExtension and CRD for non-existing operator")
260+
helpers.EnsureCleanupClusterExtension(context.Background(), "does-not-exist", "") // No CRD expected for non-existing operator
261+
262+
By("applying the ClusterExtension resource")
263+
name, cleanup := helpers.CreateClusterExtension("does-not-exist", "99.99.99", nsName, unique, helpers.WithCatalogNameSelector(ccName))
264+
DeferCleanup(cleanup)
265+
266+
By("waiting for the ClusterExtension to exist")
267+
ce := &olmv1.ClusterExtension{}
268+
Eventually(func() error {
269+
return env.Get().K8sClient.Get(ctx, client.ObjectKey{Name: name}, ce)
270+
}).WithTimeout(5 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
271+
272+
By("waiting up to 2 minutes for ClusterExtension to report failure")
273+
Eventually(func(g Gomega) {
274+
k8sClient := env.Get().K8sClient
275+
err := k8sClient.Get(ctx, client.ObjectKey{Name: name}, ce)
276+
g.Expect(err).ToNot(HaveOccurred())
277+
278+
progressing := meta.FindStatusCondition(ce.Status.Conditions, olmv1.TypeProgressing)
279+
g.Expect(progressing).ToNot(BeNil())
280+
g.Expect(progressing.Status).To(Equal(metav1.ConditionTrue))
281+
g.Expect(progressing.Reason).To(Equal("Retrying"))
282+
g.Expect(progressing.Message).To(ContainSubstring(`no bundles found`))
283+
284+
installed := meta.FindStatusCondition(ce.Status.Conditions, olmv1.TypeInstalled)
285+
g.Expect(installed).ToNot(BeNil())
286+
g.Expect(installed.Status).To(Equal(metav1.ConditionFalse))
287+
g.Expect(installed.Reason).To(Equal("Failed"))
288+
g.Expect(installed.Message).To(Equal("No bundle installed"))
289+
}).WithTimeout(5 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
290+
})
154291
})

0 commit comments

Comments
 (0)