diff --git a/rootfs-builder/alpine/config.sh b/rootfs-builder/alpine/config.sh index bc8cf43457..117669baa1 100644 --- a/rootfs-builder/alpine/config.sh +++ b/rootfs-builder/alpine/config.sh @@ -16,3 +16,9 @@ MIRROR=http://dl-5.alpinelinux.org/alpine # Mandatory Packages that must be installed # - iptables: Need by Kata agent 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=() diff --git a/rootfs-builder/centos/config.sh b/rootfs-builder/centos/config.sh index a354ea74d5..75f6cc1bd4 100644 --- a/rootfs-builder/centos/config.sh +++ b/rootfs-builder/centos/config.sh @@ -28,3 +28,9 @@ PACKAGES="iptables" # systemd: An init system that will start kata-agent if kata-agent # itself is not configured as init process. [ "$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=() diff --git a/rootfs-builder/clearlinux/config.sh b/rootfs-builder/clearlinux/config.sh index e9c3a9fe58..5deab3783d 100644 --- a/rootfs-builder/clearlinux/config.sh +++ b/rootfs-builder/clearlinux/config.sh @@ -21,3 +21,9 @@ PACKAGES="iptables-bin libudev0-shim" # systemd: An init system that will start kata-agent if kata-agent # itself is not configured as init process. [ "$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) diff --git a/rootfs-builder/debian/config.sh b/rootfs-builder/debian/config.sh index 3fd64bbefc..698a128b2b 100644 --- a/rootfs-builder/debian/config.sh +++ b/rootfs-builder/debian/config.sh @@ -10,3 +10,9 @@ OS_NAME=${OS_NAME:-"stretch"} # NOTE: Re-using ubuntu rootfs configuration, see 'ubuntu' folder for full content. 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=() diff --git a/rootfs-builder/euleros/config.sh b/rootfs-builder/euleros/config.sh index 4b7af6acda..2fcf8a7357 100644 --- a/rootfs-builder/euleros/config.sh +++ b/rootfs-builder/euleros/config.sh @@ -1,3 +1,7 @@ +# +# Copyright (C) 2018 Huawei Technologies Co., Ltd +# +# SPDX-License-Identifier: Apache-2.0 OS_NAME="EulerOS" OS_VERSION=${OS_VERSION:-2.2} @@ -12,3 +16,9 @@ PACKAGES="iptables" # systemd: An init system that will start kata-agent if kata-agent # itself is not configured as init process. [ "$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=() diff --git a/rootfs-builder/fedora/config.sh b/rootfs-builder/fedora/config.sh index a0ca15a318..6bb6bd5614 100644 --- a/rootfs-builder/fedora/config.sh +++ b/rootfs-builder/fedora/config.sh @@ -15,3 +15,7 @@ PACKAGES="iptables" # systemd: An init system that will start kata-agent if kata-agent # itself is not configured as init process. [ "$AGENT_INIT" == "no" ] && PACKAGES+=" systemd" || true + +# Init process must be one of {systemd,kata-agent} +INIT_PROCESS=systemd +ARCH_EXCLUDE_LIST=() diff --git a/rootfs-builder/suse/config.sh b/rootfs-builder/suse/config.sh index 594fc4d4ee..8f4352560e 100644 --- a/rootfs-builder/suse/config.sh +++ b/rootfs-builder/suse/config.sh @@ -20,9 +20,16 @@ REPO_TRANSPORT="https" # Can specify an alternative domain 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 # -############################################################################### SUSE_URL_BASE="${REPO_TRANSPORT}://${REPO_DOMAIN}" SUSE_PATH_OSS="/distribution/${OS_DISTRO,,}/$OS_VERSION/repo/oss" diff --git a/rootfs-builder/template/config_template.sh b/rootfs-builder/template/config_template.sh index cf3157f4e9..b32bc7ada0 100644 --- a/rootfs-builder/template/config_template.sh +++ b/rootfs-builder/template/config_template.sh @@ -1,3 +1,8 @@ +# +# Copyright (c) 2018 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 + # This is a configuration file add extra variables to # be used by build_rootfs() from rootfs_lib.sh the variables will be # loaded just before call the function. For more information see the @@ -6,3 +11,9 @@ OS_VERSION=${OS_VERSION:-DEFAULT_VERSION} 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=() diff --git a/rootfs-builder/ubuntu/config.sh b/rootfs-builder/ubuntu/config.sh index d8bb95d1b8..ed8ef7c2b7 100644 --- a/rootfs-builder/ubuntu/config.sh +++ b/rootfs-builder/ubuntu/config.sh @@ -22,3 +22,9 @@ case $(arch) in aarch64) ARCHITECTURE="arm64";; (*) die "$(arch) not supported " 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=() diff --git a/tests/test_config.sh b/tests/test_config.sh index 1697714dac..d91cdeab85 100644 --- a/tests/test_config.sh +++ b/tests/test_config.sh @@ -3,15 +3,15 @@ # # SPDX-License-Identifier: Apache-2.0 -distrosSystemd=(fedora centos ubuntu debian suse) -distrosAgent=(alpine) -if [ $MACHINE_TYPE != "ppc64le" ]; then - distrosSystemd+=(clearlinux) +if [ -n "${CI:-}" ]; then + # "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 -# "Not testing eurleros on Travis: (timeout, see: https://github.com/kata-containers/osbuilder/issues/46)" -if [ -z "${TRAVIS:-}" ]; then - distrosSystemd+=(euleros) +if [ -n "${TRAVIS:-}" ]; then + skipWhenTestingAll+=() fi diff --git a/tests/test_images.sh b/tests/test_images.sh index 3af12b9fb8..a0a342a218 100755 --- a/tests/test_images.sh +++ b/tests/test_images.sh @@ -18,6 +18,8 @@ readonly sysconfig_docker_config_file="/etc/sysconfig/docker" readonly tests_repo="github.com/kata-containers/tests" readonly tests_repo_dir="${script_dir}/../../tests" 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 MACHINE_TYPE=`uname -m` @@ -29,9 +31,8 @@ readonly docker_build_runtime="runc" build_images=1 build_initrds=1 - -source ${script_dir}/test_config.sh - +typeset -a distrosSystemd distrosAgent +source ${test_config} # Hashes used to keep track of image sizes. # - Key: name of distro. # - Value: colon-separated roots and image sizes ("${rootfs_size}:${image_size}"). @@ -53,8 +54,12 @@ Commands: help : Show usage. -When is specified, tests are run only for the specified distribution. -Otherwise, tests are be run on all distros. +When is specified, tests are run only for the specified . +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 is specified, +distro exclusion based on $(basename ${test_config}) is not enforced. EOT } @@ -181,6 +186,14 @@ info() echo -e "INFO: $s\n" >&2 } +debug() +{ + [ -z "${TEST_DEBUG:-}" ] && return + s="$*" + echo -e "DBG: $s" >&2 +} + + set_runtime() { local name="$1" @@ -222,6 +235,57 @@ setup() 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() { out=$(mktemp) @@ -342,6 +406,7 @@ get_rootfs_size() { test_distros() { local distro="$1" + get_distros_config "$distro" local separator="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" echo -e "$separator"