2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
13 ethernet_adpator_version=$( lspci | grep "Ethernet Controller XL710" | head -n 1 | cut -d " " -f 8 )
14 if [ -z "$ethernet_adpator_version" ]; then
15 echo " Ethernet adapator version is not set. SRIOV test case cannot run on this machine"
18 #checking for the right hardware version of NIC on the machine
19 if [ $ethernet_adpator_version == "XL710" ]; then
20 echo "NIC card specs match. SRIOV option avaiable for this version."
22 echo -e "Failed. The version supplied does not match.\nTest cannot be executed."
28 function create_pod_yaml_with_single_VF {
30 cat << POD > $HOME/$pod_name-single.yaml
36 k8s.v1.cni.cncf.io/networks: sriov-eno2
40 image: docker.io/centos/tools:latest
45 intel.com/intel_sriov_700: '1'
47 intel.com/intel_sriov_700: '1'
51 function create_pod_yaml_with_multiple_VF {
53 cat << POD > $HOME/$pod_name-multiple.yaml
59 k8s.v1.cni.cncf.io/networks: sriov-eno2, sriov-eno2
63 image: docker.io/centos/tools:latest
68 intel.com/intel_sriov_700: '2'
70 intel.com/intel_sriov_700: '2'
73 create_pod_yaml_with_single_VF
74 create_pod_yaml_with_multiple_VF
76 for podType in ${POD_TYPE:-single multiple}; do
78 kubectl delete pod $pod_name --ignore-not-found=true --now --wait
79 allocated_node_resource=$(kubectl describe node | grep "intel.com/intel_sriov_700" | tail -n1 |awk '{print $(NF)}')
81 echo "The allocated resource of the node is: " $allocated_node_resource
83 kubectl create -f $HOME/$pod_name-$podType.yaml --validate=false
85 for pod in $pod_name; do
87 while [[ $status_phase != "Running" ]]; do
88 new_phase=$(kubectl get pods $pod | awk 'NR==2{print $3}')
89 if [[ $new_phase != $status_phase ]]; then
90 echo "$(date +%H:%M:%S) - $pod-$podType : $new_phase"
91 status_phase=$new_phase
93 if [[ $new_phase == "Running" ]]; then
94 echo "Pod is up and running.."
96 if [[ $new_phase == "Err"* ]]; then
101 allocated_node_resource=$(kubectl describe node | grep "intel.com/intel_sriov_700" | tail -n1 |awk '{print $(NF)}')
103 echo " The current resource allocation after the pod creation is: " $allocated_node_resource
104 kubectl delete pod $pod_name --now
105 echo "Test complete."