@@ -11,6 +11,7 @@ import (
11
11
"github.com/onsi/gomega/format"
12
12
gomegatypes "github.com/onsi/gomega/types"
13
13
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install"
14
+ "github.com/stretchr/testify/require"
14
15
corev1 "k8s.io/api/core/v1"
15
16
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
16
17
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -266,20 +267,22 @@ var _ = Describe("Operator API", func() {
266
267
)
267
268
268
269
BeforeEach (func () {
269
- // Subscribe to a package and await a successful install
270
+ By ( " Subscribe to a package and await a successful install" )
270
271
ns = & corev1.Namespace {}
271
272
ns .SetName (genName ("ns-" ))
272
273
Eventually (func () error {
273
274
return client .Create (clientCtx , ns )
274
275
}).Should (Succeed ())
276
+ By (fmt .Sprintf ("created namespace %s" , ns .Name ))
275
277
276
- // Default to AllNamespaces
278
+ By ( " Default to AllNamespaces" )
277
279
og := & operatorsv1.OperatorGroup {}
278
280
og .SetNamespace (ns .GetName ())
279
281
og .SetName (genName ("og-" ))
280
282
Eventually (func () error {
281
283
return client .Create (clientCtx , og )
282
284
}).Should (Succeed ())
285
+ By (fmt .Sprintf ("created operator group %s/%s" , og .Namespace , og .Name ))
283
286
284
287
cs := & operatorsv1alpha1.CatalogSource {
285
288
Spec : operatorsv1alpha1.CatalogSourceSpec {
@@ -295,8 +298,9 @@ var _ = Describe("Operator API", func() {
295
298
Eventually (func () error {
296
299
return client .Create (clientCtx , cs )
297
300
}).Should (Succeed ())
301
+ By (fmt .Sprintf ("created catalog source %s/%s" , cs .Namespace , cs .Name ))
298
302
299
- // Wait for the CatalogSource to be ready
303
+ By ( " Wait for the CatalogSource to be ready" )
300
304
_ , err := fetchCatalogSourceOnStatus (newCRClient (), cs .GetName (), cs .GetNamespace (), catalogSourceRegistryPodSynced ())
301
305
Expect (err ).ToNot (HaveOccurred ())
302
306
@@ -314,38 +318,31 @@ var _ = Describe("Operator API", func() {
314
318
Eventually (func () error {
315
319
return client .Create (clientCtx , sub )
316
320
}).Should (Succeed ())
321
+ By (fmt .Sprintf ("created subscription %s/%s" , sub .Namespace , sub .Name ))
317
322
318
- Eventually (func () (operatorsv1alpha1.SubscriptionState , error ) {
319
- s := sub .DeepCopy ()
320
- if err := client .Get (clientCtx , testobj .NamespacedName (s ), s ); err != nil {
321
- return operatorsv1alpha1 .SubscriptionStateNone , err
322
- }
323
-
324
- return s .Status .State , nil
325
- }).Should (BeEquivalentTo (operatorsv1alpha1 .SubscriptionStateAtLatest ))
323
+ _ , err = fetchSubscription (newCRClient (), sub .Namespace , sub .Name , subscriptionStateAtLatestChecker ())
324
+ require .NoError (GinkgoT (), err )
326
325
327
- var ipRef * corev1.ObjectReference
328
- Eventually (func () (* corev1.ObjectReference , error ) {
329
- if err := client .Get (clientCtx , testobj .NamespacedName (sub ), sub ); err != nil {
330
- return nil , err
331
- }
332
- ipRef = sub .Status .InstallPlanRef
326
+ subscriptionWithInstallPLan , err := fetchSubscription (newCRClient (), sub .Namespace , sub .Name , subscriptionHasInstallPlanChecker ())
327
+ require .NoError (GinkgoT (), err )
328
+ require .NotNil (GinkgoT (), subscriptionWithInstallPLan )
329
+ ipRef := subscriptionWithInstallPLan .Status .InstallPlanRef
333
330
334
- return ipRef , nil
335
- }).ShouldNot (BeNil ())
336
-
337
- ip = & operatorsv1alpha1.InstallPlan {}
338
- Eventually (func () error {
339
- return client .Get (clientCtx , types.NamespacedName {Namespace : ipRef .Namespace , Name : ipRef .Name }, ip )
340
- }).Should (Succeed ())
331
+ ip , err = fetchInstallPlan (GinkgoT (), newCRClient (), ipRef .Name , ipRef .Namespace , buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseComplete ))
332
+ Expect (err ).To (BeNil ())
341
333
342
334
operator , err := operatorFactory .NewPackageOperator (sub .Spec .Package , sub .GetNamespace ())
343
335
Expect (err ).ToNot (HaveOccurred ())
344
336
operatorName = testobj .NamespacedName (operator )
337
+ By (fmt .Sprintf ("waiting for operator %s/%s to exist" , operator .Namespace , operator .Name ))
345
338
})
346
339
347
340
AfterEach (func () {
348
341
Eventually (func () error {
342
+ if env := os .Getenv ("SKIP_CLEANUP" ); env != "" {
343
+ fmt .Printf ("Skipping cleanup of namespace %s...\n " , ns .Name )
344
+ return nil
345
+ }
349
346
err := client .Delete (clientCtx , ns )
350
347
if apierrors .IsNotFound (err ) {
351
348
return nil
@@ -386,7 +383,7 @@ var _ = Describe("Operator API", func() {
386
383
var newNs * corev1.Namespace
387
384
388
385
BeforeEach (func () {
389
- // Subscribe to a package and await a successful install
386
+ By ( " Subscribe to a package and await a successful install" )
390
387
newNs = & corev1.Namespace {}
391
388
newNs .SetName (genName ("ns-" ))
392
389
Eventually (func () error {
0 commit comments