Skip to content

Commit

Permalink
Merge pull request #699 from SchSeba/add_mtu_func_test
Browse files Browse the repository at this point in the history
Add mtu functional test
  • Loading branch information
zeeke committed Jun 5, 2024
2 parents d0f214e + c17d336 commit 20c5e5b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hack/run-e2e-conformance-virtual-ocp.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -xeo pipefail

OCP_VERSION=${OCP_VERSION:-4.14.0-rc.6}
OCP_VERSION=${OCP_VERSION:-4.16.0-rc.1}
cluster_name=${CLUSTER_NAME:-ocp-virt}
domain_name=lab

Expand Down
3 changes: 3 additions & 0 deletions hack/virtual-cluster-redeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ else
export SRIOV_NETWORK_OPERATOR_IMAGE="$controller_ip:5000/sriov-network-operator:latest"
export SRIOV_NETWORK_CONFIG_DAEMON_IMAGE="$controller_ip:5000/sriov-network-config-daemon:latest"
export SRIOV_NETWORK_WEBHOOK_IMAGE="$controller_ip:5000/sriov-network-operator-webhook:latest"

export ADMISSION_CONTROLLERS_CERTIFICATES_CERT_MANAGER_ENABLED=true
export CNI_BIN_PATH=/opt/cni/bin
fi

export ADMISSION_CONTROLLERS_ENABLED=true
Expand Down
37 changes: 36 additions & 1 deletion test/conformance/tests/test_sriov_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ var _ = Describe("[sriov] operator", func() {
By("Using device " + vfioNic.Name + " on node " + vfioNode)
})

It("Should be possible to create a vfio-pci resource", func() {
It("Should be possible to create a vfio-pci resource and allocate to a pod", func() {
By("creating a vfio-pci node policy")
resourceName := "testvfio"
_, err := network.CreateSriovPolicy(clients, "test-policy-", operatorNamespace, vfioNic.Name, vfioNode, 5, resourceName, "vfio-pci")
Expand Down Expand Up @@ -1157,6 +1157,36 @@ var _ = Describe("[sriov] operator", func() {
allocatable, _ := resNum.AsInt64()
return allocatable
}, 10*time.Minute, time.Second).Should(Equal(int64(5)))

By("Creating sriov network to use the vfio device")
sriovNetwork := &sriovv1.SriovNetwork{
ObjectMeta: metav1.ObjectMeta{
Name: "test-vfionetwork",
Namespace: operatorNamespace,
},
Spec: sriovv1.SriovNetworkSpec{
ResourceName: resourceName,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181","routes":[{"dst":"0.0.0.0/0"}],"gateway":"10.10.10.1"}`,
NetworkNamespace: namespaces.Test,
}}

err = clients.Create(context.Background(), sriovNetwork)
Expect(err).ToNot(HaveOccurred())
waitForNetAttachDef("test-vfionetwork", namespaces.Test)

podDefinition := pod.DefineWithNetworks([]string{"test-vfionetwork"})
firstPod, err := clients.Pods(namespaces.Test).Create(context.Background(), podDefinition, metav1.CreateOptions{})
Expect(err).ToNot(HaveOccurred())

Eventually(func() corev1.PodPhase {
firstPod, _ = clients.Pods(namespaces.Test).Get(context.Background(), firstPod.Name, metav1.GetOptions{})
return firstPod.Status.Phase
}, 3*time.Minute, time.Second).Should(Equal(corev1.PodRunning))

By("Checking MTU in pod network status annotation")
networkStatusJSON, exist := firstPod.Annotations["k8s.v1.cni.cncf.io/network-status"]
Expect(exist).To(BeTrue())
Expect(networkStatusJSON).To(ContainSubstring(fmt.Sprintf("\"mtu\": %d", vfioNic.Mtu)))
})
})

Expand Down Expand Up @@ -1619,6 +1649,11 @@ var _ = Describe("[sriov] operator", func() {
return firstPod.Status.Phase
}, 3*time.Minute, time.Second).Should(Equal(corev1.PodRunning))

By("Checking MTU in pod network status annotation")
networkStatusJSON, exist := firstPod.Annotations["k8s.v1.cni.cncf.io/network-status"]
Expect(exist).To(BeTrue())
Expect(networkStatusJSON).To(ContainSubstring("\"mtu\": 9000"))

var stdout, stderr string
Eventually(func() error {
stdout, stderr, err = pod.ExecCommand(clients, firstPod, "ip", "link", "show", "net1")
Expand Down

0 comments on commit 20c5e5b

Please sign in to comment.