tests: Skip all kata-manager usage if KATA_DEV_MODE is set

kata-manager.sh makes host config changes. KATA_DEV_MODE is meant to
avoid such changes.

Add a helper run_mgr function which stubs out kata-manager.sh usage
if KATA_DEV_MODE is set.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-03-01 17:25:16 -05:00
parent e787bb0da5
commit 17a8fb13a1

View File

@ -144,6 +144,15 @@ show_stats()
rm -f "${tmpfile}" rm -f "${tmpfile}"
} }
# Run a kata-manager.sh command
run_mgr()
{
[ -n "${KATA_DEV_MODE:-}" ] && return
silent_run $mgr $*
}
exit_handler() exit_handler()
{ {
if [ "$?" -eq 0 ] if [ "$?" -eq 0 ]
@ -157,7 +166,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:-}" ] || silent_run $mgr configure-image [ -n "${TRAVIS:-}" ] || run_mgr configure-image
return return
fi fi
@ -185,7 +194,7 @@ exit_handler()
if [ -z "${showKataRunFailure}" ]; then if [ -z "${showKataRunFailure}" ]; then
# Restore the default image in config file # Restore the default image in config file
silent_run $mgr configure-image run_mgr configure-image
return return
fi fi
@ -202,7 +211,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
silent_run $mgr configure-image run_mgr configure-image
} }
die() die()
@ -289,7 +298,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
silent_run $mgr enable-debug run_mgr enable-debug
# "docker build" does not work with a VM-based runtime, and # "docker build" does not work with a VM-based runtime, and
# also does not accept a --runtime option, so our only # also does not accept a --runtime option, so our only
@ -376,11 +385,11 @@ install_image_create_container()
[ -n "${TRAVIS:-}" ] && return [ -n "${TRAVIS:-}" ] && return
showKataRunFailure=1 showKataRunFailure=1
silent_run $mgr reset-config run_mgr reset-config
if [ "${RUST_AGENT:-}" = "yes" ]; then if [ "${RUST_AGENT:-}" = "yes" ]; then
silent_run $mgr enable-vsock run_mgr enable-vsock
fi fi
silent_run $mgr configure-image "$file" run_mgr configure-image "$file"
create_container create_container
showKataRunFailure= showKataRunFailure=
} }
@ -396,11 +405,11 @@ install_initrd_create_container()
[ -n "${TRAVIS:-}" ] && return [ -n "${TRAVIS:-}" ] && return
showKataRunFailure=1 showKataRunFailure=1
silent_run $mgr reset-config run_mgr reset-config
if [ "${RUST_AGENT:-}" = "yes" ]; then if [ "${RUST_AGENT:-}" = "yes" ]; then
silent_run $mgr enable-vsock run_mgr enable-vsock
fi fi
silent_run $mgr configure-initrd "$file" run_mgr configure-initrd "$file"
create_container create_container
showKataRunFailure= showKataRunFailure=
} }