Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/e2e: emit helpful comments as logs #3137

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions test/e2e/bundle_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var _ = Describe("Installing bundles with new object types", func() {
imageName = "quay.io/olmtest/single-bundle-index:pdb-v1"
)

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

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

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

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

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

installPlanRef := sub.Status.InstallPlanRef

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

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

// confirm extra bundle objects are installed
By("confirm extra bundle objects are installed")
Eventually(func() error {
_, err := kubeClient.KubernetesInterface().SchedulingV1().PriorityClasses().Get(context.Background(), priorityClassName, metav1.GetOptions{})
return err
Expand Down
208 changes: 104 additions & 104 deletions test/e2e/catalog_e2e_test.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions test/e2e/catalog_exclusion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ var _ = Describe("Global Catalog Exclusion", func() {
localCatalog, err = NewMagicCatalogFromFile(determinedE2eClient, generatedNamespace.GetName(), localCatalogName, fbcPath)
Expect(err).To(Succeed())

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

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

Expand Down
22 changes: 11 additions & 11 deletions test/e2e/catsrc_pod_config_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var _ = Describe("CatalogSource Grpc Pod Config", func() {
BeforeEach(func() {
client = ctx.Ctx().Client()

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

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

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

// create catalog source
By("create catalog source")
catalogSource.Spec.GrpcPodConfig = &v1alpha1.GrpcPodConfig{
PriorityClassName: &overridenPriorityClassName,
SecurityContextConfig: v1alpha1.Restricted,
}
mustCreateCatalogSource(client, catalogSource)

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

// create catalog source
By("create catalog source")
catalogSource.Spec.GrpcPodConfig = &v1alpha1.GrpcPodConfig{
PriorityClassName: &overridenPriorityClassName,
SecurityContextConfig: v1alpha1.Restricted,
}
mustCreateCatalogSource(client, catalogSource)

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

// create catalog source
By("create catalog source")
catalogSource.Spec.GrpcPodConfig = &v1alpha1.GrpcPodConfig{
NodeSelector: overridenNodeSelector,
SecurityContextConfig: v1alpha1.Restricted,
}
mustCreateCatalogSource(client, catalogSource)

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

// create catalog source
By("create catalog source")
catalogSource.Spec.GrpcPodConfig = &v1alpha1.GrpcPodConfig{
Tolerations: overriddenTolerations,
SecurityContextConfig: v1alpha1.Restricted,
}
mustCreateCatalogSource(client, catalogSource)

// Check overrides are present in the spec
By("Check overrides are present in the spec")
catalogSourcePod := mustGetCatalogSourcePod(client, catalogSource)
Expect(catalogSourcePod).ToNot(BeNil())
Expect(catalogSourcePod.Spec.NodeSelector).To(BeEquivalentTo(defaultNodeSelector))
Expand Down
66 changes: 33 additions & 33 deletions test/e2e/crd_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ var _ = Describe("CRD Versions", func() {
},
}

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

// Attempt to get the catalog source before creating install plan
By("Attempt to get the catalog source before creating install plan")

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

installPlanName := subscription.Status.InstallPlanRef.Name

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

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

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

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

installPlanName := subscription.Status.InstallPlanRef.Name

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

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

// fetch new subscription
By("fetch new subscription")
s, err := fetchSubscription(crc, generatedNamespace.GetName(), subscriptionName, subscriptionAtLatestWithDifferentInstallPlan)
Expect(err).ToNot(HaveOccurred())
Expect(s).ToNot(BeNil())
Expect(s.Status.InstallPlanRef).ToNot(Equal(nil))

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

// Create a CRD on cluster with v1alpha1 (storage)
// Update that CRD with v1alpha2 (storage), v1alpha1 (served)
// Now the CRD should have two versions in status.storedVersions
// Now make a catalog with a CRD with just v1alpha2 (storage)
// That should fail because v1alpha1 is still in status.storedVersions - risk of data loss
// Update the CRD status to remove the v1alpha1
// Now the installplan should succeed

It("allows a CRD upgrade that doesn't cause data loss", func() {
By(`Create a CRD on cluster with v1alpha1 (storage)`)
By(`Update that CRD with v1alpha2 (storage), v1alpha1 (served)`)
By(`Now the CRD should have two versions in status.storedVersions`)
By(`Now make a catalog with a CRD with just v1alpha2 (storage)`)
By(`That should fail because v1alpha1 is still in status.storedVersions - risk of data loss`)
By(`Update the CRD status to remove the v1alpha1`)
By(`Now the installplan should succeed`)

By("manually editing the storage versions in the existing CRD status")

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

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

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

// create CSV and catalog with just the catalog CRD
By("create CSV and catalog with just the catalog CRD")
catalogCRD := apiextensionsv1.CustomResourceDefinition{
ObjectMeta: metav1.ObjectMeta{
Name: crdName,
Expand Down Expand Up @@ -417,11 +417,11 @@ var _ = Describe("CRD Versions", func() {
},
}

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

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

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

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

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

// install should now succeed
By("install should now succeed")
oldInstallPlanRef := subscription.Status.InstallPlanRef.Name
err = crc.OperatorsV1alpha1().InstallPlans(generatedNamespace.GetName()).Delete(context.TODO(), subscription.Status.InstallPlanRef.Name, metav1.DeleteOptions{})
Expect(err).ToNot(HaveOccurred(), "error deleting failed install plan")
// remove old subscription
By("remove old subscription")
err = crc.OperatorsV1alpha1().Subscriptions(generatedNamespace.GetName()).Delete(context.TODO(), subscription.GetName(), metav1.DeleteOptions{})
Expect(err).ToNot(HaveOccurred(), "error deleting old subscription")
// remove old csv
By("remove old csv")
crc.OperatorsV1alpha1().ClusterServiceVersions(generatedNamespace.GetName()).Delete(context.TODO(), mainPackageStable, metav1.DeleteOptions{})
Expect(err).ToNot(HaveOccurred(), "error deleting old subscription")

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

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

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

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