mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-02 18:23:12 +00:00
tests: get config from distro-specific config.sh
Move the test configuration in the distro-specific config.sh file, for better control of what to include/exclude from testing based on the test environment. test_config.sh is still used to exclude specific distros from being tested, when running tests in bulk. Fixes: #182 Signed-off-by: Marco Vedovati <mvedovati@suse.com>
This commit is contained in:
parent
be3bea4325
commit
962b7ee3d2
@ -16,3 +16,9 @@ MIRROR=http://dl-5.alpinelinux.org/alpine
|
|||||||
# Mandatory Packages that must be installed
|
# Mandatory Packages that must be installed
|
||||||
# - iptables: Need by Kata agent
|
# - iptables: Need by Kata agent
|
||||||
PACKAGES="iptables"
|
PACKAGES="iptables"
|
||||||
|
|
||||||
|
# Init process must be one of {systemd,kata-agent}
|
||||||
|
INIT_PROCESS=kata-agent
|
||||||
|
# List of zero or more architectures to exclude from build,
|
||||||
|
# as reported by `uname -m`
|
||||||
|
ARCH_EXCLUDE_LIST=()
|
||||||
|
@ -28,3 +28,9 @@ PACKAGES="iptables"
|
|||||||
# systemd: An init system that will start kata-agent if kata-agent
|
# systemd: An init system that will start kata-agent if kata-agent
|
||||||
# itself is not configured as init process.
|
# itself is not configured as init process.
|
||||||
[ "$AGENT_INIT" == "no" ] && PACKAGES+=" systemd" || true
|
[ "$AGENT_INIT" == "no" ] && PACKAGES+=" systemd" || true
|
||||||
|
|
||||||
|
# Init process must be one of {systemd,kata-agent}
|
||||||
|
INIT_PROCESS=systemd
|
||||||
|
# List of zero or more architectures to exclude from build,
|
||||||
|
# as reported by `uname -m`
|
||||||
|
ARCH_EXCLUDE_LIST=()
|
||||||
|
@ -21,3 +21,9 @@ PACKAGES="iptables-bin libudev0-shim"
|
|||||||
# systemd: An init system that will start kata-agent if kata-agent
|
# systemd: An init system that will start kata-agent if kata-agent
|
||||||
# itself is not configured as init process.
|
# itself is not configured as init process.
|
||||||
[ "$AGENT_INIT" == "no" ] && PACKAGES+=" systemd" || true
|
[ "$AGENT_INIT" == "no" ] && PACKAGES+=" systemd" || true
|
||||||
|
|
||||||
|
# Init process must be one of {systemd,kata-agent}
|
||||||
|
INIT_PROCESS=systemd
|
||||||
|
# List of zero or more architectures to exclude from build,
|
||||||
|
# as reported by `uname -m`
|
||||||
|
ARCH_EXCLUDE_LIST=(ppc64le)
|
||||||
|
@ -10,3 +10,9 @@ OS_NAME=${OS_NAME:-"stretch"}
|
|||||||
|
|
||||||
# NOTE: Re-using ubuntu rootfs configuration, see 'ubuntu' folder for full content.
|
# NOTE: Re-using ubuntu rootfs configuration, see 'ubuntu' folder for full content.
|
||||||
source $script_dir/ubuntu/$CONFIG_SH
|
source $script_dir/ubuntu/$CONFIG_SH
|
||||||
|
|
||||||
|
# Init process must be one of {systemd,kata-agent}
|
||||||
|
INIT_PROCESS=systemd
|
||||||
|
# List of zero or more architectures to exclude from build,
|
||||||
|
# as reported by `uname -m`
|
||||||
|
ARCH_EXCLUDE_LIST=()
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2018 Huawei Technologies Co., Ltd
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
OS_NAME="EulerOS"
|
OS_NAME="EulerOS"
|
||||||
|
|
||||||
OS_VERSION=${OS_VERSION:-2.2}
|
OS_VERSION=${OS_VERSION:-2.2}
|
||||||
@ -12,3 +16,9 @@ PACKAGES="iptables"
|
|||||||
# systemd: An init system that will start kata-agent if kata-agent
|
# systemd: An init system that will start kata-agent if kata-agent
|
||||||
# itself is not configured as init process.
|
# itself is not configured as init process.
|
||||||
[ "$AGENT_INIT" == "no" ] && PACKAGES+=" systemd" || true
|
[ "$AGENT_INIT" == "no" ] && PACKAGES+=" systemd" || true
|
||||||
|
|
||||||
|
# Init process must be one of {systemd,kata-agent}
|
||||||
|
INIT_PROCESS=systemd
|
||||||
|
# List of zero or more architectures to exclude from build,
|
||||||
|
# as reported by `uname -m`
|
||||||
|
ARCH_EXCLUDE_LIST=()
|
||||||
|
@ -15,3 +15,7 @@ PACKAGES="iptables"
|
|||||||
# systemd: An init system that will start kata-agent if kata-agent
|
# systemd: An init system that will start kata-agent if kata-agent
|
||||||
# itself is not configured as init process.
|
# itself is not configured as init process.
|
||||||
[ "$AGENT_INIT" == "no" ] && PACKAGES+=" systemd" || true
|
[ "$AGENT_INIT" == "no" ] && PACKAGES+=" systemd" || true
|
||||||
|
|
||||||
|
# Init process must be one of {systemd,kata-agent}
|
||||||
|
INIT_PROCESS=systemd
|
||||||
|
ARCH_EXCLUDE_LIST=()
|
||||||
|
@ -20,9 +20,16 @@ REPO_TRANSPORT="https"
|
|||||||
# Can specify an alternative domain
|
# Can specify an alternative domain
|
||||||
REPO_DOMAIN="download.opensuse.org"
|
REPO_DOMAIN="download.opensuse.org"
|
||||||
|
|
||||||
|
# Init process must be one of {systemd,kata-agent}
|
||||||
|
INIT_PROCESS=systemd
|
||||||
|
# List of zero or more architectures to exclude from build,
|
||||||
|
# as reported by `uname -m`
|
||||||
|
ARCH_EXCLUDE_LIST=()
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
# NOTE: you probably dont need to edit things below this
|
# NOTE: you probably dont need to edit things below this
|
||||||
#
|
#
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
SUSE_URL_BASE="${REPO_TRANSPORT}://${REPO_DOMAIN}"
|
SUSE_URL_BASE="${REPO_TRANSPORT}://${REPO_DOMAIN}"
|
||||||
SUSE_PATH_OSS="/distribution/${OS_DISTRO,,}/$OS_VERSION/repo/oss"
|
SUSE_PATH_OSS="/distribution/${OS_DISTRO,,}/$OS_VERSION/repo/oss"
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2018 Intel Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
# This is a configuration file add extra variables to
|
# This is a configuration file add extra variables to
|
||||||
# be used by build_rootfs() from rootfs_lib.sh the variables will be
|
# be used by build_rootfs() from rootfs_lib.sh the variables will be
|
||||||
# loaded just before call the function. For more information see the
|
# loaded just before call the function. For more information see the
|
||||||
@ -6,3 +11,9 @@
|
|||||||
OS_VERSION=${OS_VERSION:-DEFAULT_VERSION}
|
OS_VERSION=${OS_VERSION:-DEFAULT_VERSION}
|
||||||
|
|
||||||
PACKAGES="systemd iptables udevlib.so"
|
PACKAGES="systemd iptables udevlib.so"
|
||||||
|
|
||||||
|
# Init process must be one of {systemd,kata-agent}
|
||||||
|
INIT_PROCESS=systemd
|
||||||
|
# List of zero or more architectures to exclude from build,
|
||||||
|
# as reported by `uname -m`
|
||||||
|
ARCH_EXCLUDE_LIST=()
|
||||||
|
@ -22,3 +22,9 @@ case $(arch) in
|
|||||||
aarch64) ARCHITECTURE="arm64";;
|
aarch64) ARCHITECTURE="arm64";;
|
||||||
(*) die "$(arch) not supported "
|
(*) die "$(arch) not supported "
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Init process must be one of {systemd,kata-agent}
|
||||||
|
INIT_PROCESS=systemd
|
||||||
|
# List of zero or more architectures to exclude from build,
|
||||||
|
# as reported by `uname -m`
|
||||||
|
ARCH_EXCLUDE_LIST=()
|
||||||
|
@ -3,15 +3,15 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
distrosSystemd=(fedora centos ubuntu debian suse)
|
|
||||||
distrosAgent=(alpine)
|
|
||||||
|
|
||||||
if [ $MACHINE_TYPE != "ppc64le" ]; then
|
if [ -n "${CI:-}" ]; then
|
||||||
distrosSystemd+=(clearlinux)
|
# "Not testing eurleros on Jenkins or Travis:
|
||||||
|
# (unreliable mirros, see: https://github.com/kata-containers/osbuilder/issues/182)
|
||||||
|
# (timeout, see: https://github.com/kata-containers/osbuilder/issues/46)"
|
||||||
|
skipWhenTestingAll=(euleros)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# "Not testing eurleros on Travis: (timeout, see: https://github.com/kata-containers/osbuilder/issues/46)"
|
if [ -n "${TRAVIS:-}" ]; then
|
||||||
if [ -z "${TRAVIS:-}" ]; then
|
skipWhenTestingAll+=()
|
||||||
distrosSystemd+=(euleros)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ readonly sysconfig_docker_config_file="/etc/sysconfig/docker"
|
|||||||
readonly tests_repo="github.com/kata-containers/tests"
|
readonly tests_repo="github.com/kata-containers/tests"
|
||||||
readonly tests_repo_dir="${script_dir}/../../tests"
|
readonly tests_repo_dir="${script_dir}/../../tests"
|
||||||
readonly mgr="${tests_repo_dir}/cmd/kata-manager/kata-manager.sh"
|
readonly mgr="${tests_repo_dir}/cmd/kata-manager/kata-manager.sh"
|
||||||
|
readonly test_config=${script_dir}/test_config.sh
|
||||||
|
readonly rootfs_builder=${script_dir}/../rootfs-builder/rootfs.sh
|
||||||
readonly RUNTIME=${RUNTIME:-kata-runtime}
|
readonly RUNTIME=${RUNTIME:-kata-runtime}
|
||||||
readonly MACHINE_TYPE=`uname -m`
|
readonly MACHINE_TYPE=`uname -m`
|
||||||
|
|
||||||
@ -29,9 +31,8 @@ readonly docker_build_runtime="runc"
|
|||||||
|
|
||||||
build_images=1
|
build_images=1
|
||||||
build_initrds=1
|
build_initrds=1
|
||||||
|
typeset -a distrosSystemd distrosAgent
|
||||||
source ${script_dir}/test_config.sh
|
source ${test_config}
|
||||||
|
|
||||||
# Hashes used to keep track of image sizes.
|
# Hashes used to keep track of image sizes.
|
||||||
# - Key: name of distro.
|
# - Key: name of distro.
|
||||||
# - Value: colon-separated roots and image sizes ("${rootfs_size}:${image_size}").
|
# - Value: colon-separated roots and image sizes ("${rootfs_size}:${image_size}").
|
||||||
@ -53,8 +54,12 @@ Commands:
|
|||||||
help : Show usage.
|
help : Show usage.
|
||||||
|
|
||||||
|
|
||||||
When <distro> is specified, tests are run only for the specified <distro> distribution.
|
When <distro> is specified, tests are run only for the specified <distro>.
|
||||||
Otherwise, tests are be run on all distros.
|
Otherwise, tests are run on all distros.
|
||||||
|
|
||||||
|
$(basename ${test_config}) includes a list of distros to exclude from testing,
|
||||||
|
depending on the detected test environment. However, when a <distro> is specified,
|
||||||
|
distro exclusion based on $(basename ${test_config}) is not enforced.
|
||||||
EOT
|
EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,6 +186,14 @@ info()
|
|||||||
echo -e "INFO: $s\n" >&2
|
echo -e "INFO: $s\n" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug()
|
||||||
|
{
|
||||||
|
[ -z "${TEST_DEBUG:-}" ] && return
|
||||||
|
s="$*"
|
||||||
|
echo -e "DBG: $s" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
set_runtime()
|
set_runtime()
|
||||||
{
|
{
|
||||||
local name="$1"
|
local name="$1"
|
||||||
@ -222,6 +235,57 @@ setup()
|
|||||||
set_runtime "${docker_build_runtime}"
|
set_runtime "${docker_build_runtime}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Fetches the distros test configuration from the distro-specific config.sh file.
|
||||||
|
# $1 : only fetch configuration for the distro with name $1. When not specified,
|
||||||
|
# fetch configuration for all distros.
|
||||||
|
get_distros_config()
|
||||||
|
{
|
||||||
|
local distro="$1"
|
||||||
|
local distrosList
|
||||||
|
local -A distroCfg=(\
|
||||||
|
[INIT_PROCESS]=\
|
||||||
|
[ARCH_EXCLUDE_LIST]=\
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ -n "$distro" ]; then
|
||||||
|
distrosList=("$distro")
|
||||||
|
# When specifying a single distro name, skip does not apply
|
||||||
|
skipWhenTestingAll=()
|
||||||
|
else
|
||||||
|
distrosList=($(make list-distros))
|
||||||
|
fi
|
||||||
|
|
||||||
|
for d in ${distrosList[@]}; do
|
||||||
|
debug "Getting config for distro $d"
|
||||||
|
distroPattern="\<${d}\>"
|
||||||
|
if [[ "${skipWhenTestingAll[@]}" =~ $distroPattern ]]; then
|
||||||
|
info "Skipping distro $d as specified by $(basename ${test_config})"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
tmpfile=$(mktemp /tmp/osbuilder-$d-config.XXX)
|
||||||
|
${rootfs_builder} -t $d > $tmpfile
|
||||||
|
# Get value of all keys in distroCfg
|
||||||
|
for k in ${!distroCfg[@]}; do
|
||||||
|
distroCfg[$k]="$(awk -v cfgKey=$k 'BEGIN{FS=":\t+"}{if ($1 == cfgKey) print $2}' $tmpfile)"
|
||||||
|
debug "distroCfg[$k]=${distroCfg[$k]}"
|
||||||
|
done
|
||||||
|
rm -f $tmpfile
|
||||||
|
|
||||||
|
machinePattern="\<${MACHINE_TYPE}\>"
|
||||||
|
if [[ "${distroCfg[ARCH_EXCLUDE_LIST]}" =~ $machinePattern ]]; then
|
||||||
|
info "Skipping distro $d on architecture $MACHINE_TYPE"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "${distroCfg[INIT_PROCESS]}" in
|
||||||
|
systemd) distrosSystemd+=($d) ;;
|
||||||
|
kata-agent) distrosAgent+=($d) ;;
|
||||||
|
*) die "Invalid init process specified for distro $d: \"${distroCfg[INIT_PROCESS]}\"" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
create_container()
|
create_container()
|
||||||
{
|
{
|
||||||
out=$(mktemp)
|
out=$(mktemp)
|
||||||
@ -342,6 +406,7 @@ get_rootfs_size() {
|
|||||||
test_distros()
|
test_distros()
|
||||||
{
|
{
|
||||||
local distro="$1"
|
local distro="$1"
|
||||||
|
get_distros_config "$distro"
|
||||||
local separator="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
|
local separator="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
|
||||||
|
|
||||||
echo -e "$separator"
|
echo -e "$separator"
|
||||||
|
Loading…
Reference in New Issue
Block a user