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 sriov_capable_nodes=$(kubectl get nodes -o json | jq -r '.items[] | select((.status.capacity."intel.com/intel_sriov_700"|tonumber)>=2) | .metadata.name')
14 if [ -z "$sriov_capable_nodes" ]; then
15 echo "SRIOV test case cannot run on the cluster."
18 echo "SRIOV option avaiable in the cluster."
23 function create_pod_yaml_with_single_VF {
25 cat << POD > $HOME/$pod_name-single.yaml
31 k8s.v1.cni.cncf.io/networks: sriov-eno2
35 image: docker.io/centos/tools:latest
40 intel.com/intel_sriov_700: '1'
42 intel.com/intel_sriov_700: '1'
46 function create_pod_yaml_with_multiple_VF {
48 cat << POD > $HOME/$pod_name-multiple.yaml
54 k8s.v1.cni.cncf.io/networks: sriov-eno2, sriov-eno2
58 image: docker.io/centos/tools:latest
63 intel.com/intel_sriov_700: '2'
65 intel.com/intel_sriov_700: '2'
68 create_pod_yaml_with_single_VF
69 create_pod_yaml_with_multiple_VF
71 for podType in ${POD_TYPE:-single multiple}; do
73 kubectl delete pod $pod_name --ignore-not-found=true --now --wait
74 allocated_node_resource=$(kubectl describe node | grep "intel.com/intel_sriov_700" | tail -n1 |awk '{print $(NF)}')
76 echo "The allocated resource of the node is: " $allocated_node_resource
78 kubectl create -f $HOME/$pod_name-$podType.yaml --validate=false
80 for pod in $pod_name; do
82 while [[ $status_phase != "Running" ]]; do
83 new_phase=$(kubectl get pods $pod | awk 'NR==2{print $3}')
84 if [[ $new_phase != $status_phase ]]; then
85 echo "$(date +%H:%M:%S) - $pod-$podType : $new_phase"
86 status_phase=$new_phase
88 if [[ $new_phase == "Running" ]]; then
89 echo "Pod is up and running.."
91 if [[ $new_phase == "Err"* ]]; then
96 allocated_node_resource=$(kubectl describe node | grep "intel.com/intel_sriov_700" | tail -n1 |awk '{print $(NF)}')
98 echo " The current resource allocation after the pod creation is: " $allocated_node_resource
99 kubectl delete pod $pod_name --now
100 echo "Test complete."