tests: reduce the amount of log displayed

Reduce the amount of logs displayed when running test. This is achieved
calling commands using chronic, and printing extra information about
the Kata / Docker configuration only if a test fails to start a
container.

Fixes: #145

Signed-off-by: Marco Vedovati <mvedovati@suse.com>
This commit is contained in:
Marco Vedovati 2019-06-18 13:43:31 +02:00
parent acc9c7fe0d
commit 25d75e5b1c

View File

@ -42,6 +42,10 @@ source ${test_config}
typeset -A built_images
typeset -A built_initrds
# If set, show the reason why a container using the built images/initrds could
# not be started. Needed only after all images/initrd built successfully
typeset -A showKataRunFailure=
usage()
{
cat <<EOT
@ -148,7 +152,7 @@ exit_handler()
rm -rf "${tmp_dir}"
# Restore the default image in config file
[ -n "${TRAVIS:-}" ] || chronic $mgr configure-image
[ -n "${TRAVIS:-}" ] || silent_run $mgr configure-image
return
fi
@ -174,8 +178,7 @@ exit_handler()
return
fi
# Travis tests do not install kata
[ -n "${TRAVIS:-}" ] && return
[ -z "${showKataRunFailure}" ] && return
info "local runtime config:"
cat /etc/kata-containers/configuration.toml >&2
@ -190,7 +193,7 @@ exit_handler()
sudo -E ps -efwww | egrep "docker|kata" >&2
# Restore the default image in config file
chronic $mgr configure-image
silent_run $mgr configure-image
}
die()
@ -213,6 +216,15 @@ debug()
echo -e "DBG: $s" >&2
}
# Run a command in silent mode using chronic.
# The command output is printed only if the command fails
silent_run()
{
typeset -a commandLine=("$@")
info "running: ${commandLine[@]}"
chronic "${commandLine[@]}"
}
set_runtime()
{
@ -268,7 +280,7 @@ setup()
[ -n "$cfgRuntime" ] || die "${RUNTIME} is not a configured runtime for docker"
[ -x "$cfgRuntime" ] || die "docker ${RUNTIME} is linked to an invalid executable: $cfgRuntime"
fi
chronic $mgr enable-debug
silent_run $mgr enable-debug
# Ensure "docker build" works
set_runtime "${docker_build_runtime}"
@ -352,9 +364,11 @@ install_image_create_container()
# Travis doesn't support VT-x
[ -n "${TRAVIS:-}" ] && return
chronic $mgr reset-config
chronic $mgr configure-image "$file"
showKataRunFailure=1
silent_run $mgr reset-config
silent_run $mgr configure-image "$file"
create_container
showKataRunFailure=
}
install_initrd_create_container()
@ -367,9 +381,11 @@ install_initrd_create_container()
# Travis doesn't support VT-x
[ -n "${TRAVIS:-}" ] && return
chronic $mgr reset-config
chronic $mgr configure-initrd "$file"
showKataRunFailure=1
silent_run $mgr reset-config
silent_run $mgr configure-initrd "$file"
create_container
showKataRunFailure=
}
# Displays a list of distros which can be tested
@ -403,6 +419,12 @@ call_make() {
((makeJobs=$(nproc) / 2))
fi
# When calling make, do not use the silent_run wrapper, pass the
# OSBUILDER_USE_CHRONIC instead.
# In this way running make in parallel mode will, in case of failure, just
# show the print out of the single target failing.
makeVars+=(OSBUILDER_USE_CHRONIC=1)
info "Starting make with \n\
# of // jobs: ${makeJobs:-[unlimited]} \n\
targets: ${makeTargets[@]} \n\
@ -437,7 +459,6 @@ show_rootfs_metadata() {
[ $# -ne 1 ] && die "show_rootfs_metadata: wrong number of arguments"
local rootfs_path=$1
local osbuilder_file_fullpath="${rootfs_path}/${osbuilder_file}"
echo -e "$separator"
yamllint "${osbuilder_file_fullpath}"
info "osbuilder metadata file for $d:"
@ -458,15 +479,12 @@ test_distros()
{
local distro="$1"
get_distros_config "$distro"
local separator="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
local commonMakeVars=( \
USE_DOCKER=true \
ROOTFS_BUILD_DEST="$tmp_rootfs" \
IMAGES_BUILD_DEST="$images_dir" \
DEBUG=1 )
echo -e "$separator"
# If a distro was specified, filter out the distro list to only include that distro
if [ -n "$distro" ]; then
pattern="\<$distro\>"
@ -522,9 +540,9 @@ test_distros()
typeset -a completed=($(find ${tmp_rootfs} -name ".*${marker}" -exec basename {} \; | sed -E "s/\.(.+)${marker}/\1/"))
for d in "${distrosSystemd[@]} ${distrosAgent[@]}"; do
if [[ "${completed[@]}" =~ $d ]]; then
info "- $c : completed"
info "- $d : completed"
else
info "- $c : failed"
info "- $d : failed"
fi
done
die "rootfs build failed"
@ -547,12 +565,10 @@ test_distros()
fi
show_rootfs_metadata "$rootfs_path"
echo -e "$separator"
info "Making rootfs image for ${d}"
make_image ${commonMakeVars[@]} $d
local image_size=$(stat -c "%s" "${image_path}")
echo -e "$separator"
built_images["${d}"]="${rootfs_size}:${image_size}"
info "Creating container for ${d}"
install_image_create_container $image_path
@ -572,22 +588,17 @@ test_distros()
if [ "$KATA_HYPERVISOR" != "firecracker" ]; then
echo -e "$separator"
info "Making initrd image for ${d}"
make_initrd ${commonMakeVars[@]} AGENT_INIT=yes $d
local initrd_size=$(stat -c "%s" "${initrd_path}")
echo -e "$separator"
built_initrds["${d}"]="${rootfs_size}:${initrd_size}"
info "Creating container for ${d}"
install_initrd_create_container $initrd_path
fi
done
echo -e "$separator"
show_stats
echo -e "$separator"
}
main()