Skip to content

Commit

Permalink
Fixing flake tests so they don't fail 100% of the time.
Browse files Browse the repository at this point in the history
E2E tests were updated recently to use a generated namespace with an OperatorGroup created from the beginning of each test. However some of the tests were not updated to reflect this and were still creating and deleting resources in an additional namespace, or began to fail because the test environment required that no OperatorGroups exist from the beginning of the test.

This commit addresses two tests that have been failing at a rate of 100% due to the issues stated above.

Signed-off-by: Daniel Franz <dfranz@redhat.com>
  • Loading branch information
dtfranz committed Oct 19, 2023
1 parent 647fe25 commit 91b5762
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions test/e2e/installplan_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3076,22 +3076,6 @@ var _ = Describe("Install Plan", func() {
GinkgoT().Logf("%s: %s", time.Now().Format("15:04:05.9999"), s)
}

ns := &corev1.Namespace{}
ns.SetName(genName("ns-"))

// Create a namespace an OperatorGroup
ns, err := c.KubernetesInterface().CoreV1().Namespaces().Create(context.Background(), ns, metav1.CreateOptions{})
require.NoError(GinkgoT(), err)
deleteOpts := &metav1.DeleteOptions{}
defer func() {
require.NoError(GinkgoT(), c.KubernetesInterface().CoreV1().Namespaces().Delete(context.Background(), generatedNamespace.GetName(), *deleteOpts))
}()

og := &operatorsv1.OperatorGroup{}
og.SetName("og")
_, err = crc.OperatorsV1().OperatorGroups(generatedNamespace.GetName()).Create(context.Background(), og, metav1.CreateOptions{})
require.NoError(GinkgoT(), err)

mainPackageName := genName("nginx-")
dependentPackageName := genName("nginxdep-")

Expand Down Expand Up @@ -3210,6 +3194,7 @@ var _ = Describe("Install Plan", func() {
require.NoError(GinkgoT(), err)

// Make sure to clean up the installed CRD
deleteOpts := &metav1.DeleteOptions{}
defer func() {
require.NoError(GinkgoT(), c.ApiextensionsInterface().ApiextensionsV1().CustomResourceDefinitions().Delete(context.Background(), dependentCRD.GetName(), *deleteOpts))
}()
Expand All @@ -3223,17 +3208,11 @@ var _ = Describe("Install Plan", func() {
When("an InstallPlan is created with no valid OperatorGroup present", func() {
var (
installPlanName string
ns *corev1.Namespace
)

BeforeEach(func() {
ns = &corev1.Namespace{}
ns.SetName(genName("ns-"))

// Create a namespace
Eventually(func() error {
return ctx.Ctx().Client().Create(context.Background(), ns)
}, timeout, interval).Should(Succeed(), "could not create Namespace")
// Make sure there are no OGs in the namespace already
require.NoError(GinkgoT(), crc.OperatorsV1().OperatorGroups(generatedNamespace.GetName()).DeleteCollection(context.Background(), metav1.DeleteOptions{}, metav1.ListOptions{}))

// Create InstallPlan
installPlanName = "ip"
Expand All @@ -3252,8 +3231,6 @@ var _ = Describe("Install Plan", func() {
AfterEach(func() {
err := crc.OperatorsV1alpha1().InstallPlans(generatedNamespace.GetName()).Delete(context.Background(), installPlanName, metav1.DeleteOptions{})
Expect(err).NotTo(HaveOccurred())
err = c.KubernetesInterface().CoreV1().Namespaces().Delete(context.Background(), generatedNamespace.GetName(), metav1.DeleteOptions{})
Expect(err).ToNot(HaveOccurred())
})

// issue: https://github.com/operator-framework/operator-lifecycle-manager/issues/2636
Expand Down

0 comments on commit 91b5762

Please sign in to comment.