Skip to content

Commit db8082f

Browse files
author
Mikalai Radchuk
committed
WIP: e2e tests
Signed-off-by: Mikalai Radchuk <[email protected]>
1 parent 221951c commit db8082f

File tree

4 files changed

+191
-345
lines changed

4 files changed

+191
-345
lines changed

test/e2e/fail_forward_e2e_test.go

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
. "github.com/onsi/gomega"
1010
corev1 "k8s.io/api/core/v1"
1111
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12+
"k8s.io/apimachinery/pkg/types"
1213
"sigs.k8s.io/controller-runtime/pkg/client"
1314

1415
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
@@ -27,6 +28,7 @@ var _ = Describe("Fail Forward Upgrades", func() {
2728
ns corev1.Namespace
2829
crclient versioned.Interface
2930
c client.Client
31+
ogName string
3032
)
3133

3234
BeforeEach(func() {
@@ -45,6 +47,8 @@ var _ = Describe("Fail Forward Upgrades", func() {
4547
},
4648
}
4749
ns = SetupGeneratedTestNamespaceWithOperatorGroup(namespaceName, og)
50+
51+
ogName = og.GetName()
4852
})
4953

5054
AfterEach(func() {
@@ -61,9 +65,9 @@ var _ = Describe("Fail Forward Upgrades", func() {
6165
)
6266

6367
BeforeEach(func() {
68+
By("deploying the testing catalog")
6469
provider, err := NewFileBasedFiledBasedCatalogProvider(filepath.Join(testdataDir, failForwardTestDataBaseDir, "example-operator.v0.1.0.yaml"))
6570
Expect(err).To(BeNil())
66-
6771
catalogSourceName = genName("mc-ip-failed-")
6872
magicCatalog = NewMagicCatalog(c, ns.GetName(), catalogSourceName, provider)
6973
Expect(magicCatalog.DeployCatalog(context.Background())).To(BeNil())
@@ -87,30 +91,21 @@ var _ = Describe("Fail Forward Upgrades", func() {
8791
subscription, err := fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasInstallPlanChecker)
8892
Expect(err).Should(BeNil())
8993

90-
originalInstallPlanRef := subscription.Status.InstallPlanRef
91-
9294
By("waiting for the v0.1.0 CSV to report a succeeded phase")
9395
_, err = fetchCSV(crclient, subscription.Status.CurrentCSV, ns.GetName(), buildCSVConditionChecker(operatorsv1alpha1.CSVPhaseSucceeded))
9496
Expect(err).ShouldNot(HaveOccurred())
9597

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+
96101
By("updating the catalog with a broken v0.2.0 bundle image")
97102
brokenProvider, err := NewFileBasedFiledBasedCatalogProvider(filepath.Join(testdataDir, failForwardTestDataBaseDir, "example-operator.v0.2.0.yaml"))
98103
Expect(err).To(BeNil())
99-
100104
err = magicCatalog.UpdateCatalog(context.Background(), brokenProvider)
101105
Expect(err).To(BeNil())
102106

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"))
114109

115110
})
116111
AfterEach(func() {
@@ -121,26 +116,18 @@ var _ = Describe("Fail Forward Upgrades", func() {
121116
By("patching the catalog with another bad bundle version")
122117
badProvider, err := NewFileBasedFiledBasedCatalogProvider(filepath.Join(testdataDir, "fail-forward/multiple-bad-versions", "example-operator.v0.2.1.yaml"))
123118
Expect(err).To(BeNil())
124-
125119
err = magicCatalog.UpdateCatalog(context.Background(), badProvider)
126120
Expect(err).To(BeNil())
127121

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"))
134124

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")
139127

140128
By("patching the catalog with a fixed version")
141129
fixedProvider, err := NewFileBasedFiledBasedCatalogProvider(filepath.Join(testdataDir, "fail-forward/multiple-bad-versions", "example-operator.v0.3.0.yaml"))
142130
Expect(err).To(BeNil())
143-
144131
err = magicCatalog.UpdateCatalog(context.Background(), fixedProvider)
145132
Expect(err).To(BeNil())
146133

@@ -150,10 +137,12 @@ var _ = Describe("Fail Forward Upgrades", func() {
150137
})
151138

152139
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+
153143
By("patching the catalog with a fixed version")
154144
fixedProvider, err := NewFileBasedFiledBasedCatalogProvider(filepath.Join(testdataDir, "fail-forward/skip-range", "example-operator.v0.3.0.yaml"))
155145
Expect(err).To(BeNil())
156-
157146
err = magicCatalog.UpdateCatalog(context.Background(), fixedProvider)
158147
Expect(err).To(BeNil())
159148

@@ -162,10 +151,12 @@ var _ = Describe("Fail Forward Upgrades", func() {
162151
Expect(err).Should(BeNil())
163152
})
164153
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+
165157
By("patching the catalog with a fixed version")
166158
fixedProvider, err := NewFileBasedFiledBasedCatalogProvider(filepath.Join(testdataDir, "fail-forward/skips", "example-operator.v0.3.0.yaml"))
167159
Expect(err).To(BeNil())
168-
169160
err = magicCatalog.UpdateCatalog(context.Background(), fixedProvider)
170161
Expect(err).To(BeNil())
171162

@@ -174,21 +165,17 @@ var _ = Describe("Fail Forward Upgrades", func() {
174165
Expect(err).Should(BeNil())
175166
})
176167
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+
177171
By("patching the catalog with a fixed version")
178172
fixedProvider, err := NewFileBasedFiledBasedCatalogProvider(filepath.Join(testdataDir, "fail-forward/replaces", "example-operator.v0.3.0.yaml"))
179173
Expect(err).To(BeNil())
180-
181174
err = magicCatalog.UpdateCatalog(context.Background(), fixedProvider)
182175
Expect(err).To(BeNil())
183176

184177
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"))
192179
})
193180
})
194181
When("a CSV resource is in a failed state", func() {

0 commit comments

Comments
 (0)