Skip to content

Commit

Permalink
CI: Added s390x support for CI scripts
Browse files Browse the repository at this point in the history
Adds support for s390x to the CI scripts.
Build Qemu is not yet supported but will be added later.
Hot Plug CPUs is currently not working on s390x and was disabled in the Test-Configuration

Fixes: kata-containers#1129

Signed-off-by: Jan Schintag <jan.schintag@de.ibm.com>
  • Loading branch information
jschintag committed Feb 6, 2019
1 parent fbdfd00 commit d6bd6d2
Show file tree
Hide file tree
Showing 14 changed files with 260 additions and 28 deletions.
5 changes: 4 additions & 1 deletion .ci/install_go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ case "$(arch)" in
"ppc64le")
goarch=ppc64le
;;


"s390x")
goarch=s390x
;;
"*")
die "Arch $(arch) not supported"
;;
Expand Down
47 changes: 28 additions & 19 deletions .ci/install_qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,34 @@ if [ -f "${cidir}/${QEMU_ARCH}/lib_install_qemu_${QEMU_ARCH}.sh" ]; then
fi

main() {
if [ "$QEMU_ARCH" == "x86_64" ]; then
packaged_qemu_commit=$(get_packaged_qemu_commit)
short_current_qemu_commit=${CURRENT_QEMU_COMMIT:0:10}
if [ "$packaged_qemu_commit" == "$short_current_qemu_commit" ]; then
# If installing packaged qemu from OBS fails,
# then build and install it from sources.
install_packaged_qemu || build_and_install_qemu
else
build_and_install_qemu
fi
elif [ "$QEMU_ARCH" == "aarch64" ] || [ "$QEMU_ARCH" == "ppc64le" ]; then
packaged_qemu_version=$(get_packaged_qemu_version)
short_current_qemu_version=${CURRENT_QEMU_VERSION#*-}
if [ "$packaged_qemu_version" == "$short_current_qemu_version" ] && [ -z "${CURRENT_QEMU_COMMIT}" ]; then
install_packaged_qemu || build_and_install_qemu
else
build_and_install_qemu
fi
fi
case "$QEMU_ARCH" in
"x86_64")
packaged_qemu_commit=$(get_packaged_qemu_commit)
short_current_qemu_commit=${CURRENT_QEMU_COMMIT:0:10}
if [ "$packaged_qemu_commit" == "$short_current_qemu_commit" ]; then
# If installing packaged qemu from OBS fails,
# then build and install it from sources.
install_packaged_qemu || build_and_install_qemu
else
build_and_install_qemu
fi
;;
"aarch64"|"ppc64le")
packaged_qemu_version=$(get_packaged_qemu_version)
short_current_qemu_version=${CURRENT_QEMU_VERSION#*-}
if [ "$packaged_qemu_version" == "$short_current_qemu_version" ] && [ -z "${CURRENT_QEMU_COMMIT}" ]; then
install_packaged_qemu || build_and_install_qemu
else
build_and_install_qemu
fi
;;
"s390x")
install_packaged_qemu
;;
*)
die "Architecture $QEMU_ARCH not supported"
;;
esac
}

main
11 changes: 11 additions & 0 deletions .ci/s390x/clean_up_s390x.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
#
# Copyright (c) 2019 IBM
#
# SPDX-License-Identifier: Apache-2.0
#

lib_script="${GOPATH}/src/${tests_repo}/.ci/lib.sh"
source "${lib_script}"

gen_clean_arch || info "Arch cleanup scripts failed"
22 changes: 22 additions & 0 deletions .ci/s390x/configuration_s390x.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Copyright (c) 2019 IBM
#
# SPDX-License-Identifier: Apache-2.0
#
test:
- functional
- docker

# Same model as is for aarch64
docker:
Describe:
- CPUs and CPU set
- Update number of CPUs
- Hot plug CPUs
- Update CPU constraints
- Hotplug memory
- update memory constraints
Context:
- remove bind-mount source before container exits
- run container exceeding memory constraints
It:
51 changes: 51 additions & 0 deletions .ci/s390x/filter_docker_s390x.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
#
# Copyright (c) 2019 IBM
#
# SPDX-License-Identifier: Apache-2.0
#

set -e

GOPATH_LOCAL="${GOPATH%%:*}"
kata_dir="${GOPATH_LOCAL}/src/github.com/kata-containers"
test_dir="${kata_dir}/tests"
ci_dir="${test_dir}/.ci"
test_config_file="${ci_dir}/s390x/configuration_s390x.yaml"

describe_skip_flag="docker.Describe"
context_skip_flag="docker.Context"
it_skip_flag="docker.It"

# value for '-skip' in ginkgo
_skip_options=()

filter_and_build()
{
local dependency="$1"
local array_docker=$("${GOPATH_LOCAL}/bin/yq" read "${test_config_file}" "${dependency}")
[ "${array_docker}" = "null" ] && return
mapfile -t _array_docker <<< "${array_docker}"
for entry in "${_array_docker[@]}"
do
_skip_options+=("${entry#- }|")
done
}

main()
{
# build skip option based on Describe block
filter_and_build "${describe_skip_flag}"

# build skip option based on context block
filter_and_build "${context_skip_flag}"

# build skip option based on it block
filter_and_build "${it_skip_flag}"

skip_options=$(IFS= ; echo "${_skip_options[*]}")

echo "${skip_options%|}"
}

