9
9
. "github.com/onsi/gomega"
10
10
corev1 "k8s.io/api/core/v1"
11
11
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12
+ "k8s.io/apimachinery/pkg/types"
12
13
"sigs.k8s.io/controller-runtime/pkg/client"
13
14
14
15
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
@@ -27,6 +28,7 @@ var _ = Describe("Fail Forward Upgrades", func() {
27
28
ns corev1.Namespace
28
29
crclient versioned.Interface
29
30
c client.Client
31
+ ogName string
30
32
)
31
33
32
34
BeforeEach (func () {
@@ -45,6 +47,8 @@ var _ = Describe("Fail Forward Upgrades", func() {
45
47
},
46
48
}
47
49
ns = SetupGeneratedTestNamespaceWithOperatorGroup (namespaceName , og )
50
+
51
+ ogName = og .GetName ()
48
52
})
49
53
50
54
AfterEach (func () {
@@ -61,9 +65,9 @@ var _ = Describe("Fail Forward Upgrades", func() {
61
65
)
62
66
63
67
BeforeEach (func () {
68
+ By ("deploying the testing catalog" )
64
69
provider , err := NewFileBasedFiledBasedCatalogProvider (filepath .Join (testdataDir , failForwardTestDataBaseDir , "example-operator.v0.1.0.yaml" ))
65
70
Expect (err ).To (BeNil ())
66
-
67
71
catalogSourceName = genName ("mc-ip-failed-" )
68
72
magicCatalog = NewMagicCatalog (c , ns .GetName (), catalogSourceName , provider )
69
73
Expect (magicCatalog .DeployCatalog (context .Background ())).To (BeNil ())
@@ -87,30 +91,21 @@ var _ = Describe("Fail Forward Upgrades", func() {
87
91
subscription , err := fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasInstallPlanChecker )
88
92
Expect (err ).Should (BeNil ())
89
93
90
- originalInstallPlanRef := subscription .Status .InstallPlanRef
91
-
92
94
By ("waiting for the v0.1.0 CSV to report a succeeded phase" )
93
95
_ , err = fetchCSV (crclient , subscription .Status .CurrentCSV , ns .GetName (), buildCSVConditionChecker (operatorsv1alpha1 .CSVPhaseSucceeded ))
94
96
Expect (err ).ShouldNot (HaveOccurred ())
95
97
98
+ By ("patching the OperatorGroup to reduce the bundle unpacking timeout" )
99
+ addBundleUnpackTimeoutOGAnnotation (context .Background (), c , types.NamespacedName {Name : ogName , Namespace : ns .GetName ()}, "1s" )
100
+
96
101
By ("updating the catalog with a broken v0.2.0 bundle image" )
97
102
brokenProvider , err := NewFileBasedFiledBasedCatalogProvider (filepath .Join (testdataDir , failForwardTestDataBaseDir , "example-operator.v0.2.0.yaml" ))
98
103
Expect (err ).To (BeNil ())
99
-
100
104
err = magicCatalog .UpdateCatalog (context .Background (), brokenProvider )
101
105
Expect (err ).To (BeNil ())
102
106
103
- By ("verifying the subscription is referencing a new installplan" )
104
- subscription , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasInstallPlanDifferentChecker (originalInstallPlanRef .Name ))
105
- Expect (err ).Should (BeNil ())
106
-
107
- By ("patching the installplan to reduce the bundle unpacking timeout" )
108
- addBundleUnpackTimeoutIPAnnotation (context .Background (), c , objectRefToNamespacedName (subscription .Status .InstallPlanRef ), "1s" )
109
-
110
- By ("waiting for the bad InstallPlan to report a failed installation state" )
111
- ref := subscription .Status .InstallPlanRef
112
- _ , err = fetchInstallPlan (GinkgoT (), crclient , ref .Name , ref .Namespace , buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseFailed ))
113
- Expect (err ).To (BeNil ())
107
+ By ("verifying that the subscription is still on v0.1.0" )
108
+ Consistently (subscriptionCurrentCSVGetter (crclient , subscription .GetNamespace (), subscription .GetName ())).Should (Equal ("example-operator.v0.1.0" ))
114
109
115
110
})
116
111
AfterEach (func () {
@@ -121,26 +116,18 @@ var _ = Describe("Fail Forward Upgrades", func() {
121
116
By ("patching the catalog with another bad bundle version" )
122
117
badProvider , err := NewFileBasedFiledBasedCatalogProvider (filepath .Join (testdataDir , "fail-forward/multiple-bad-versions" , "example-operator.v0.2.1.yaml" ))
123
118
Expect (err ).To (BeNil ())
124
-
125
119
err = magicCatalog .UpdateCatalog (context .Background (), badProvider )
126
120
Expect (err ).To (BeNil ())
127
121
128
- By ("waiting for the subscription to have the example-operator.v0.2.1 status.updatedCSV" )
129
- subscription , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasCurrentCSV ("example-operator.v0.2.1" ))
130
- Expect (err ).Should (BeNil ())
131
-
132
- By ("patching the installplan to reduce the bundle unpacking timeout" )
133
- addBundleUnpackTimeoutIPAnnotation (context .Background (), c , objectRefToNamespacedName (subscription .Status .InstallPlanRef ), "1s" )
122
+ By ("verifying that the subscription is still on v0.1.0" )
123
+ Consistently (subscriptionCurrentCSVGetter (crclient , subscription .GetNamespace (), subscription .GetName ())).Should (Equal ("example-operator.v0.1.0" ))
134
124
135
- By ("waiting for the bad v0.2.1 InstallPlan to report a failed installation state" )
136
- ref := subscription .Status .InstallPlanRef
137
- _ , err = fetchInstallPlan (GinkgoT (), crclient , ref .Name , ref .Namespace , buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseFailed ))
138
- Expect (err ).To (BeNil ())
125
+ By ("patching the OperatorGroup to increase the bundle unpacking timeout" )
126
+ addBundleUnpackTimeoutOGAnnotation (context .Background (), c , types.NamespacedName {Name : ogName , Namespace : ns .GetName ()}, "5m" )
139
127
140
128
By ("patching the catalog with a fixed version" )
141
129
fixedProvider , err := NewFileBasedFiledBasedCatalogProvider (filepath .Join (testdataDir , "fail-forward/multiple-bad-versions" , "example-operator.v0.3.0.yaml" ))
142
130
Expect (err ).To (BeNil ())
143
-
144
131
err = magicCatalog .UpdateCatalog (context .Background (), fixedProvider )
145
132
Expect (err ).To (BeNil ())
146
133
@@ -150,10 +137,12 @@ var _ = Describe("Fail Forward Upgrades", func() {
150
137
})
151
138
152
139
It ("eventually reports a successful state when using skip ranges" , func () {
140
+ By ("patching the OperatorGroup to increase the bundle unpacking timeout" )
141
+ addBundleUnpackTimeoutOGAnnotation (context .Background (), c , types.NamespacedName {Name : ogName , Namespace : ns .GetName ()}, "5m" )
142
+
153
143
By ("patching the catalog with a fixed version" )
154
144
fixedProvider , err := NewFileBasedFiledBasedCatalogProvider (filepath .Join (testdataDir , "fail-forward/skip-range" , "example-operator.v0.3.0.yaml" ))
155
145
Expect (err ).To (BeNil ())
156
-
157
146
err = magicCatalog .UpdateCatalog (context .Background (), fixedProvider )
158
147
Expect (err ).To (BeNil ())
159
148
@@ -162,10 +151,12 @@ var _ = Describe("Fail Forward Upgrades", func() {
162
151
Expect (err ).Should (BeNil ())
163
152
})
164
153
It ("eventually reports a successful state when using skips" , func () {
154
+ By ("patching the OperatorGroup to increase the bundle unpacking timeout" )
155
+ addBundleUnpackTimeoutOGAnnotation (context .Background (), c , types.NamespacedName {Name : ogName , Namespace : ns .GetName ()}, "5m" )
156
+
165
157
By ("patching the catalog with a fixed version" )
166
158
fixedProvider , err := NewFileBasedFiledBasedCatalogProvider (filepath .Join (testdataDir , "fail-forward/skips" , "example-operator.v0.3.0.yaml" ))
167
159
Expect (err ).To (BeNil ())
168
-
169
160
err = magicCatalog .UpdateCatalog (context .Background (), fixedProvider )
170
161
Expect (err ).To (BeNil ())
171
162
@@ -174,21 +165,17 @@ var _ = Describe("Fail Forward Upgrades", func() {
174
165
Expect (err ).Should (BeNil ())
175
166
})
176
167
It ("eventually reports a failed state when using replaces" , func () {
168
+ By ("patching the OperatorGroup to increase the bundle unpacking timeout" )
169
+ addBundleUnpackTimeoutOGAnnotation (context .Background (), c , types.NamespacedName {Name : ogName , Namespace : ns .GetName ()}, "5m" )
170
+
177
171
By ("patching the catalog with a fixed version" )
178
172
fixedProvider , err := NewFileBasedFiledBasedCatalogProvider (filepath .Join (testdataDir , "fail-forward/replaces" , "example-operator.v0.3.0.yaml" ))
179
173
Expect (err ).To (BeNil ())
180
-
181
174
err = magicCatalog .UpdateCatalog (context .Background (), fixedProvider )
182
175
Expect (err ).To (BeNil ())
183
176
184
177
By ("waiting for the subscription to maintain the example-operator.v0.2.0 status.updatedCSV" )
185
- Consistently (func () string {
186
- subscription , err := crclient .OperatorsV1alpha1 ().Subscriptions (subscription .GetNamespace ()).Get (context .Background (), subscription .GetName (), metav1.GetOptions {})
187
- if err != nil || subscription == nil {
188
- return ""
189
- }
190
- return subscription .Status .CurrentCSV
191
- }).Should (Equal ("example-operator.v0.2.0" ))
178
+ Consistently (subscriptionCurrentCSVGetter (crclient , subscription .GetNamespace (), subscription .GetName ())).Should (Equal ("example-operator.v0.1.0" ))
192
179
})
193
180
})
194
181
When ("a CSV resource is in a failed state" , func () {
0 commit comments