Skip to content

Commit

Permalink
test: unit test for topolvm node daemonset
Browse files Browse the repository at this point in the history
Verify node daemonset creation and deletion using the controller unit test

Signed-off-by: Juan Miguel Olmo Martínez <[email protected]>
  • Loading branch information
jmolmo committed Dec 20, 2021
1 parent 1e6480f commit 19f72a2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion controllers/lvmcluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ var _ = Describe("LVMCluster controller", func() {
controllerName := types.NamespacedName{Name: TopolvmControllerDeploymentName, Namespace: testLvmClusterNamespace}
controllerOut := &appsv1.Deployment{}

// CSI Node resource
csiNodeName := types.NamespacedName{Namespace: testLvmClusterNamespace, Name: TopolvmNodeDaemonsetName}
csiNodeOut := &appsv1.DaemonSet{}

Context("Reconciliation on creating an LVMCluster CR", func() {
It("should reconcile LVMCluster CR creation, ", func() {
By("verifying CR status.Ready is set to true on reconciliation")
Expand All @@ -81,6 +85,12 @@ var _ = Describe("LVMCluster controller", func() {
err := k8sClient.Get(ctx, controllerName, controllerOut)
return err == nil
}, timeout, interval).Should(BeTrue())

By("confirming the existence of CSI Node resource")
Eventually(func() bool {
err := k8sClient.Get(ctx, csiNodeName, csiNodeOut)
return err == nil
}, timeout, interval).Should(BeTrue())
})
})

Expand All @@ -100,13 +110,18 @@ var _ = Describe("LVMCluster controller", func() {
return errors.IsNotFound(err)
}, timeout, interval).Should(BeTrue())

// auto deletion of Topolvm Controller deployment based on CR deletion
By("confirming absence of Topolvm Controller Deployment")
Eventually(func() bool {
err := k8sClient.Get(ctx, controllerName, controllerOut)
return errors.IsNotFound(err)
}, timeout, interval).Should(BeTrue())

By("confirming absence of CSI Node Resource")
Eventually(func() bool {
err := k8sClient.Get(ctx, csiNodeName, csiNodeOut)
return errors.IsNotFound(err)
}, timeout, interval).Should(BeTrue())

By("confirming absence of LVMCluster CR")
Eventually(func() bool {
err := k8sClient.Get(ctx, lvmClusterName, lvmClusterOut)
Expand Down

0 comments on commit 19f72a2

Please sign in to comment.