main
33 changes: 33 additions & 0 deletions .ci/s390x/filter_test_s390x.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
#
# Copyright (c) 2019 IBM
#
# SPDX-License-Identifier: Apache-2.0
#

set -e

GOPATH_LOCAL="${GOPATH%%:*}"
kata_dir="${GOPATH_LOCAL}/src/github.com/kata-containers"
test_dir="${kata_dir}/tests"
ci_dir="${test_dir}/.ci"
test_config_file="${ci_dir}/s390x/configuration_s390x.yaml"

test_filter_flag="test"

_test_union=()

main()
{
local array_test=$("${GOPATH_LOCAL}/bin/yq" read "${test_config_file}" "${test_filter_flag}")
[ "${array_test}" = "null" ] && return
mapfile -t _array_test <<< "${array_test}"
for entry in "${_array_test[@]}"
do
_test_union+=("${entry#- }")
done
test_union=$(IFS=" "; echo "${_test_union[*]}")
echo "${test_union}"
}

main
35 changes: 35 additions & 0 deletions .ci/s390x/lib_install_qemu_s390x.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
#
# Copyright (c) 2019 IBM
#
# SPDX-License-Identifier: Apache-2.0
#

set -e

PACKAGED_QEMU="qemu"

[ "$ID" == "ubuntu" ] || die "Unsupported distro: $ID"

get_packaged_qemu_version() {
if [ "$ID" == "ubuntu" ]; then
sudo apt-get update > /dev/null
qemu_version=$(apt-cache madison $PACKAGED_QEMU \
| awk '{print $3}' | cut -d':' -f2 | cut -d'+' -f1 | head -n 1 )
fi

if [ -z "$qemu_version" ]; then
die "unknown qemu version"
else
echo "${qemu_version}"
fi
}

install_packaged_qemu() {
sudo apt install -y "$PACKAGED_QEMU"
}

build_and_install_qemu() {
die "Not implemented on s390x yet"
}

23 changes: 23 additions & 0 deletions .ci/s390x/lib_kata_image_s390x.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
#
# Copyright (c) 2019 IBM
#
# SPDX-License-Identifier: Apache-2.0
#

set -e

OSBUILDER_DISTRO="ubuntu"
AGENT_INIT="yes"

#packaged kata agent haven't been supported in any mainstream distribution
get_packaged_agent_version() {
version=""
echo "$version"
}

#packaged kata image haven't been supported in any mainstream distribution
install_packaged_image() {
info "installing packaged kata-image not supported in s390x"
return 1
}
24 changes: 24 additions & 0 deletions .ci/s390x/lib_setup_s390x.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
#
# Copyright (c) 2019 IBM
#
# SPDX-License-Identifier: Apache-2.0
#

set -e

filter_test_script="${cidir}/${arch}/filter_test_s390x.sh"

check_test_union()
{
local test_union=$(bash -f ${filter_test_script})
flag="$1"
# regex match
[[ ${test_union} =~ ${flag} ]] && echo "true"

echo "false"
}

CRIO=$(check_test_union crio)
KUBERNETES=$(check_test_union kubernetes)
OPENSHIFT=$(check_test_union openshift)
12 changes: 7 additions & 5 deletions .ci/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ install_docker() {

enable_nested_virtualization() {
case "$arch" in
x86_64)
if [ "$CI" == true ] && grep -q "N" /sys/module/kvm_intel/parameters/nested 2>/dev/null; then
x86_64 | s390x)
kvm_arch="kvm"
[ ${arch} == "x86_64" ] && kvm_arch="kvm_intel"
if [ "$CI" == true ] && grep -q "N" /sys/module/$kvm_arch/parameters/nested 2>/dev/null; then
echo "enable Nested Virtualization"
sudo modprobe -r kvm_intel
sudo modprobe kvm_intel nested=1
if grep -q "N" /sys/module/kvm_intel/parameters/nested 2>/dev/null; then
sudo modprobe -r $kvm_arch
sudo modprobe $kvm_arch nested=1
if grep -q "N" /sys/module/$kvm_arch/parameters/nested 2>/dev/null; then
die "Failed to find or enable Nested virtualization"
fi
fi
Expand Down
10 changes: 10 additions & 0 deletions arch/s390x-options.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Copyright (c) 2019 IBM
#
# SPDX-License-Identifier: Apache-2.0

# union for 'make test'
UNION := $(shell bash -f .ci/s390x/filter_test_s390x.sh)

# skiped test suites for docker integration tests
SKIP := $(shell bash -f .ci/s390x/filter_docker_s390x.sh)
3 changes: 0 additions & 3 deletions integration/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ const (
// FedoraImage is the fedora image
FedoraImage = "fedora"

// CentosImage is the centos image
CentosImage = "centos"

// StressImage is the vish/stress image
StressImage = "vish/stress"

Expand Down
6 changes: 6 additions & 0 deletions integration/docker/docker_arch_base.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//+build !s390x

const(
// CentosImage is the centos image
CentosImage = "centos"
)
6 changes: 6 additions & 0 deletions integration/docker/docker_s390x.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package docker

const (
// On s390x there is not centos image, instead the clefos image could be used
CentosImage = "clefos"
)

0 comments on commit d6bd6d2

Please sign in to comment.