diff --git a/controllers/sriovnetworknodepolicy_controller_test.go b/controllers/sriovnetworknodepolicy_controller_test.go index abdddbc91..29d2266da 100644 --- a/controllers/sriovnetworknodepolicy_controller_test.go +++ b/controllers/sriovnetworknodepolicy_controller_test.go @@ -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()) + + }) + }) })