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

Improvements to the E2E tests #336

Merged
merged 3 commits into from
Apr 11, 2023
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
2 changes: 1 addition & 1 deletion controllers/metallb_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (r *MetalLBReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
}
}
if err := status.Update(context.TODO(), r.Client, instance, condition, errorMsg, wrappedErrMsg); err != nil {
logger.Info("Failed to update metallb status", "Desired status", status.ConditionAvailable)
logger.Error(err, "Failed to update metallb status", "Desired status", status.ConditionAvailable)
}
}
return result, err
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/functional/tests/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ var _ = Describe("metallb", func() {
Expect(daemonset.OwnerReferences).ToNot(BeNil())
Expect(daemonset.OwnerReferences[0].Kind).To(Equal("MetalLB"))

metallbutils.Delete(metallb)
metallbutils.DeleteAndCheck(metallb)
}
})

Expand Down Expand Up @@ -209,7 +209,7 @@ var _ = Describe("metallb", func() {

AfterEach(func() {
metallbutils.Delete(incorrect_metallb)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the right way to do is to revise Delete and have it "just" delete, and moving the check logic in another function, OR having a Delete and a DeleteAndCheck

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

metallbutils.Delete(correct_metallb)
metallbutils.DeleteAndCheck(correct_metallb)
})
It("should have correct statuses", func() {
By("checking MetalLB resource status", func() {
Expand Down Expand Up @@ -261,7 +261,7 @@ var _ = Describe("metallb", func() {
})

AfterEach(func() {
metallbutils.Delete(correct_metallb)
metallbutils.DeleteAndCheck(correct_metallb)
metallbutils.DeletePriorityClass(priorityClass)
})

Expand Down Expand Up @@ -388,7 +388,7 @@ var _ = Describe("metallb", func() {
return nil
}, metallbutils.DeployTimeout, metallbutils.Interval).ShouldNot(HaveOccurred())

metallbutils.Delete(metallb)
metallbutils.DeleteAndCheck(metallb)
})
})
})
Expand All @@ -407,7 +407,7 @@ var _ = Describe("metallb", func() {
})

AfterEach(func() {
metallbutils.Delete(metallb)
metallbutils.DeleteAndCheck(metallb)
metallbutils.DeletePriorityClass(priorityClass)
})
It("patch additional parameters", func() {
Expand Down Expand Up @@ -557,7 +557,7 @@ var _ = Describe("metallb", func() {
})

AfterEach(func() {
metallbutils.Delete(correct_metallb)
metallbutils.DeleteAndCheck(correct_metallb)
})
It("validate create with incorrect toleration", func() {
metallb := metallbutils.New(OperatorNameSpace, func(m *metallbv1beta1.MetalLB) {
Expand Down Expand Up @@ -634,7 +634,7 @@ var _ = Describe("metallb", func() {
}
})
Expect(testclient.Client.Create(context.Background(), metallb)).Should(Succeed())
metallbutils.Delete(metallb)
metallbutils.DeleteAndCheck(metallb)
metallb = metallbutils.New(OperatorNameSpace, func(m *metallbv1beta1.MetalLB) {
m.Spec.SpeakerConfig = &metallbv1beta1.Config{
Affinity: &v1.Affinity{NodeAffinity: &v1.NodeAffinity{PreferredDuringSchedulingIgnoredDuringExecution: []v1.PreferredSchedulingTerm{
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/metallb/metallb.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func Delete(metallb *metallbv1beta1.MetalLB) {
return
}
Expect(err).ToNot(HaveOccurred())
}

func DeleteAndCheck(metallb *metallbv1beta1.MetalLB) {
Delete(metallb)

Eventually(func() bool {
err := testclient.Client.Get(context.Background(), goclient.ObjectKey{Namespace: metallb.Namespace, Name: metallb.Name}, metallb)
Expand Down