github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/vcpus/default_vcpus_test.sh (about) 1 #!/bin/bash 2 # 3 # Copyright (c) 2020-2021 Intel Corporation 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 # 7 # This will test the default_vcpus 8 # feature is working properly 9 10 set -o errexit 11 set -o nounset 12 set -o pipefail 13 set -o errtrace 14 15 dir_path=$(dirname "$0") 16 source "${dir_path}/../../lib/common.bash" 17 source "${dir_path}/../../.ci/lib.sh" 18 KATA_HYPERVISOR="${KATA_HYPERVISOR:-qemu}" 19 name="${name:-default_vcpus}" 20 IMAGE="${IMAGE:-quay.io/prometheus/busybox:latest}" 21 CONTAINER_NAME="${CONTAINER_NAME:-test}" 22 PAYLOAD_ARGS="${PAYLOAD_ARGS:-nproc | grep 4}" 23 RUNTIME_CONFIG_PATH="${RUNTIME_CONFIG_PATH:-}" 24 TEST_INITRD="${TEST_INITRD:-no}" 25 issue="github.com/kata-containers/tests/issues/3303" 26 27 if [ "$TEST_INITRD" == "yes" ]; then 28 echo "Skip vcpu test is not working $issue" 29 exit 0 30 fi 31 32 function setup() { 33 sudo systemctl restart containerd 34 clean_env_ctr 35 check_processes 36 extract_kata_env 37 sudo sed -i "s/${name} = 1/${name} = 4/g" "${RUNTIME_CONFIG_PATH}" 38 } 39 40 function test_ctr_with_vcpus() { 41 CONTAINERD_RUNTIME="io.containerd.kata.v2" 42 sudo ctr image pull "${IMAGE}" 43 [ $? != 0 ] && die "Unable to get image $IMAGE" 44 sudo ctr run --runtime="${CONTAINERD_RUNTIME}" -d "${IMAGE}" \ 45 "${CONTAINER_NAME}" sh -c "${PAYLOAD_ARGS}" || die "Test failed" 46 } 47 48 function teardown() { 49 echo "Running teardown" 50 sudo sed -i "s/${name} = 4/${name} = 1/g" "${RUNTIME_CONFIG_PATH}" 51 clean_env_ctr 52 check_processes 53 } 54 55 trap teardown EXIT 56 57 echo "Running setup" 58 setup 59 60 echo "Running ctr integration tests with vcpus" 61 test_ctr_with_vcpus