github.com/kata-containers/tests@v0.0.0-20240307153542-772105b56064/integration/kubernetes/k8s-number-cpus.bats (about) 1 #!/usr/bin/env bats 2 # 3 # Copyright (c) 2019 Intel Corporation 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 # 7 8 load "${BATS_TEST_DIRNAME}/../../.ci/lib.sh" 9 load "${BATS_TEST_DIRNAME}/tests_common.sh" 10 11 setup() { 12 pod_name="cpu-test" 13 container_name="c1" 14 get_pod_config_dir 15 } 16 17 # Skip on aarch64 due to missing cpu hotplug related functionality. 18 @test "Check number of cpus" { 19 # Create pod 20 kubectl create -f "${pod_config_dir}/pod-number-cpu.yaml" 21 22 # Check pod creation 23 kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name" 24 25 retries="10" 26 max_number_cpus="3" 27 28 num_cpus_cmd='cat /proc/cpuinfo |grep processor|wc -l' 29 for _ in $(seq 1 "$retries"); do 30 # Get number of cpus 31 number_cpus=$(kubectl exec pod/"$pod_name" -c "$container_name" \ 32 -- sh -c "$num_cpus_cmd") 33 if [[ "$number_cpus" =~ ^[0-9]+$ ]]; then 34 # Verify number of cpus 35 [ "$number_cpus" -le "$max_number_cpus" ] 36 [ "$number_cpus" -eq "$max_number_cpus" ] && break 37 fi 38 sleep 1 39 done 40 } 41 42 teardown() { 43 # Debugging information 44 kubectl describe "pod/$pod_name" 45 46 kubectl delete pod "$pod_name" 47 }