Skip to content

Commit

Permalink
Add test for multiple updates to the node selector of the config daemon
Browse files Browse the repository at this point in the history
It was found that updating the node selector may not be applied. This
test ensures that we catch any problems with the node selector being
modified.

Signed-off-by: William Zhao <[email protected]>
  • Loading branch information
wizhaoredhat committed Aug 29, 2023
1 parent 25a291e commit bf30003
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions controllers/sriovoperatorconfig_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,27 @@ var _ = Describe("Operator", func() {
}, timeout*10, interval).Should(Equal(config.Spec.ConfigDaemonNodeSelector))
})

It("should be able to do multiple updates to the node selector of sriov-network-config-daemon", func() {
By("changing the configDaemonNodeSelector")
config := &sriovnetworkv1.SriovOperatorConfig{}
err := util.WaitForNamespacedObject(config, k8sClient, testNamespace, "default", interval, timeout)
Expect(err).NotTo(HaveOccurred())
config.Spec.ConfigDaemonNodeSelector = map[string]string{"labelA": "", "labelB": "", "labelC": ""}
err = k8sClient.Update(goctx.TODO(), config)
Expect(err).NotTo(HaveOccurred())
config.Spec.ConfigDaemonNodeSelector = map[string]string{"labelA": "", "labelB": ""}
err = k8sClient.Update(goctx.TODO(), config)
Expect(err).NotTo(HaveOccurred())

daemonSet := &appsv1.DaemonSet{}
Eventually(func() map[string]string {
err := k8sClient.Get(goctx.TODO(), types.NamespacedName{Name: "sriov-network-config-daemon", Namespace: testNamespace}, daemonSet)
if err != nil {
return nil
}
return daemonSet.Spec.Template.Spec.NodeSelector
}, timeout*10, interval).Should(Equal(config.Spec.ConfigDaemonNodeSelector))
})

})
})

0 comments on commit bf30003

Please sign in to comment.