Include image test as part of kokoro tests

PiperOrigin-RevId: 201427731
Change-Id: I5cbee383ec51c02b7892ec7812cbbdc426be8991
This commit is contained in:
Fabricio Voznika
2018-06-20 15:28:12 -07:00
committed by Shentubot
parent 2b5bdb525e
commit 2f59ba0e2d
3 changed files with 101 additions and 1 deletions
+13
View File
@@ -31,6 +31,10 @@ cd git/repo
# Build everything.
bazel build //...
# Test use this variable to determine what runtime to use.
runtime=runsc_test_$((RANDOM))
sudo -n ./runsc/test/image/install.sh --runtime ${runtime}
# Run the tests and upload results.
#
# We turn off "-e" flag because we must move the log files even if the test
@@ -38,6 +42,15 @@ bazel build //...
set +e
bazel test --test_output=errors //...
exit_code=${?}
if [[ ${exit_code} -eq 0 ]]; then
# image_test is tagged manual
bazel test --test_output=errors --test_env=RUNSC_RUNTIME=${runtime} //runsc/test/image:image_test
exit_code=${?}
fi
# Best effort to uninstall
sudo -n ./runsc/test/image/install.sh -u --runtime ${runtime}
set -e
# Find and rename all test xml and log files so that Sponge can pick them up.
+3 -1
View File
@@ -13,7 +13,9 @@
// limitations under the License.
// Package image provides end-to-end image tests for runsc. These tests require
// docker and runsc to be installed on the machine.
// docker and runsc to be installed on the machine. To set it up, run:
//
// ./runsc/test/image/install.sh [--runtime <name>]
//
// The tests expect the runtime name to be provided in the RUNSC_RUNTIME
// environment variable (default: runsc-test).
+85
View File
@@ -0,0 +1,85 @@
#!/bin/bash
# Copyright 2018 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Fail on any error
set -e
# Defaults
declare runtime=runsc-test
declare uninstall=0
function findExe() {
local exe=${1}
local path=$(find bazel-bin/runsc -type f -executable -name "${exe}" | head -n1)
if [[ "${path}" == "" ]]; then
echo "Location of ${exe} not found in bazel-bin" >&2
exit 1
fi
echo "${path}"
}
while [[ $# -gt 0 ]]; do
case "$1" in
--runtime)
shift
[ "$#" -le 0 ] && echo "No runtime provided" && exit 1
runtime=$1
;;
-u)
uninstall=1
;;
*)
echo "Unknown option: ${1}"
echo ""
echo "Usage: ${0} [--runtime <name>] [-u]"
echo " --runtime sets the runtime name, default: runsc-test"
echo " -u uninstall the runtime"
exit 1
esac
shift
done
# Find location of executables.
declare -r dockercfg=$(findExe dockercfg)
[[ "${dockercfg}" == "" ]] && exit 1
declare runsc=$(findExe runsc)
[[ "${runsc}" == "" ]] && exit 1
if [[ ${uninstall} == 0 ]]; then
rm -rf /tmp/${runtime}
mkdir -p /tmp/${runtime}
cp "${runsc}" /tmp/${runtime}/runsc
runsc=/tmp/${runtime}/runsc
# Make tmp dir and runsc binary readable and executable to all users, since it
# will run in an empty user namespace.
chmod a+rx "${runsc}" $(dirname "${runsc}")
# Make log dir executable and writable to all users for the same reason.
declare logdir=/tmp/"${runtime?}/logs"
mkdir -p "${logdir}"
sudo -n chmod a+wx "${logdir}"
sudo -n "${dockercfg}" runtime-add "${runtime}" "${runsc}" --debug-log-dir "${logdir}" --debug --strace --log-packets
else
sudo -n "${dockercfg}" runtime-rm "${runtime}"
fi
echo "Restarting docker service..."
sudo -n /etc/init.d/docker restart