Skip to content

Commit 44935f1

Browse files
test/e2e: improve waits, logs, etc
Signed-off-by: Steve Kuznetsov <[email protected]>
1 parent 530ca9c commit 44935f1

20 files changed

+312
-216
lines changed

scripts/build_local.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
# This is used to start and build services for running e2e tests
55

66
set -e
7+
set -o xtrace
78

89
[ -x "$(command -v kind)" ] && [[ "$(kubectl config current-context)" =~ ^kind-? ]] && KIND=1 NO_MINIKUBE=1
910

1011
if [ -z "$NO_MINIKUBE" ]; then
11-
pgrep -f "[m]inikube" >/dev/null || minikube start --extra-config=apiserver.v=4 || { echo 'Cannot start minikube.'; exit 1; }
12+
pgrep -f "[m]inikube" >/dev/null || minikube start "${MINIKUBE_ARGS}" --extra-config=apiserver.v=4 || { echo 'Cannot start minikube.'; exit 1; }
1213
eval "$(minikube docker-env)" || { echo 'Cannot switch to minikube docker'; exit 1; }
1314
kubectl config use-context minikube
1415
fi

scripts/lib/olm_util.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ olm::util::await_csv_success() {
1313
echo "awaiting ${namespace}/${csv} csv installation success"
1414
until [[ "${retries}" -le "0" || "${phase:=$(kubectl get csv -n "${namespace}" "${csv}" -o jsonpath='{.status.phase}' 2>/dev/null || echo "missing")}" == "Succeeded" ]]; do
1515
retries=$((retries - 1))
16+
kubectl get csv -n "${namespace}" "${csv}" -o yaml
1617
echo "current phase: ${phase}, remaining attempts: ${retries}"
1718
unset phase
1819
sleep 1
@@ -29,7 +30,7 @@ olm::util::await_csv_success() {
2930
olm::util::await_olm_ready() {
3031
local namespace="$1"
3132

32-
kubectl rollout status -w deployment/olm-operator --namespace="${namespace}" || return
33-
kubectl rollout status -w deployment/catalog-operator --namespace="${namespace}" || return
33+
kubectl rollout status -w deployment/olm-operator --namespace="${namespace}" || kubectl get deployment olm-operator --namespace="${namespace}" -o yaml && return
34+
kubectl rollout status -w deployment/catalog-operator --namespace="${namespace}" || kubectl get deployment catalog-operator --namespace="${namespace}" -o yaml && return
3435
olm::util::await_csv_success "${namespace}" "packageserver" 32 || return
3536
}

test/e2e/bundle_e2e_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ var _ = Describe("Installing bundles with new object types", func() {
114114
}).Should(Succeed())
115115

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

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

123123
// Wait for the Subscription to succeed
124-
sub, err := fetchSubscription(operatorClient, generatedNamespace.GetName(), subName, subscriptionStateAtLatestChecker)
124+
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

test/e2e/catalog_e2e_test.go

+19-19
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
109109
defer cleanupSource()
110110

111111
// ensure the mock catalog exists and has been synced by the catalog operator
112-
catalogSource, err := fetchCatalogSourceOnStatus(crc, catalogSourceName, ns.GetName(), catalogSourceRegistryPodSynced)
112+
catalogSource, err := fetchCatalogSourceOnStatus(crc, catalogSourceName, ns.GetName(), catalogSourceRegistryPodSynced())
113113
Expect(err).ShouldNot(HaveOccurred())
114114

115115
// get catalog operator deployment
@@ -180,7 +180,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
180180
defer cleanup()
181181

182182
// Attempt to get the catalog source before creating install plan
183-
_, err := fetchCatalogSourceOnStatus(crc, cs.GetName(), cs.GetNamespace(), catalogSourceRegistryPodSynced)
183+
_, err := fetchCatalogSourceOnStatus(crc, cs.GetName(), cs.GetNamespace(), catalogSourceRegistryPodSynced())
184184
Expect(err).ToNot(HaveOccurred())
185185

186186
subscriptionSpec := &v1alpha1.SubscriptionSpec{
@@ -196,7 +196,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
196196
subscriptionName := genName("sub-")
197197
createSubscriptionForCatalogWithSpec(GinkgoT(), crc, ns.GetName(), subscriptionName, subscriptionSpec)
198198

199-
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionHasInstallPlanChecker)
199+
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionHasInstallPlanChecker())
200200
Expect(err).ShouldNot(HaveOccurred())
201201
Expect(subscription).ToNot(BeNil())
202202

@@ -232,10 +232,10 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
232232
updateInternalCatalog(GinkgoT(), c, crc, cs.GetName(), cs.GetNamespace(), []apiextensions.CustomResourceDefinition{mainCRD}, []v1alpha1.ClusterServiceVersion{mainCSV, replacementCSV}, mainManifests)
233233

234234
// Get updated catalogsource
235-
fetchedUpdatedCatalog, err := fetchCatalogSourceOnStatus(crc, cs.GetName(), cs.GetNamespace(), catalogSourceRegistryPodSynced)
235+
fetchedUpdatedCatalog, err := fetchCatalogSourceOnStatus(crc, cs.GetName(), cs.GetNamespace(), catalogSourceRegistryPodSynced())
236236
Expect(err).ShouldNot(HaveOccurred())
237237

238-
subscription, err = fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionStateUpgradePendingChecker)
238+
subscription, err = fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionStateUpgradePendingChecker())
239239
Expect(err).ShouldNot(HaveOccurred())
240240
Expect(subscription).ShouldNot(BeNil())
241241

