Skip to content

Commit aaba54c

Browse files
authored
Merge pull request #825 from SchSeba/rdma-functest
Rdma functional tests improvements
2 parents 7990611 + 009c45f commit aaba54c

File tree

1 file changed

+80
-52
lines changed

1 file changed

+80
-52
lines changed

test/conformance/tests/test_networkpool.go

Lines changed: 80 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
var _ = Describe("[sriov] NetworkPool", Ordered, func() {
2828
var testNode string
2929
var interfaces []*sriovv1.InterfaceExt
30+
var resourceName = "testrdma"
3031

3132
BeforeAll(func() {
3233
err := namespaces.Create(namespaces.Test, clients)
@@ -68,10 +69,12 @@ var _ = Describe("[sriov] NetworkPool", Ordered, func() {
6869
By("waiting for operator to finish the configuration")
6970
WaitForSRIOVStable()
7071
nodeState := &sriovv1.SriovNetworkNodeState{}
71-
err = clients.Get(context.Background(), client.ObjectKey{Name: testNode, Namespace: operatorNamespace}, nodeState)
72-
Expect(err).ToNot(HaveOccurred())
73-
Expect(nodeState.Spec.System.RdmaMode).To(Equal(consts.RdmaSubsystemModeExclusive))
74-
Expect(nodeState.Status.System.RdmaMode).To(Equal(consts.RdmaSubsystemModeExclusive))
72+
Eventually(func(g Gomega) {
73+
err = clients.Get(context.Background(), client.ObjectKey{Name: testNode, Namespace: operatorNamespace}, nodeState)
74+
g.Expect(err).ToNot(HaveOccurred())
75+
g.Expect(nodeState.Spec.System.RdmaMode).To(Equal(consts.RdmaSubsystemModeExclusive))
76+
g.Expect(nodeState.Status.System.RdmaMode).To(Equal(consts.RdmaSubsystemModeExclusive))
77+
}, 20*time.Minute, 5*time.Second).Should(Succeed())
7578

7679
By("Checking rdma mode and kernel args")
7780
cmdlineOutput, _, err := runCommandOnConfigDaemon(testNode, "/bin/bash", "-c", "cat /host/proc/cmdline")
@@ -85,14 +88,22 @@ var _ = Describe("[sriov] NetworkPool", Ordered, func() {
8588
Expect(strings.HasPrefix(output, "1")).To(BeTrue())
8689

8790
By("configure rdma mode to shared")
88-
networkPool.Spec.RdmaMode = consts.RdmaSubsystemModeShared
89-
err = clients.Update(context.Background(), networkPool)
90-
Expect(err).ToNot(HaveOccurred())
91+
Eventually(func(g Gomega) {
92+
err = clients.Get(context.Background(), client.ObjectKey{Name: testNode, Namespace: operatorNamespace}, networkPool)
93+
g.Expect(err).ToNot(HaveOccurred())
94+
networkPool.Spec.RdmaMode = consts.RdmaSubsystemModeShared
95+
err = clients.Update(context.Background(), networkPool)
96+
g.Expect(err).ToNot(HaveOccurred())
97+
}, time.Minute, 5*time.Second).Should(Succeed())
98+
99+
By("waiting for operator to finish the configuration")
91100
WaitForSRIOVStable()
92-
err = clients.Get(context.Background(), client.ObjectKey{Name: testNode, Namespace: operatorNamespace}, nodeState)
93-
Expect(err).ToNot(HaveOccurred())
94-
Expect(nodeState.Spec.System.RdmaMode).To(Equal(consts.RdmaSubsystemModeShared))
95-
Expect(nodeState.Status.System.RdmaMode).To(Equal(consts.RdmaSubsystemModeShared))
101+
Eventually(func(g Gomega) {
102+
err = clients.Get(context.Background(), client.ObjectKey{Name: testNode, Namespace: operatorNamespace}, nodeState)
103+
g.Expect(err).ToNot(HaveOccurred())
104+
g.Expect(nodeState.Spec.System.RdmaMode).To(Equal(consts.RdmaSubsystemModeShared))
105+
g.Expect(nodeState.Status.System.RdmaMode).To(Equal(consts.RdmaSubsystemModeShared))
106+
}, 20*time.Minute, 5*time.Second).Should(Succeed())
96107

97108
By("Checking rdma mode and kernel args")
98109
cmdlineOutput, _, err = runCommandOnConfigDaemon(testNode, "/bin/bash", "-c", "cat /host/proc/cmdline")
@@ -107,16 +118,20 @@ var _ = Describe("[sriov] NetworkPool", Ordered, func() {
107118

108119
By("removing rdma mode configuration")
109120
Eventually(func(g Gomega) {
121+
err = clients.Get(context.Background(), client.ObjectKey{Name: testNode, Namespace: operatorNamespace}, networkPool)
122+
g.Expect(err).ToNot(HaveOccurred())
110123
err = clients.Delete(context.Background(), networkPool)
111124
g.Expect(err).ToNot(HaveOccurred())
112125
}, 5*time.Minute, 5*time.Second).Should(Succeed())
113126

127+
By("waiting for operator to finish the configuration")
114128
WaitForSRIOVStable()
115-
116-
err = clients.Get(context.Background(), client.ObjectKey{Name: testNode, Namespace: operatorNamespace}, nodeState)
117-
Expect(err).ToNot(HaveOccurred())
118-
Expect(nodeState.Spec.System.RdmaMode).To(Equal(""))
119-
Expect(nodeState.Status.System.RdmaMode).To(Equal(consts.RdmaSubsystemModeShared))
129+
Eventually(func(g Gomega) {
130+
err = clients.Get(context.Background(), client.ObjectKey{Name: testNode, Namespace: operatorNamespace}, nodeState)
131+
g.Expect(err).ToNot(HaveOccurred())
132+
g.Expect(nodeState.Spec.System.RdmaMode).To(Equal(""))
133+
g.Expect(nodeState.Status.System.RdmaMode).To(Equal(consts.RdmaSubsystemModeShared))
134+
}, 20*time.Minute, 5*time.Second).Should(Succeed())
120135

121136
By("Checking rdma mode and kernel args")
122137
cmdlineOutput, _, err = runCommandOnConfigDaemon(testNode, "/bin/bash", "-c", "cat /host/proc/cmdline")
@@ -150,25 +165,6 @@ var _ = Describe("[sriov] NetworkPool", Ordered, func() {
150165
Skip("no mellanox card available to test rdma")
151166
}
152167

153-
networkPool := &sriovv1.SriovNetworkPoolConfig{
154-
ObjectMeta: metav1.ObjectMeta{Name: testNode, Namespace: operatorNamespace},
155-
Spec: sriovv1.SriovNetworkPoolConfigSpec{RdmaMode: consts.RdmaSubsystemModeExclusive,
156-
NodeSelector: &metav1.LabelSelector{MatchLabels: map[string]string{"kubernetes.io/hostname": testNode}}}}
157-
158-
err = clients.Create(context.Background(), networkPool)
159-
Expect(err).ToNot(HaveOccurred())
160-
By("waiting for operator to finish the configuration")
161-
WaitForSRIOVStable()
162-
})
163-
164-
It("should run pod with RDMA cni and expose nic metrics and another one without rdma info", func() {
165-
By("creating a policy")
166-
resourceName := "testrdma"
167-
_, err := network.CreateSriovPolicy(clients, "test-policy-", operatorNamespace, iface.Name, testNode, 5, resourceName, "netdevice",
168-
func(policy *sriovv1.SriovNetworkNodePolicy) { policy.Spec.IsRdma = true })
169-
Expect(err).ToNot(HaveOccurred())
170-
WaitForSRIOVStable()
171-
172168
By("Creating sriov network to use the rdma device")
173169
sriovNetwork := &sriovv1.SriovNetwork{
174170
ObjectMeta: metav1.ObjectMeta{
@@ -201,6 +197,32 @@ var _ = Describe("[sriov] NetworkPool", Ordered, func() {
201197
Expect(err).ToNot(HaveOccurred())
202198
waitForNetAttachDef("test-nordmanetwork", namespaces.Test)
203199

200+
networkPool := &sriovv1.SriovNetworkPoolConfig{
201+
ObjectMeta: metav1.ObjectMeta{Name: testNode, Namespace: operatorNamespace},
202+
Spec: sriovv1.SriovNetworkPoolConfigSpec{RdmaMode: consts.RdmaSubsystemModeExclusive,
203+
NodeSelector: &metav1.LabelSelector{MatchLabels: map[string]string{"kubernetes.io/hostname": testNode}}}}
204+
err = clients.Create(context.Background(), networkPool)
205+
Expect(err).ToNot(HaveOccurred())
206+
207+
By("waiting for operator to finish the configuration")
208+
WaitForSRIOVStable()
209+
nodeState := &sriovv1.SriovNetworkNodeState{}
210+
Eventually(func(g Gomega) {
211+
err = clients.Get(context.Background(), client.ObjectKey{Name: testNode, Namespace: operatorNamespace}, nodeState)
212+
g.Expect(err).ToNot(HaveOccurred())
213+
g.Expect(nodeState.Spec.System.RdmaMode).To(Equal(consts.RdmaSubsystemModeExclusive))
214+
g.Expect(nodeState.Status.System.RdmaMode).To(Equal(consts.RdmaSubsystemModeExclusive))
215+
}, 20*time.Minute, 5*time.Second).Should(Succeed())
216+
})
217+
218+
It("should run pod with RDMA cni and expose nic metrics and another one without rdma info", func() {
219+
By("creating a policy")
220+
_, err := network.CreateSriovPolicy(clients, "test-policy-", operatorNamespace, iface.Name, testNode, 5, resourceName, "netdevice",
221+
func(policy *sriovv1.SriovNetworkNodePolicy) { policy.Spec.IsRdma = true })
222+
Expect(err).ToNot(HaveOccurred())
223+
224+
By("waiting for operator to finish the configuration")
225+
WaitForSRIOVStable()
204226
podDefinition := pod.DefineWithNetworks([]string{"test-rdmanetwork"})
205227
firstPod, err := clients.Pods(namespaces.Test).Create(context.Background(), podDefinition, metav1.CreateOptions{})
206228
Expect(err).ToNot(HaveOccurred())
@@ -287,6 +309,22 @@ var _ = Describe("[sriov] NetworkPool", Ordered, func() {
287309
Skip("no mellanox card available to test rdma")
288310
}
289311

312+
By("Creating sriov network to use the rdma device")
313+
sriovNetwork := &sriovv1.SriovNetwork{
314+
ObjectMeta: metav1.ObjectMeta{
315+
Name: "test-rdmanetwork",
316+
Namespace: operatorNamespace,
317+
},
318+
Spec: sriovv1.SriovNetworkSpec{
319+
ResourceName: resourceName,
320+
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181"}`,
321+
NetworkNamespace: namespaces.Test,
322+
}}
323+
324+
err = clients.Create(context.Background(), sriovNetwork)
325+
Expect(err).ToNot(HaveOccurred())
326+
waitForNetAttachDef("test-rdmanetwork", namespaces.Test)
327+
290328
networkPool := &sriovv1.SriovNetworkPoolConfig{
291329
ObjectMeta: metav1.ObjectMeta{Name: testNode, Namespace: operatorNamespace},
292330
Spec: sriovv1.SriovNetworkPoolConfigSpec{RdmaMode: consts.RdmaSubsystemModeShared,
@@ -296,32 +334,22 @@ var _ = Describe("[sriov] NetworkPool", Ordered, func() {
296334
Expect(err).ToNot(HaveOccurred())
297335
By("waiting for operator to finish the configuration")
298336
WaitForSRIOVStable()
337+
nodeState := &sriovv1.SriovNetworkNodeState{}
338+
Eventually(func(g Gomega) {
339+
err = clients.Get(context.Background(), client.ObjectKey{Name: testNode, Namespace: operatorNamespace}, nodeState)
340+
g.Expect(err).ToNot(HaveOccurred())
341+
g.Expect(nodeState.Spec.System.RdmaMode).To(Equal(consts.RdmaSubsystemModeShared))
342+
g.Expect(nodeState.Status.System.RdmaMode).To(Equal(consts.RdmaSubsystemModeShared))
343+
}, 20*time.Minute, 5*time.Second).Should(Succeed())
299344
})
300345

301346
It("should run pod without RDMA cni and not expose nic metrics", func() {
302347
By("creating a policy")
303-
resourceName := "testrdma"
304348
_, err := network.CreateSriovPolicy(clients, "test-policy-", operatorNamespace, iface.Name, testNode, 5, resourceName, "netdevice",
305349
func(policy *sriovv1.SriovNetworkNodePolicy) { policy.Spec.IsRdma = true })
306350
Expect(err).ToNot(HaveOccurred())
307351
WaitForSRIOVStable()
308352

309-
By("Creating sriov network to use the rdma device")
310-
sriovNetwork := &sriovv1.SriovNetwork{
311-
ObjectMeta: metav1.ObjectMeta{
312-
Name: "test-rdmanetwork",
313-
Namespace: operatorNamespace,
314-
},
315-
Spec: sriovv1.SriovNetworkSpec{
316-
ResourceName: resourceName,
317-
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181"}`,
318-
NetworkNamespace: namespaces.Test,
319-
}}
320-
321-
err = clients.Create(context.Background(), sriovNetwork)
322-
Expect(err).ToNot(HaveOccurred())
323-
waitForNetAttachDef("test-rdmanetwork", namespaces.Test)
324-
325353
podDefinition := pod.DefineWithNetworks([]string{"test-rdmanetwork"})
326354
firstPod, err := clients.Pods(namespaces.Test).Create(context.Background(), podDefinition, metav1.CreateOptions{})
327355
Expect(err).ToNot(HaveOccurred())

0 commit comments

Comments
 (0)