Skip to content

Commit

Permalink
Unit test for RdmaMode
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Panattoni <[email protected]>
  • Loading branch information
zeeke committed Dec 5, 2024
1 parent 5f492e5 commit 8b2d83f
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions controllers/sriovnetworknodepolicy_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,44 @@ var _ = Describe("SriovnetworkNodePolicy controller", Ordered, func() {
}, time.Minute, time.Second).Should(Succeed())
})
})

Context("RdmaMode", func() {
It("field is correctly written to the SriovNetworkNodePolicy", func() {
node := &corev1.Node{ObjectMeta: metav1.ObjectMeta{
Name: "node0",
Labels: map[string]string{
"node-role.kubernetes.io/worker": "",
"kubernetes.io/os": "linux",
"test": "",
},
}}
Expect(k8sClient.Create(ctx, node)).To(Succeed())

nodeState := &sriovnetworkv1.SriovNetworkNodeState{}
Eventually(func(g Gomega) {
err := k8sClient.Get(context.TODO(), k8sclient.ObjectKey{Name: "node0", Namespace: testNamespace}, nodeState)
g.Expect(err).ToNot(HaveOccurred())
}, time.Minute, time.Second).Should(Succeed())

poolConfig := &sriovnetworkv1.SriovNetworkPoolConfig{}
poolConfig.SetNamespace(testNamespace)
poolConfig.SetName("test-workers")
poolConfig.Spec = sriovnetworkv1.SriovNetworkPoolConfigSpec{
NodeSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"test": "",
},
},
RdmaMode: "exclusive",
}
Expect(k8sClient.Create(ctx, poolConfig)).To(Succeed())

Eventually(func(g Gomega) {
err := k8sClient.Get(context.Background(), k8sclient.ObjectKey{Name: node.Name, Namespace: testNamespace}, nodeState)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(nodeState.Spec.System.RdmaMode).To(Equal("exclusive"))
}).WithPolling(time.Second).WithTimeout(time.Minute).Should(Succeed())

})
})
})

0 comments on commit 8b2d83f

Please sign in to comment.