github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/cri-o/cri-o.sh (about) 1 #!/bin/bash 2 # 3 # Copyright (c) 2017-2018 Intel Corporation 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 # 7 8 set -e 9 10 SCRIPT_PATH=$(dirname "$(readlink -f "$0")") 11 source "${SCRIPT_PATH}/../../.ci/lib.sh" 12 source "${SCRIPT_PATH}/crio_skip_tests.sh" 13 source "${SCRIPT_PATH}/../../metrics/lib/common.bash" 14 source /etc/os-release || source /usr/lib/os-release 15 16 export JOBS="${JOBS:-$(nproc)}" 17 export CONTAINER_RUNTIME="${CONTAINER_RUNTIME:-containerd-shim-kata-v2}" 18 export CONTAINER_DEFAULT_RUNTIME="${CONTAINER_DEFAULT_RUNTIME:-$CONTAINER_RUNTIME}" 19 export RUNTIME_ROOT="${RUNTIME_ROOT:-/run/vc}" 20 export RUNTIME_TYPE="${RUNTIME_TYPE:-vm}" 21 export STORAGE_OPTIONS="--storage-driver overlay" 22 23 # Skip the cri-o tests if TEST_CRIO is not true 24 # and we are on a CI job. 25 # For non CI execution, run the cri-o tests always. 26 if [ "$CI" = true ] && [ "$TEST_CRIO" != true ] 27 then 28 echo "Skipping cri-o tests as TEST_CRIO is not true" 29 exit 30 fi 31 32 crio_repository="github.com/cri-o/cri-o" 33 crio_repository_path="$GOPATH/src/${crio_repository}" 34 35 img_file="" 36 loop_device="" 37 cleanup() { 38 [ -n "${loop_device}" ] && sudo losetup -d "${loop_device}" 39 [ -n "${img_file}" ] && rm -f "${img_file}" 40 } 41 42 # Check no processes are left behind 43 check_processes 44 45 # Clone CRI-O repo if it is not already present. 46 if [ ! -d "${crio_repository_path}" ]; then 47 go get -d "${crio_repository}" || true 48 fi 49 50 # If the change we are testing does not come from CRI-O repository, 51 # then checkout to the version from versions.yaml in the runtime repository. 52 if [ "$ghprbGhRepository" != "${crio_repository/github.com\/}" ];then 53 pushd "${crio_repository_path}" 54 crio_version=$(get_version "externals.crio.branch") 55 git fetch 56 git checkout "${crio_version}" 57 popd 58 fi 59 60 # Ensure the correct version of the CRI-O binary is built and ready 61 pushd "${crio_repository_path}" 62 CONTAINER_DEFAULT_RUNTIME="" make 63 make test-binaries 64 popd 65 66 OLD_IFS=$IFS 67 IFS='' 68 69 # Skip CRI-O tests that currently are not working 70 pushd "${crio_repository_path}/test/" 71 cp ctr.bats ctr_kata_integration_tests.bats 72 for i in "${skipCRIOTests[@]}" 73 do 74 sed -i '/'${i}'/a skip \"This is not working\"' "ctr_kata_integration_tests.bats" 75 done 76 77 IFS=$OLD_IFS 78 79 echo "Ensure crio service is stopped before running the tests" 80 if systemctl is-active --quiet crio; then 81 sudo systemctl stop crio 82 fi 83 84 echo "Ensure docker service is stopped before running the tests" 85 if systemctl is-active --quiet docker; then 86 sudo systemctl stop docker 87 fi 88 89 echo "Running cri-o tests with runtime: $CONTAINER_RUNTIME" 90 ./test_runner.sh ctr_kata_integration_tests.bats 91 rm ctr_kata_integration_tests.bats 92 93 popd