Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Improve SnapshotSchedule tests
  • Loading branch information
sklarsa committed Jun 21, 2023
commit fa42b5c2c9bb9fc02f82f0b0cbdd160bdabf5018
26 changes: 17 additions & 9 deletions internal/controller/questdbsnapshotschedule_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ var _ = Describe("QuestDBSnapshotSchedule Controller", func() {
timeSource.Advance(time.Minute + 10*time.Second)

By("Forcing a reconcile")
_, err := r.Reconcile(ctx, ctrl.Request{
res, err := r.Reconcile(ctx, ctrl.Request{
NamespacedName: client.ObjectKeyFromObject(sched),
})
Expect(res).To(Equal(ctrl.Result{}))
Expect(err).ToNot(HaveOccurred())

By("Checking that a snapshot has been created")
Expand All @@ -102,9 +103,10 @@ var _ = Describe("QuestDBSnapshotSchedule Controller", func() {
}, timeout, interval).Should(Succeed())

By("Forcing a reconcile")
_, err := r.Reconcile(ctx, ctrl.Request{
res, err := r.Reconcile(ctx, ctrl.Request{
NamespacedName: client.ObjectKeyFromObject(sched),
})
Expect(res).To(Equal(ctrl.Result{}))
Expect(err).ToNot(HaveOccurred())

By("Checking that the status has been updated")
Expand All @@ -117,15 +119,18 @@ var _ = Describe("QuestDBSnapshotSchedule Controller", func() {
timeSource.Advance(time.Minute + 10*time.Second)

By("Forcing a reconcile")
_, err := r.Reconcile(ctx, ctrl.Request{
res, err := r.Reconcile(ctx, ctrl.Request{
NamespacedName: client.ObjectKeyFromObject(sched),
})
Expect(res).To(Equal(ctrl.Result{}))
Expect(err).ToNot(HaveOccurred())

By("Checking that a snapshot has been created")
snapList := &crdv1beta1.QuestDBSnapshotList{}
Expect(k8sClient.List(ctx, snapList, client.InNamespace(sched.Namespace))).Should(Succeed())
Expect(snapList.Items).To(HaveLen(2))
Eventually(func(g Gomega) {
snapList := &crdv1beta1.QuestDBSnapshotList{}
g.Expect(k8sClient.List(ctx, snapList, client.InNamespace(sched.Namespace))).Should(Succeed())
g.Expect(snapList.Items).To(HaveLen(2))
}, timeout, interval).Should(Succeed())
})

It("should requeue the request to the time of the next trigger", func() {
Expand Down Expand Up @@ -157,14 +162,17 @@ var _ = Describe("QuestDBSnapshotSchedule Controller", func() {
}

By("Forcing a reconcile")
_, err := r.Reconcile(ctx, ctrl.Request{
res, err := r.Reconcile(ctx, ctrl.Request{
NamespacedName: client.ObjectKeyFromObject(sched),
})
Expect(err).ToNot(HaveOccurred())
Expect(res).To(Equal(ctrl.Result{})

By("Checking that a snapshot has been deleted")
Expect(k8sClient.List(ctx, snapList, client.InNamespace(sched.Namespace))).Should(Succeed())
Expect(snapList.Items).To(HaveLen(1))
Eventually(func(g Gomega) {
g.Expect(k8sClient.List(ctx, snapList, client.InNamespace(sched.Namespace))).Should(Succeed())
g.Expect(snapList.Items).To(HaveLen(1))
}, timeout, interval).Should(Succeed())
})

})
Expand Down