@@ -3,6 +3,8 @@ package e2e
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "time"
7
+
6
8
"github.com/blang/semver"
7
9
. "github.com/onsi/ginkgo"
8
10
. "github.com/onsi/gomega"
@@ -13,7 +15,6 @@ import (
13
15
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
14
16
k8serrors "k8s.io/apimachinery/pkg/api/errors"
15
17
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
16
- "time"
17
18
)
18
19
19
20
var _ = Describe ("CRD Versions" , func () {
@@ -313,14 +314,22 @@ var _ = Describe("CRD Versions", func() {
313
314
Expect (s .Status .InstallPlanRef ).ToNot (Equal (nil ))
314
315
315
316
// Check the error on the installplan - should be related to data loss and the CRD upgrade missing a stored version
316
- Eventually (func () bool {
317
- ip , err := crc .OperatorsV1alpha1 ().InstallPlans (testNamespace ).Get (context .TODO (), s .Status .InstallPlanRef .Name , metav1.GetOptions {})
318
- Expect (err ).ToNot (HaveOccurred (), "could not get installplan" )
319
-
320
- Expect (ip .Status .Phase ).To (Equal (operatorsv1alpha1 .InstallPlanPhaseFailed ))
321
- Expect (ip .Status .Conditions [len (ip .Status .Conditions )- 1 ].Message ).To (ContainSubstring ("risk of data loss" ))
322
- return true
323
- }).Should (BeTrue ())
317
+ Eventually (func () (* operatorsv1alpha1.InstallPlan , error ) {
318
+ return crc .OperatorsV1alpha1 ().InstallPlans (testNamespace ).Get (context .TODO (), s .Status .InstallPlanRef .Name , metav1.GetOptions {})
319
+ }).Should (And (
320
+ WithTransform (
321
+ func (v * operatorsv1alpha1.InstallPlan ) operatorsv1alpha1.InstallPlanPhase {
322
+ return v .Status .Phase
323
+ },
324
+ Equal (operatorsv1alpha1 .InstallPlanPhaseFailed ),
325
+ ),
326
+ WithTransform (
327
+ func (v * operatorsv1alpha1.InstallPlan ) string {
328
+ return v .Status .Conditions [len (v .Status .Conditions )- 1 ].Message
329
+ },
330
+ ContainSubstring ("risk of data loss" ),
331
+ ),
332
+ ))
324
333
})
325
334
326
335
// Create a CRD on cluster with v1alpha1 (storage)
@@ -369,7 +378,9 @@ var _ = Describe("CRD Versions", func() {
369
378
// wrap CRD update in a poll because of the object has been modified related errors
370
379
Eventually (func () error {
371
380
oldCRD , err = c .ApiextensionsInterface ().ApiextensionsV1beta1 ().CustomResourceDefinitions ().Get (context .TODO (), oldCRD .GetName (), metav1.GetOptions {})
372
- Expect (err ).ToNot (HaveOccurred (), "error getting old CRD" )
381
+ if err != nil {
382
+ return err
383
+ }
373
384
GinkgoT ().Logf ("old crd status stored versions: %#v" , oldCRD .Status .StoredVersions )
374
385
375
386
// set v1alpha1 to no longer served
@@ -448,12 +459,12 @@ var _ = Describe("CRD Versions", func() {
448
459
Expect (catalogCSV .GetName ()).To (Equal (subscription .Status .CurrentCSV ))
449
460
450
461
// Check the error on the installplan - should be related to data loss and the CRD upgrade missing a stored version (v1alpha1)
451
- Eventually (func () bool {
452
- ip , err := crc .OperatorsV1alpha1 ().InstallPlans (testNamespace ).Get (context .TODO (), subscription .Status .InstallPlanRef .Name , metav1.GetOptions {})
453
- Expect ( err ). ToNot ( HaveOccurred (), "could not get installplan" )
454
-
455
- return ip . Status . Phase == operatorsv1alpha1 .InstallPlanPhaseFailed
456
- }). Should ( BeTrue ( ))
462
+ Eventually (func () ( * operatorsv1alpha1. InstallPlan , error ) {
463
+ return crc .OperatorsV1alpha1 ().InstallPlans (testNamespace ).Get (context .TODO (), subscription .Status .InstallPlanRef .Name , metav1.GetOptions {})
464
+ }). Should ( WithTransform (
465
+ func ( v * operatorsv1alpha1. InstallPlan ) operatorsv1alpha1. InstallPlanPhase { return v . Status . Phase },
466
+ Equal ( operatorsv1alpha1 .InstallPlanPhaseFailed ),
467
+ ))
457
468
458
469
// update CRD status to remove the v1alpha1 stored version
459
470
newCRD , err := c .ApiextensionsInterface ().ApiextensionsV1beta1 ().CustomResourceDefinitions ().Get (context .TODO (), oldCRD .GetName (), metav1.GetOptions {})
0 commit comments