@@ -298,7 +298,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
298298
createInternalCatalogSource(c, crc, mainCatalogName, ns.GetName(), mainManifests, nil, []v1alpha1.ClusterServiceVersion{mainCSV})
299299

300300
// Attempt to get the catalog source before creating install plan
301-
fetchedInitialCatalog, err := fetchCatalogSourceOnStatus(crc, mainCatalogName, ns.GetName(), catalogSourceRegistryPodSynced)
301+
fetchedInitialCatalog, err := fetchCatalogSourceOnStatus(crc, mainCatalogName, ns.GetName(), catalogSourceRegistryPodSynced())
302302
Expect(err).ShouldNot(HaveOccurred())
303303

304304
// Get initial configmap
@@ -361,7 +361,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
361361
subscriptionName := genName("sub-")
362362
createSubscriptionForCatalog(crc, ns.GetName(), subscriptionName, fetchedUpdatedCatalog.GetName(), mainPackageName, stableChannel, "", v1alpha1.ApprovalAutomatic)
363363

364-
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionStateAtLatestChecker)
364+
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionStateAtLatestChecker())
365365
Expect(err).ShouldNot(HaveOccurred())
366366
Expect(subscription).ShouldNot(BeNil())
367367
_, err = fetchCSV(crc, subscription.Status.CurrentCSV, ns.GetName(), buildCSVConditionChecker(v1alpha1.CSVPhaseSucceeded))
@@ -431,7 +431,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
431431
_, cleanupSource := createInternalCatalogSource(c, crc, mainCatalogName, ns.GetName(), mainManifests, nil, []v1alpha1.ClusterServiceVersion{mainCSV})
432432

433433
// Attempt to get the catalog source before creating install plan
434-
fetchedInitialCatalog, err := fetchCatalogSourceOnStatus(crc, mainCatalogName, ns.GetName(), catalogSourceRegistryPodSynced)
434+
fetchedInitialCatalog, err := fetchCatalogSourceOnStatus(crc, mainCatalogName, ns.GetName(), catalogSourceRegistryPodSynced())
435435
Expect(err).ShouldNot(HaveOccurred())
436436
// Get initial configmap
437437
configMap, err := c.KubernetesInterface().CoreV1().ConfigMaps(ns.GetName()).Get(context.Background(), fetchedInitialCatalog.Spec.ConfigMap, metav1.GetOptions{})
@@ -452,7 +452,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
452452
subscriptionName := genName("sub-")
453453
createSubscriptionForCatalog(crc, ns.GetName(), subscriptionName, mainCatalogName, mainPackageName, stableChannel, "", v1alpha1.ApprovalAutomatic)
454454

455-
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionStateAtLatestChecker)
455+
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionStateAtLatestChecker())
456456
Expect(err).ShouldNot(HaveOccurred())
457457
Expect(subscription).ToNot(BeNil())
458458
_, err = fetchCSV(crc, subscription.Status.CurrentCSV, ns.GetName(), buildCSVConditionChecker(v1alpha1.CSVPhaseSucceeded))
@@ -540,9 +540,9 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
540540
createInternalCatalogSource(c, crc, replacementSourceName, ns.GetName(), append(replacementManifests, dependentManifests...), []apiextensions.CustomResourceDefinition{dependentCRD}, []v1alpha1.ClusterServiceVersion{replacementCSV, mainCSV, dependentCSV})
541541

542542
// Wait for ConfigMap CatalogSources to be ready
543-
mainSource, err := fetchCatalogSourceOnStatus(crc, mainSourceName, ns.GetName(), catalogSourceRegistryPodSynced)
543+
mainSource, err := fetchCatalogSourceOnStatus(crc, mainSourceName, ns.GetName(), catalogSourceRegistryPodSynced())
544544
Expect(err).ShouldNot(HaveOccurred())
545-
replacementSource, err := fetchCatalogSourceOnStatus(crc, replacementSourceName, ns.GetName(), catalogSourceRegistryPodSynced)
545+
replacementSource, err := fetchCatalogSourceOnStatus(crc, replacementSourceName, ns.GetName(), catalogSourceRegistryPodSynced())
546546
Expect(err).ShouldNot(HaveOccurred())
547547

