Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mtu functional test #699

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading