From 58b799bf9d876b96007303bc23cfe2b6a6db140b Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Mon, 8 Apr 2019 12:05:27 -0500 Subject: [PATCH] ci: run tests using kata snap build, install and test kata containers snap package. Depends-on: github.com/kata-containers/tests#1454 fixes #428 Signed-off-by: Julio Montes --- .ci/run.sh | 5 ----- .ci/setup.sh | 48 ++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/.ci/run.sh b/.ci/run.sh index 7487229d..14860612 100755 --- a/.ci/run.sh +++ b/.ci/run.sh @@ -18,8 +18,3 @@ pushd "${tests_repo_dir}" popd # This script will execute packaging tests suite - -if [ "$ID" == ubuntu ]; then - echo "Building snap image" - make snap -fi diff --git a/.ci/setup.sh b/.ci/setup.sh index 9420fd50..0dce500d 100755 --- a/.ci/setup.sh +++ b/.ci/setup.sh @@ -11,15 +11,9 @@ set -o pipefail source /etc/os-release -echo "Setup script for packaging" - -if [ "$ID" == ubuntu ]; then - echo "Install snap dependencies" - sudo apt-get install -y snapd snapcraft +SNAP_CI="${SNAP_CI:-false}" - echo "Install kernel dependencies" - sudo -E apt install -y libelf-dev bc gcc -fi +echo "Setup script for packaging" export tests_repo="${tests_repo:-github.com/kata-containers/tests}" export tests_repo_dir="$GOPATH/src/$tests_repo" @@ -38,6 +32,44 @@ clone_tests_repo() clone_tests_repo +if [ "$SNAP_CI" == "true" ] && [ "$ID" == "ubuntu" ]; then + # Do not install kata since we want to build, install and test the snap + export INSTALL_KATA="no" + + echo "Install snap dependencies" + sudo apt-get install -y snapd snapcraft make + + echo "Building snap image" + make snap + + echo "Install kata container snap" + sudo snap install --dangerous --classic "$(basename kata-containers_*.snap)" + + etc_confile="/etc/kata-containers/configuration.toml" + usr_confile="/usr/share/defaults/kata-containers/configuration.toml" + snap_confile="/snap/kata-containers/current/usr/share/defaults/kata-containers/configuration.toml" + snap_bin_dir="/snap/kata-containers/current/usr/bin" + + sudo rm -f /usr/local/bin/kata-runtime \ + /usr/bin/kata-runtime \ + /usr/local/bin/containerd-shim-kata-v2 \ + /usr/bin/containerd-shim-kata-v2 \ + "${etc_confile}" "${usr_confile}" + + sudo ln -sf ${snap_bin_dir}/kata-runtime /usr/bin/kata-runtime + sudo ln -sf ${snap_bin_dir}/kata-runtime /usr/local/bin/kata-runtime + + sudo ln -sf ${snap_bin_dir}/containerd-shim-kata-v2 /usr/bin/containerd-shim-kata-v2 + sudo ln -sf ${snap_bin_dir}/containerd-shim-kata-v2 /usr/local/bin/containerd-shim-kata-v2 + + # copy configuration file since some tests modify it. + sudo mkdir -p "$(dirname "${etc_confile}")" "$(dirname "${usr_confile}")" + sudo cp "${snap_confile}" "${etc_confile}" + sudo cp "${snap_confile}" "${usr_confile}" + + "${tests_repo_dir}/cmd/container-manager/manage_ctr_mgr.sh" docker configure -r kata-runtime -f +fi + pushd "${tests_repo_dir}" .ci/setup.sh popd