diff options
Diffstat (limited to 'tools/run_tests.sh')
-rwxr-xr-x | tools/run_tests.sh | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/tools/run_tests.sh b/tools/run_tests.sh index dc282c142..7a1f889dd 100755 --- a/tools/run_tests.sh +++ b/tools/run_tests.sh @@ -106,18 +106,31 @@ install_runtime() { sudo -n ${WORKSPACE_DIR}/runsc/test/install.sh --runtime ${RUNTIME} } +install_helper() { + PACKAGE="${1}" + TAG="${2}" + GOPATH="${3}" + + # Clone the repository. + mkdir -p "${GOPATH}"/src/$(dirname "${PACKAGE}") && \ + git clone https://"${PACKAGE}" "${GOPATH}"/src/"${PACKAGE}" + + # Checkout and build the repository. + (cd "${GOPATH}"/src/"${PACKAGE}" && \ + git checkout "${TAG}" && \ + GOPATH="${GOPATH}" make && \ + sudo -n -E env GOPATH="${GOPATH}" make install) +} + # Install dependencies for the crictl tests. install_crictl_test_deps() { sudo -n -E apt-get update sudo -n -E apt-get install -y btrfs-tools libseccomp-dev - # Install containerd. - [[ -d containerd ]] || git clone https://github.com/containerd/containerd - (cd containerd && git checkout v1.2.2 && make && sudo -n -E make install) - - # Install crictl. - [[ -d cri-tools ]] || git clone https://github.com/kubernetes-sigs/cri-tools - (cd cri-tools && git checkout tags/v1.11.0 && make && sudo -n -E make install) + # Install containerd & cri-tools. + GOPATH=$(mktemp -d --tmpdir gopathXXXXX) + install_helper github.com/containerd/containerd v1.2.2 "${GOPATH}" + install_helper github.com/kubernetes-sigs/cri-tools v1.11.0 "${GOPATH}" # Install gvisor-containerd-shim. local latest=/tmp/gvisor-containerd-shim-latest @@ -143,7 +156,8 @@ EOF sudo mv ${shim_config_tmp_path} ${shim_config_path} # Configure CNI. - sudo -n -E env PATH=${PATH} containerd/script/setup/install-cni + (cd "${GOPATH}" && sudo -n -E env PATH="${PATH}" GOPATH="${GOPATH}" \ + src/github.com/containerd/containerd/script/setup/install-cni) } # Run the tests that require docker. @@ -161,13 +175,17 @@ run_docker_tests() { # configuration, e.g. save/restore not supported with hostnet. declare -a variations=("" "-kvm" "-hostnet" "-overlay") for v in "${variations[@]}"; do + # Change test names otherwise each run of tests will overwrite logs and + # results of the previous run. + sed -i "s/name = \"integration_test.*\"/name = \"integration_test${v}\"/" runsc/test/integration/BUILD + sed -i "s/name = \"image_test.*\"/name = \"image_test${v}\"/" runsc/test/image/BUILD # Run runsc tests with docker that are tagged manual. bazel test \ "${BAZEL_BUILD_FLAGS[@]}" \ --test_env=RUNSC_RUNTIME="${RUNTIME}${v}" \ --test_output=all \ - //runsc/test/image:image_test \ - //runsc/test/integration:integration_test + //runsc/test/image:image_test${v} \ + //runsc/test/integration:integration_test${v} done } @@ -194,8 +212,8 @@ run_runsc_do_tests() { local runsc=$(find bazel-bin/runsc -type f -executable -name "runsc" | head -n1) # run runsc do without root privileges. - unshare -Ur ${runsc} --network=none --TESTONLY-unsafe-nonroot do true - unshare -Ur ${runsc} --TESTONLY-unsafe-nonroot --network=host do --netns=false true + ${runsc} --rootless do true + ${runsc} --rootless --network=none do true # run runsc do with root privileges. sudo -n -E ${runsc} do true |