mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-18 07:58:36 +00:00
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:
parent
acc9c7fe0d
commit
25d75e5b1c
@ -42,6 +42,10 @@ source ${test_config}
|
|||||||
typeset -A built_images
|
typeset -A built_images
|
||||||
typeset -A built_initrds
|
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()
|
usage()
|
||||||
{
|
{
|
||||||
cat <<EOT
|
cat <<EOT
|
||||||
@ -148,7 +152,7 @@ exit_handler()
|
|||||||
rm -rf "${tmp_dir}"
|
rm -rf "${tmp_dir}"
|
||||||
|
|
||||||
# Restore the default image in config file
|
# Restore the default image in config file
|
||||||
[ -n "${TRAVIS:-}" ] || chronic $mgr configure-image
|
[ -n "${TRAVIS:-}" ] || silent_run $mgr configure-image
|
||||||
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -174,8 +178,7 @@ exit_handler()
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Travis tests do not install kata
|
[ -z "${showKataRunFailure}" ] && return
|
||||||
[ -n "${TRAVIS:-}" ] && return
|
|
||||||
|
|
||||||
info "local runtime config:"
|
info "local runtime config:"
|
||||||
cat /etc/kata-containers/configuration.toml >&2
|
cat /etc/kata-containers/configuration.toml >&2
|
||||||
@ -190,7 +193,7 @@ exit_handler()
|
|||||||
sudo -E ps -efwww | egrep "docker|kata" >&2
|
sudo -E ps -efwww | egrep "docker|kata" >&2
|
||||||
|
|
||||||
# Restore the default image in config file
|
# Restore the default image in config file
|
||||||
chronic $mgr configure-image
|
silent_run $mgr configure-image
|
||||||
}
|
}
|
||||||
|
|
||||||
die()
|
die()
|
||||||
@ -213,6 +216,15 @@ debug()
|
|||||||
echo -e "DBG: $s" >&2
|
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()
|
set_runtime()
|
||||||
{
|
{
|
||||||
@ -268,7 +280,7 @@ setup()
|
|||||||
[ -n "$cfgRuntime" ] || die "${RUNTIME} is not a configured runtime for docker"
|
[ -n "$cfgRuntime" ] || die "${RUNTIME} is not a configured runtime for docker"
|
||||||
[ -x "$cfgRuntime" ] || die "docker ${RUNTIME} is linked to an invalid executable: $cfgRuntime"
|
[ -x "$cfgRuntime" ] || die "docker ${RUNTIME} is linked to an invalid executable: $cfgRuntime"
|
||||||
fi
|
fi
|
||||||
chronic $mgr enable-debug
|
silent_run $mgr enable-debug
|
||||||
|
|
||||||
# Ensure "docker build" works
|
# Ensure "docker build" works
|
||||||
set_runtime "${docker_build_runtime}"
|
set_runtime "${docker_build_runtime}"
|
||||||
@ -352,9 +364,11 @@ install_image_create_container()
|
|||||||
# Travis doesn't support VT-x
|
# Travis doesn't support VT-x
|
||||||
[ -n "${TRAVIS:-}" ] && return
|
[ -n "${TRAVIS:-}" ] && return
|
||||||
|
|
||||||
chronic $mgr reset-config
|
showKataRunFailure=1
|
||||||
chronic $mgr configure-image "$file"
|
silent_run $mgr reset-config
|
||||||
|
silent_run $mgr configure-image "$file"
|
||||||
create_container
|
create_container
|
||||||
|
showKataRunFailure=
|
||||||
}
|
}
|
||||||
|
|
||||||
install_initrd_create_container()
|
install_initrd_create_container()
|
||||||
@ -367,9 +381,11 @@ install_initrd_create_container()
|
|||||||
# Travis doesn't support VT-x
|
# Travis doesn't support VT-x
|
||||||
[ -n "${TRAVIS:-}" ] && return
|
[ -n "${TRAVIS:-}" ] && return
|
||||||
|
|
||||||
chronic $mgr reset-config
|
showKataRunFailure=1
|
||||||
chronic $mgr configure-initrd "$file"
|
silent_run $mgr reset-config
|
||||||
|
silent_run $mgr configure-initrd "$file"
|
||||||
create_container
|
create_container
|
||||||
|
showKataRunFailure=
|
||||||
}
|
}
|
||||||
|
|
||||||
# Displays a list of distros which can be tested
|
# Displays a list of distros which can be tested
|
||||||
@ -403,6 +419,12 @@ call_make() {
|
|||||||
((makeJobs=$(nproc) / 2))
|
((makeJobs=$(nproc) / 2))
|
||||||
fi
|
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\
|
info "Starting make with \n\
|
||||||
# of // jobs: ${makeJobs:-[unlimited]} \n\
|
# of // jobs: ${makeJobs:-[unlimited]} \n\
|
||||||
targets: ${makeTargets[@]} \n\
|
targets: ${makeTargets[@]} \n\
|
||||||
@ -437,7 +459,6 @@ show_rootfs_metadata() {
|
|||||||
[ $# -ne 1 ] && die "show_rootfs_metadata: wrong number of arguments"
|
[ $# -ne 1 ] && die "show_rootfs_metadata: wrong number of arguments"
|
||||||
local rootfs_path=$1
|
local rootfs_path=$1
|
||||||
local osbuilder_file_fullpath="${rootfs_path}/${osbuilder_file}"
|
local osbuilder_file_fullpath="${rootfs_path}/${osbuilder_file}"
|
||||||
echo -e "$separator"
|
|
||||||
yamllint "${osbuilder_file_fullpath}"
|
yamllint "${osbuilder_file_fullpath}"
|
||||||
|
|
||||||
info "osbuilder metadata file for $d:"
|
info "osbuilder metadata file for $d:"
|
||||||
@ -458,15 +479,12 @@ test_distros()
|
|||||||
{
|
{
|
||||||
local distro="$1"
|
local distro="$1"
|
||||||
get_distros_config "$distro"
|
get_distros_config "$distro"
|
||||||
local separator="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
|
|
||||||
local commonMakeVars=( \
|
local commonMakeVars=( \
|
||||||
USE_DOCKER=true \
|
USE_DOCKER=true \
|
||||||
ROOTFS_BUILD_DEST="$tmp_rootfs" \
|
ROOTFS_BUILD_DEST="$tmp_rootfs" \
|
||||||
IMAGES_BUILD_DEST="$images_dir" \
|
IMAGES_BUILD_DEST="$images_dir" \
|
||||||
DEBUG=1 )
|
DEBUG=1 )
|
||||||
|
|
||||||
echo -e "$separator"
|
|
||||||
|
|
||||||
# If a distro was specified, filter out the distro list to only include that distro
|
# If a distro was specified, filter out the distro list to only include that distro
|
||||||
if [ -n "$distro" ]; then
|
if [ -n "$distro" ]; then
|
||||||
pattern="\<$distro\>"
|
pattern="\<$distro\>"
|
||||||
@ -522,9 +540,9 @@ test_distros()
|
|||||||
typeset -a completed=($(find ${tmp_rootfs} -name ".*${marker}" -exec basename {} \; | sed -E "s/\.(.+)${marker}/\1/"))
|
typeset -a completed=($(find ${tmp_rootfs} -name ".*${marker}" -exec basename {} \; | sed -E "s/\.(.+)${marker}/\1/"))
|
||||||
for d in "${distrosSystemd[@]} ${distrosAgent[@]}"; do
|
for d in "${distrosSystemd[@]} ${distrosAgent[@]}"; do
|
||||||
if [[ "${completed[@]}" =~ $d ]]; then
|
if [[ "${completed[@]}" =~ $d ]]; then
|
||||||
info "- $c : completed"
|
info "- $d : completed"
|
||||||
else
|
else
|
||||||
info "- $c : failed"
|
info "- $d : failed"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
die "rootfs build failed"
|
die "rootfs build failed"
|
||||||
@ -547,12 +565,10 @@ test_distros()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
show_rootfs_metadata "$rootfs_path"
|
show_rootfs_metadata "$rootfs_path"
|
||||||
echo -e "$separator"
|
|
||||||
info "Making rootfs image for ${d}"
|
info "Making rootfs image for ${d}"
|
||||||
make_image ${commonMakeVars[@]} $d
|
make_image ${commonMakeVars[@]} $d
|
||||||
local image_size=$(stat -c "%s" "${image_path}")
|
local image_size=$(stat -c "%s" "${image_path}")
|
||||||
|
|
||||||
echo -e "$separator"
|
|
||||||
built_images["${d}"]="${rootfs_size}:${image_size}"
|
built_images["${d}"]="${rootfs_size}:${image_size}"
|
||||||
info "Creating container for ${d}"
|
info "Creating container for ${d}"
|
||||||
install_image_create_container $image_path
|
install_image_create_container $image_path
|
||||||
@ -572,22 +588,17 @@ test_distros()
|
|||||||
|
|
||||||
|
|
||||||
if [ "$KATA_HYPERVISOR" != "firecracker" ]; then
|
if [ "$KATA_HYPERVISOR" != "firecracker" ]; then
|
||||||
echo -e "$separator"
|
|
||||||
info "Making initrd image for ${d}"
|
info "Making initrd image for ${d}"
|
||||||
make_initrd ${commonMakeVars[@]} AGENT_INIT=yes $d
|
make_initrd ${commonMakeVars[@]} AGENT_INIT=yes $d
|
||||||
local initrd_size=$(stat -c "%s" "${initrd_path}")
|
local initrd_size=$(stat -c "%s" "${initrd_path}")
|
||||||
|
|
||||||
echo -e "$separator"
|
|
||||||
built_initrds["${d}"]="${rootfs_size}:${initrd_size}"
|
built_initrds["${d}"]="${rootfs_size}:${initrd_size}"
|
||||||
info "Creating container for ${d}"
|
info "Creating container for ${d}"
|
||||||
install_initrd_create_container $initrd_path
|
install_initrd_create_container $initrd_path
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo -e "$separator"
|
|
||||||
show_stats
|
show_stats
|
||||||
|
|
||||||
echo -e "$separator"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user