548548
// Replicate catalog pods with no OwnerReferences
@@ -580,7 +580,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
580580
}()
581581

582582
// Wait for the CatalogSource to be ready
583-
_, err = fetchCatalogSourceOnStatus(crc, addressSource.GetName(), addressSource.GetNamespace(), catalogSourceRegistryPodSynced)
583+
_, err = fetchCatalogSourceOnStatus(crc, addressSource.GetName(), addressSource.GetNamespace(), catalogSourceRegistryPodSynced())
584584
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
585585

586586
// Delete CatalogSources
@@ -594,7 +594,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
594594
cleanupSubscription := createSubscriptionForCatalog(crc, ns.GetName(), subscriptionName, addressSourceName, mainPackageName, stableChannel, "", v1alpha1.ApprovalAutomatic)
595595
defer cleanupSubscription()
596596

597-
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionStateAtLatestChecker)
597+
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionStateAtLatestChecker())
598598
Expect(err).ShouldNot(HaveOccurred())
599599
Expect(subscription).ShouldNot(BeNil())
600600
_, err = fetchCSV(crc, subscription.Status.CurrentCSV, ns.GetName(), csvSucceededChecker)
@@ -783,7 +783,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
783783
Expect(err).ShouldNot(HaveOccurred())
784784

785785
By("Wait for the CatalogSource to be ready")
786-
source, err = fetchCatalogSourceOnStatus(crc, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced)
786+
source, err = fetchCatalogSourceOnStatus(crc, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced())
787787
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
788788

789789
// the gRPC endpoints are not exposed from the pod, and there's no simple way to get at them -
@@ -923,7 +923,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
923923
defer cleanupSubscription()
924924

925925
// Wait for the Subscription to succeed
926-
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionStateAtLatestChecker)
926+
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionStateAtLatestChecker())
927927
Expect(err).ShouldNot(HaveOccurred())
928928
Expect(subscription).ShouldNot(BeNil())
929929

@@ -1088,7 +1088,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
10881088
}()
10891089

10901090
By("waiting for the CatalogSource to be ready")
1091-
_, err = fetchCatalogSourceOnStatus(crc, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced)
1091+
_, err = fetchCatalogSourceOnStatus(crc, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced())
10921092
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
10931093

10941094
By("creating a Subscription for busybox")
@@ -1097,7 +1097,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
10971097
defer cleanupSubscription()
10981098

10991099
By("waiting for the Subscription to succeed")
1100-
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionStateAtLatestChecker)
1100+
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionStateAtLatestChecker())
11011101
Expect(err).ShouldNot(HaveOccurred())
11021102
Expect(subscription).ShouldNot(BeNil())
11031103
Expect(subscription.Status.InstalledCSV).To(Equal("busybox.v1.0.0"))
@@ -1114,7 +1114,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
11141114
Expect(dependencySubscriptionName).ToNot(BeEmpty())
11151115

11161116
By("waiting for the Subscription to succeed")
1117-
subscription, err = fetchSubscription(crc, ns.GetName(), dependencySubscriptionName, subscriptionStateAtLatestChecker)
1117+
subscription, err = fetchSubscription(crc, ns.GetName(), dependencySubscriptionName, subscriptionStateAtLatestChecker())
11181118
Expect(err).ShouldNot(HaveOccurred())
11191119
Expect(subscription).ShouldNot(BeNil())
11201120
Expect(subscription.Status.InstalledCSV).To(Equal("busybox-dependency.v1.0.0"))
@@ -1132,7 +1132,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
11321132
}).Should(Succeed())
11331133

11341134
By("waiting for the CatalogSource to be ready")
1135-
_, err = fetchCatalogSourceOnStatus(crc, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced)
1135+
_, err = fetchCatalogSourceOnStatus(crc, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced())
11361136
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
11371137

11381138
By("waiting for the busybox v2 Subscription to succeed")

