Skip to content

Commit 59e23ca

Browse files
test/e2e: emit helpful comments as logs
Signed-off-by: Steve Kuznetsov <[email protected]>
1 parent cee0622 commit 59e23ca

19 files changed

+1124
-1135
lines changed

test/e2e/bundle_e2e_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ var _ = Describe("Installing bundles with new object types", func() {
6262
imageName = "quay.io/olmtest/single-bundle-index:pdb-v1"
6363
)
6464

65-
// create VPA CRD on cluster
65+
By("create VPA CRD on cluster")
6666
Expect(vpaCRDRaw).ToNot(BeEmpty(), "could not read vpa bindata")
6767
data, err := yaml.YAMLToJSON(vpaCRDRaw)
6868
Expect(err).ToNot(HaveOccurred(), "could not convert vpa crd to json")
@@ -80,7 +80,7 @@ var _ = Describe("Installing bundles with new object types", func() {
8080
return nil
8181
}).Should(Succeed())
8282

83-
// ensure vpa crd is established and accepted on the cluster before continuing
83+
By("ensure vpa crd is established and accepted on the cluster before continuing")
8484
Eventually(func() (bool, error) {
8585
crd, err := kubeClient.ApiextensionsInterface().ApiextensionsV1().CustomResourceDefinitions().Get(context.Background(), vpaCRD.GetName(), metav1.GetOptions{})
8686
if err != nil {
@@ -113,20 +113,20 @@ var _ = Describe("Installing bundles with new object types", func() {
113113
return err
114114
}).Should(Succeed())
115115

116-
// Wait for the CatalogSource to be ready
116+
By("Wait for the CatalogSource to be ready")
117117
_, err = fetchCatalogSourceOnStatus(operatorClient, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced())
118118
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
119119

120-
// Create a Subscription for package
120+
By("Create a Subscription for package")
121121
_ = createSubscriptionForCatalog(operatorClient, source.GetNamespace(), subName, source.GetName(), packageName, channelName, "", v1alpha1.ApprovalAutomatic)
122122

123-
// Wait for the Subscription to succeed
123+
By("Wait for the Subscription to succeed")
124124
sub, err := fetchSubscription(operatorClient, generatedNamespace.GetName(), subName, subscriptionStateAtLatestChecker())
125125
Expect(err).ToNot(HaveOccurred(), "could not get subscription at latest status")
126126

127127
installPlanRef := sub.Status.InstallPlanRef
128128

129-
// Wait for the installplan to complete (5 minute timeout)
129+
By("Wait for the installplan to complete (5 minute timeout)")
130130
_, err = fetchInstallPlanWithNamespace(GinkgoT(), operatorClient, installPlanRef.Name, installPlanRef.Namespace, buildInstallPlanPhaseCheckFunc(v1alpha1.InstallPlanPhaseComplete))
131131
Expect(err).ToNot(HaveOccurred(), "could not get installplan at complete phase")
132132

@@ -149,7 +149,7 @@ var _ = Describe("Installing bundles with new object types", func() {
149149
Resource: vpaResource,
150150
}
151151

152-
// confirm extra bundle objects are installed
152+
By("confirm extra bundle objects are installed")
153153
Eventually(func() error {
154154
_, err := kubeClient.KubernetesInterface().SchedulingV1().PriorityClasses().Get(context.Background(), priorityClassName, metav1.GetOptions{})
155155
return err

test/e2e/catalog_e2e_test.go

+104-104
Large diffs are not rendered by default.

test/e2e/catalog_exclusion_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ var _ = Describe("Global Catalog Exclusion", func() {
6969
localCatalog, err = NewMagicCatalogFromFile(determinedE2eClient, generatedNamespace.GetName(), localCatalogName, fbcPath)
7070
Expect(err).To(Succeed())
7171

72-
// deploy catalog blocks until the catalog has reached a ready state or fails
72+
By("deploy catalog blocks until the catalog has reached a ready state or fails")
7373
Expect(localCatalog.DeployCatalog(context.Background())).To(Succeed())
7474

7575
By("checking that the global catalog is broken")
76-
// Adding this check here to speed up the test
77-
// the global catalog can fail while we wait for the local catalog to get to a ready state
76+
By("Adding this check here to speed up the test")
77+
By("the global catalog can fail while we wait for the local catalog to get to a ready state")
7878
EventuallyResource(globalCatalog).Should(HaveGrpcConnectionWithLastConnectionState(connectivity.TransientFailure))
7979
})
8080

test/e2e/catsrc_pod_config_e2e_test.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var _ = Describe("CatalogSource Grpc Pod Config", func() {
4747
BeforeEach(func() {
4848
client = ctx.Ctx().Client()
4949

50-
// must be a grpc source type with spec.image defined
50+
By("must be a grpc source type with spec.image defined")
5151
catalogSource = &v1alpha1.CatalogSource{
5252
ObjectMeta: metav1.ObjectMeta{
5353
Name: catalogSourceName,
@@ -64,10 +64,10 @@ var _ = Describe("CatalogSource Grpc Pod Config", func() {
6464
})
6565

6666
AfterEach(func() {
67-
// assume the catalog source was created and just delete it
67+
By("assume the catalog source was created and just delete it")
6868
_ = client.Delete(context.TODO(), catalogSource)
6969

70-
// wait for it to go away
70+
By("wait for it to go away")
7171
Expect(waitForDelete(func() error {
7272
return client.Get(context.TODO(), k8scontrollerclient.ObjectKey{
7373
Name: catalogSource.GetName(),
@@ -79,14 +79,14 @@ var _ = Describe("CatalogSource Grpc Pod Config", func() {
7979
It("should override the pod's spec.priorityClassName", func() {
8080
var overridenPriorityClassName = "system-node-critical"
8181

82-
// create catalog source
82+
By("create catalog source")
8383
catalogSource.Spec.GrpcPodConfig = &v1alpha1.GrpcPodConfig{
8484
PriorityClassName: &overridenPriorityClassName,
8585
SecurityContextConfig: v1alpha1.Restricted,
8686
}
8787
mustCreateCatalogSource(client, catalogSource)
8888

89-
// Check overrides are present in the spec
89+
By("Check overrides are present in the spec")
9090
catalogSourcePod := mustGetCatalogSourcePod(client, catalogSource)
9191
Expect(catalogSourcePod).ToNot(BeNil())
9292
Expect(catalogSourcePod.Spec.NodeSelector).To(BeEquivalentTo(defaultNodeSelector))
@@ -97,14 +97,14 @@ var _ = Describe("CatalogSource Grpc Pod Config", func() {
9797
It("should override the pod's spec.priorityClassName when it is empty", func() {
9898
var overridenPriorityClassName = ""
9999

100-
// create catalog source
100+
By("create catalog source")
101101
catalogSource.Spec.GrpcPodConfig = &v1alpha1.GrpcPodConfig{
102102
PriorityClassName: &overridenPriorityClassName,
103103
SecurityContextConfig: v1alpha1.Restricted,
104104
}
105105
mustCreateCatalogSource(client, catalogSource)
106106

107-
// Check overrides are present in the spec
107+
By("Check overrides are present in the spec")
108108
catalogSourcePod := mustGetCatalogSourcePod(client, catalogSource)
109109
Expect(catalogSourcePod).ToNot(BeNil())
110110
Expect(catalogSourcePod.Spec.NodeSelector).To(BeEquivalentTo(defaultNodeSelector))
@@ -118,14 +118,14 @@ var _ = Describe("CatalogSource Grpc Pod Config", func() {
118118
"some": "tag",
119119
}
120120

121-
// create catalog source
121+
By("create catalog source")
122122
catalogSource.Spec.GrpcPodConfig = &v1alpha1.GrpcPodConfig{
123123
NodeSelector: overridenNodeSelector,
124124
SecurityContextConfig: v1alpha1.Restricted,
125125
}
126126
mustCreateCatalogSource(client, catalogSource)
127127

128-
// Check overrides are present in the spec
128+
By("Check overrides are present in the spec")
129129
catalogSourcePod := mustGetCatalogSourcePod(client, catalogSource)
130130
Expect(catalogSourcePod).ToNot(BeNil())
131131
Expect(catalogSourcePod.Spec.NodeSelector).To(BeEquivalentTo(overridenNodeSelector))
@@ -149,14 +149,14 @@ var _ = Describe("CatalogSource Grpc Pod Config", func() {
149149
},
150150
}
151151

152-
// create catalog source
152+
By("create catalog source")
153153
catalogSource.Spec.GrpcPodConfig = &v1alpha1.GrpcPodConfig{
154154
Tolerations: overriddenTolerations,
155155
SecurityContextConfig: v1alpha1.Restricted,
156156
}
157157
mustCreateCatalogSource(client, catalogSource)
158158

159-
// Check overrides are present in the spec
159+
By("Check overrides are present in the spec")
160160
catalogSourcePod := mustGetCatalogSourcePod(client, catalogSource)
161161
Expect(catalogSourcePod).ToNot(BeNil())
162162
Expect(catalogSourcePod.Spec.NodeSelector).To(BeEquivalentTo(defaultNodeSelector))

test/e2e/crd_e2e_test.go

+33-33
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ var _ = Describe("CRD Versions", func() {
8282
},
8383
}
8484

85-
// Create the catalog sources
85+
By("Create the catalog sources")
8686
_, cleanupMainCatalogSource := createV1CRDInternalCatalogSource(GinkgoT(), c, crc, mainCatalogName, generatedNamespace.GetName(), mainManifests, []apiextensionsv1.CustomResourceDefinition{v1crd}, []operatorsv1alpha1.ClusterServiceVersion{mainCSV})
8787
defer cleanupMainCatalogSource()
8888
defer func() {
8989
_ = crc.OperatorsV1alpha1().ClusterServiceVersions(generatedNamespace.GetName()).Delete(context.TODO(), mainCSV.GetName(), metav1.DeleteOptions{})
9090
_ = c.ApiextensionsInterface().ApiextensionsV1().CustomResourceDefinitions().Delete(context.TODO(), v1crd.GetName(), metav1.DeleteOptions{})
9191
}()
9292

93-
// Attempt to get the catalog source before creating install plan
93+
By("Attempt to get the catalog source before creating install plan")
9494

9595
_, err := fetchCatalogSourceOnStatus(crc, mainCatalogName, generatedNamespace.GetName(), catalogSourceRegistryPodSynced())
9696
Expect(err).ToNot(HaveOccurred())
@@ -107,7 +107,7 @@ var _ = Describe("CRD Versions", func() {
107107

108108
installPlanName := subscription.Status.InstallPlanRef.Name
109109

110-
// Wait for InstallPlan to be status: Complete before checking resource presence
110+
By("Wait for InstallPlan to be status: Complete before checking resource presence")
111111
fetchedInstallPlan, err := fetchInstallPlan(GinkgoT(), crc, installPlanName, generatedNamespace.GetName(), buildInstallPlanPhaseCheckFunc(operatorsv1alpha1.InstallPlanPhaseComplete))
112112
Expect(err).ToNot(HaveOccurred())
113113
GinkgoT().Logf("Install plan %s fetched with status %s", fetchedInstallPlan.GetName(), fetchedInstallPlan.Status.Phase)
@@ -220,7 +220,7 @@ var _ = Describe("CRD Versions", func() {
220220
},
221221
}
222222

223-
// Create the catalog sources
223+
By("Create the catalog sources")
224224
_, cleanupMainCatalogSource := createInternalCatalogSource(c, crc, mainCatalogName, generatedNamespace.GetName(), mainManifests, []apiextensionsv1.CustomResourceDefinition{oldCRD, newCRD}, []operatorsv1alpha1.ClusterServiceVersion{oldCSV, newCSV})
225225
defer cleanupMainCatalogSource()
226226
defer func() {
@@ -230,7 +230,7 @@ var _ = Describe("CRD Versions", func() {
230230
_ = c.ApiextensionsInterface().ApiextensionsV1().CustomResourceDefinitions().Delete(context.TODO(), newCRD.GetName(), metav1.DeleteOptions{})
231231
}()
232232

233-
// Attempt to get the catalog source before creating install plan
233+
By("Attempt to get the catalog source before creating install plan")
234234
_, err := fetchCatalogSourceOnStatus(crc, mainCatalogName, generatedNamespace.GetName(), catalogSourceRegistryPodSynced())
235235
Expect(err).ToNot(HaveOccurred())
236236

@@ -246,15 +246,15 @@ var _ = Describe("CRD Versions", func() {
246246

247247
installPlanName := subscription.Status.InstallPlanRef.Name
248248

249-
// Wait for InstallPlan to be status: Complete before checking resource presence
249+
By("Wait for InstallPlan to be status: Complete before checking resource presence")
250250
fetchedInstallPlan, err := fetchInstallPlan(GinkgoT(), crc, installPlanName, generatedNamespace.GetName(), buildInstallPlanPhaseCheckFunc(operatorsv1alpha1.InstallPlanPhaseComplete))
251251
Expect(err).ToNot(HaveOccurred())
252252
GinkgoT().Logf("Install plan %s fetched with status %s", fetchedInstallPlan.GetName(), fetchedInstallPlan.Status.Phase)
253253
Expect(fetchedInstallPlan.Status.Phase).To(Equal(operatorsv1alpha1.InstallPlanPhaseComplete))
254254

255-
// old CRD has been installed onto the cluster - now upgrade the subscription to point to the channel with the new CRD
256-
// installing the new CSV should fail with a warning about data loss, since a storage version is missing in the new CRD
257-
// use server-side apply to apply the update to the subscription point to the alpha channel
255+
By("old CRD has been installed onto the cluster - now upgrade the subscription to point to the channel with the new CRD")
256+
By("installing the new CSV should fail with a warning about data loss, since a storage version is missing in the new CRD")
257+
By("use server-side apply to apply the update to the subscription point to the alpha channel")
258258
Eventually(Apply(subscription, func(s *operatorsv1alpha1.Subscription) error {
259259
s.Spec.Channel = alphaChannel
260260
return nil
@@ -266,13 +266,13 @@ var _ = Describe("CRD Versions", func() {
266266
return checker(v) && v.Status.InstallPlanRef != nil && v.Status.InstallPlanRef.Name != fetchedInstallPlan.Name
267267
}
268268

269-
// fetch new subscription
269+
By("fetch new subscription")
270270
s, err := fetchSubscription(crc, generatedNamespace.GetName(), subscriptionName, subscriptionAtLatestWithDifferentInstallPlan)
271271
Expect(err).ToNot(HaveOccurred())
272272
Expect(s).ToNot(BeNil())
273273
Expect(s.Status.InstallPlanRef).ToNot(Equal(nil))
274274

275-
// Check the error on the installplan - should be related to data loss and the CRD upgrade missing a stored version
275+
By("Check the error on the installplan - should be related to data loss and the CRD upgrade missing a stored version")
276276
Eventually(func() (*operatorsv1alpha1.InstallPlan, error) {
277277
return crc.OperatorsV1alpha1().InstallPlans(generatedNamespace.GetName()).Get(context.TODO(), s.Status.InstallPlanRef.Name, metav1.GetOptions{})
278278
}).Should(And(
@@ -291,15 +291,15 @@ var _ = Describe("CRD Versions", func() {
291291
))
292292
})
293293

294-
// Create a CRD on cluster with v1alpha1 (storage)
295-
// Update that CRD with v1alpha2 (storage), v1alpha1 (served)
296-
// Now the CRD should have two versions in status.storedVersions
297-
// Now make a catalog with a CRD with just v1alpha2 (storage)
298-
// That should fail because v1alpha1 is still in status.storedVersions - risk of data loss
299-
// Update the CRD status to remove the v1alpha1
300-
// Now the installplan should succeed
301-
302294
It("allows a CRD upgrade that doesn't cause data loss", func() {
295+
By(`Create a CRD on cluster with v1alpha1 (storage)`)
296+
By(`Update that CRD with v1alpha2 (storage), v1alpha1 (served)`)
297+
By(`Now the CRD should have two versions in status.storedVersions`)
298+
By(`Now make a catalog with a CRD with just v1alpha2 (storage)`)
299+
By(`That should fail because v1alpha1 is still in status.storedVersions - risk of data loss`)
300+
By(`Update the CRD status to remove the v1alpha1`)
301+
By(`Now the installplan should succeed`)
302+
303303
By("manually editing the storage versions in the existing CRD status")
304304

305305
crdPlural := genName("ins-v1-")
@@ -337,17 +337,17 @@ var _ = Describe("CRD Versions", func() {
337337
_, err := c.ApiextensionsInterface().ApiextensionsV1().CustomResourceDefinitions().Create(context.TODO(), oldCRD, metav1.CreateOptions{})
338338
Expect(err).ToNot(HaveOccurred(), "error creating old CRD")
339339

340-
// wrap CRD update in a poll because of the object has been modified related errors
340+
By("wrap CRD update in a poll because of the object has been modified related errors")
341341
Eventually(func() error {
342342
oldCRD, err = c.ApiextensionsInterface().ApiextensionsV1().CustomResourceDefinitions().Get(context.TODO(), oldCRD.GetName(), metav1.GetOptions{})
343343
if err != nil {
344344
return err
345345
}
346346
GinkgoT().Logf("old crd status stored versions: %#v", oldCRD.Status.StoredVersions)
347347

348-
// set v1alpha1 to no longer stored
348+
By("set v1alpha1 to no longer stored")
349349
oldCRD.Spec.Versions[0].Storage = false
350-
// update CRD on-cluster with a new version
350+
By("update CRD on-cluster with a new version")
351351
oldCRD.Spec.Versions = append(oldCRD.Spec.Versions, apiextensionsv1.CustomResourceDefinitionVersion{
352352
Name: "v1alpha2",
353353
Served: true,
@@ -367,7 +367,7 @@ var _ = Describe("CRD Versions", func() {
367367
return nil
368368
}).Should(BeNil())
369369

370-
// create CSV and catalog with just the catalog CRD
370+
By("create CSV and catalog with just the catalog CRD")
371371
catalogCRD := apiextensionsv1.CustomResourceDefinition{
372372
ObjectMeta: metav1.ObjectMeta{
373373
Name: crdName,
@@ -417,11 +417,11 @@ var _ = Describe("CRD Versions", func() {
417417
},
418418
}
419419

420-
// Create the catalog sources
420+
By("Create the catalog sources")
421421
_, cleanupMainCatalogSource := createInternalCatalogSource(c, crc, mainCatalogName, generatedNamespace.GetName(), mainManifests, []apiextensionsv1.CustomResourceDefinition{catalogCRD}, []operatorsv1alpha1.ClusterServiceVersion{catalogCSV})
422422
defer cleanupMainCatalogSource()
423423

424-
// Attempt to get the catalog source before creating install plan
424+
By("Attempt to get the catalog source before creating install plan")
425425
_, err = fetchCatalogSourceOnStatus(crc, mainCatalogName, generatedNamespace.GetName(), catalogSourceRegistryPodSynced())
426426
Expect(err).ToNot(HaveOccurred())
427427

@@ -434,7 +434,7 @@ var _ = Describe("CRD Versions", func() {
434434
Expect(subscription.Status.InstallPlanRef).ToNot(Equal(nil))
435435
Expect(catalogCSV.GetName()).To(Equal(subscription.Status.CurrentCSV))
436436

437-
// Check the error on the installplan - should be related to data loss and the CRD upgrade missing a stored version (v1alpha1)
437+
By("Check the error on the installplan - should be related to data loss and the CRD upgrade missing a stored version (v1alpha1)")
438438
Eventually(
439439
func() (*operatorsv1alpha1.InstallPlan, error) {
440440
return crc.OperatorsV1alpha1().InstallPlans(generatedNamespace.GetName()).Get(context.TODO(), subscription.Status.InstallPlanRef.Name, metav1.GetOptions{})
@@ -445,26 +445,26 @@ var _ = Describe("CRD Versions", func() {
445445
Equal(operatorsv1alpha1.InstallPlanPhaseFailed),
446446
))
447447

448-
// update CRD status to remove the v1alpha1 stored version
448+
By("update CRD status to remove the v1alpha1 stored version")
449449
newCRD, err := c.ApiextensionsInterface().ApiextensionsV1().CustomResourceDefinitions().Get(context.TODO(), oldCRD.GetName(), metav1.GetOptions{})
450450
Expect(err).ToNot(HaveOccurred(), "error getting new CRD")
451451
newCRD.Status.StoredVersions = []string{"v1alpha2"}
452452
newCRD, err = c.ApiextensionsInterface().ApiextensionsV1().CustomResourceDefinitions().UpdateStatus(context.TODO(), newCRD, metav1.UpdateOptions{})
453453
Expect(err).ToNot(HaveOccurred(), "error updating new CRD")
454454
GinkgoT().Logf("new crd status stored versions: %#v", newCRD.Status.StoredVersions) // only v1alpha2 should be in the status now
455455

456-
// install should now succeed
456+
By("install should now succeed")
457457
oldInstallPlanRef := subscription.Status.InstallPlanRef.Name
458458
err = crc.OperatorsV1alpha1().InstallPlans(generatedNamespace.GetName()).Delete(context.TODO(), subscription.Status.InstallPlanRef.Name, metav1.DeleteOptions{})
459459
Expect(err).ToNot(HaveOccurred(), "error deleting failed install plan")
460-
// remove old subscription
460+
By("remove old subscription")
461461
err = crc.OperatorsV1alpha1().Subscriptions(generatedNamespace.GetName()).Delete(context.TODO(), subscription.GetName(), metav1.DeleteOptions{})
462462
Expect(err).ToNot(HaveOccurred(), "error deleting old subscription")
463-
// remove old csv
463+
By("remove old csv")
464464
crc.OperatorsV1alpha1().ClusterServiceVersions(generatedNamespace.GetName()).Delete(context.TODO(), mainPackageStable, metav1.DeleteOptions{})
465465
Expect(err).ToNot(HaveOccurred(), "error deleting old subscription")
466466

467-
// recreate subscription
467+
By("recreate subscription")
468468
subscriptionNameNew := genName("sub-nginx-update2-new-")
469469
_ = createSubscriptionForCatalog(crc, generatedNamespace.GetName(), subscriptionNameNew, mainCatalogName, mainPackageName, stableChannel, "", operatorsv1alpha1.ApprovalAutomatic)
470470

@@ -474,14 +474,14 @@ var _ = Describe("CRD Versions", func() {
474474
Expect(subscription.Status.InstallPlanRef).ToNot(Equal(nil))
475475
Expect(catalogCSV.GetName()).To(Equal(subscription.Status.CurrentCSV))
476476

477-
// eventually the subscription should create a new install plan
477+
By("eventually the subscription should create a new install plan")
478478
Eventually(func() bool {
479479
sub, _ := crc.OperatorsV1alpha1().Subscriptions(generatedNamespace.GetName()).Get(context.TODO(), subscription.GetName(), metav1.GetOptions{})
480480
GinkgoT().Logf("waiting for subscription %s to generate a new install plan...", subscription.GetName())
481481
return sub.Status.InstallPlanRef.Name != oldInstallPlanRef
482482
}, 5*time.Minute, 10*time.Second).Should(BeTrue())
483483

484-
// eventually the new installplan should succeed
484+
By("eventually the new installplan should succeed")
485485
Eventually(func() bool {
486486
sub, _ := crc.OperatorsV1alpha1().Subscriptions(generatedNamespace.GetName()).Get(context.TODO(), subscription.GetName(), metav1.GetOptions{})
487487
ip, err := crc.OperatorsV1alpha1().InstallPlans(generatedNamespace.GetName()).Get(context.TODO(), sub.Status.InstallPlanRef.Name, metav1.GetOptions{})

0 commit comments

Comments
 (0)