test/e2e/crd_e2e_test.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ var _ = Describe("CRD Versions", func() {
9292
}()
9393

9494
// Attempt to get the catalog source before creating install plan
95-
_, err := fetchCatalogSourceOnStatus(crc, mainCatalogName, ns.GetName(), catalogSourceRegistryPodSynced)
95+
_, err := fetchCatalogSourceOnStatus(crc, mainCatalogName, ns.GetName(), catalogSourceRegistryPodSynced())
9696
Expect(err).ToNot(HaveOccurred())
9797

9898
subscriptionName := genName("sub-nginx-update2-")
9999
subscriptionCleanup := createSubscriptionForCatalog(crc, ns.GetName(), subscriptionName, mainCatalogName, mainPackageName, stableChannel, "", operatorsv1alpha1.ApprovalAutomatic)
100100
defer subscriptionCleanup()
101101

102-
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionHasInstallPlanChecker)
102+
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionHasInstallPlanChecker())
103103
Expect(err).ToNot(HaveOccurred())
104104
Expect(subscription).ToNot(Equal(nil))
105105
Expect(subscription.Status.InstallPlanRef).ToNot(Equal(nil))
@@ -231,14 +231,14 @@ var _ = Describe("CRD Versions", func() {
231231
}()
232232

233233
// Attempt to get the catalog source before creating install plan
234-
_, err := fetchCatalogSourceOnStatus(crc, mainCatalogName, ns.GetName(), catalogSourceRegistryPodSynced)
234+
_, err := fetchCatalogSourceOnStatus(crc, mainCatalogName, ns.GetName(), catalogSourceRegistryPodSynced())
235235
Expect(err).ToNot(HaveOccurred())
236236

237237
subscriptionName := genName("sub-nginx-update2-")
238238
subscriptionCleanup := createSubscriptionForCatalog(crc, ns.GetName(), subscriptionName, mainCatalogName, mainPackageName, stableChannel, "", operatorsv1alpha1.ApprovalAutomatic)
239239
defer subscriptionCleanup()
240240

241-
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionHasInstallPlanChecker)
241+
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionHasInstallPlanChecker())
242242
Expect(err).ToNot(HaveOccurred())
243243
Expect(subscription).ToNot(BeNil())
244244
Expect(subscription.Status.InstallPlanRef).ToNot(Equal(nil))
@@ -261,8 +261,9 @@ var _ = Describe("CRD Versions", func() {
261261
})).Should(Succeed())
262262
ctx.Ctx().Logf("updated subscription to point to alpha channel")
263263

264+
checker := subscriptionStateAtLatestChecker()
264265
subscriptionAtLatestWithDifferentInstallPlan := func(v *operatorsv1alpha1.Subscription) bool {
265-
return subscriptionStateAtLatestChecker(v) && v.Status.InstallPlanRef != nil && v.Status.InstallPlanRef.Name != fetchedInstallPlan.Name
266+
return checker(v) && v.Status.InstallPlanRef != nil && v.Status.InstallPlanRef.Name != fetchedInstallPlan.Name
266267
}
267268

268269
// fetch new subscription
@@ -421,13 +422,13 @@ var _ = Describe("CRD Versions", func() {
421422
defer cleanupMainCatalogSource()
422423

423424
// Attempt to get the catalog source before creating install plan
424-
_, err = fetchCatalogSourceOnStatus(crc, mainCatalogName, ns.GetName(), catalogSourceRegistryPodSynced)
425+
_, err = fetchCatalogSourceOnStatus(crc, mainCatalogName, ns.GetName(), catalogSourceRegistryPodSynced())
425426
Expect(err).ToNot(HaveOccurred())
426427

427428
subscriptionName := genName("sub-nginx-update2-")
428429
_ = createSubscriptionForCatalog(crc, ns.GetName(), subscriptionName, mainCatalogName, mainPackageName, stableChannel, "", operatorsv1alpha1.ApprovalAutomatic)
429430

430-
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionHasInstallPlanChecker)
431+
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionHasInstallPlanChecker())
431432
Expect(err).ToNot(HaveOccurred())
432433
Expect(subscription).ToNot(BeNil())
433434
Expect(subscription.Status.InstallPlanRef).ToNot(Equal(nil))
@@ -467,7 +468,7 @@ var _ = Describe("CRD Versions", func() {
467468
subscriptionNameNew := genName("sub-nginx-update2-new-")
468469
_ = createSubscriptionForCatalog(crc, ns.GetName(), subscriptionNameNew, mainCatalogName, mainPackageName, stableChannel, "", operatorsv1alpha1.ApprovalAutomatic)
469470

470-
subscription, err = fetchSubscription(crc, ns.GetName(), subscriptionNameNew, subscriptionHasInstallPlanChecker)
471+
subscription, err = fetchSubscription(crc, ns.GetName(), subscriptionNameNew, subscriptionHasInstallPlanChecker())
471472
Expect(err).ToNot(HaveOccurred())
472473
Expect(subscription).ToNot(BeNil())
473474
Expect(subscription.Status.InstallPlanRef).ToNot(Equal(nil))

0 commit comments

Comments
 (0)