Skip to content

Commit

Permalink
ci: add filter scheme for architecture-independent
Browse files Browse the repository at this point in the history
Not all test components are supported in all archs, so addding filter
scheme to select specific ones for different archs is necessary.

Fixes: kata-containers#472

Signed-off-by: Penny Zheng <penny.zheng@arm.com>
Signed-off-by: Wei Chen <Wei.Chen@arm.com>
  • Loading branch information
Pennyzct committed Jul 19, 2018
1 parent 805092a commit f701c68
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 4 deletions.
51 changes: 51 additions & 0 deletions .ci/filter_docker_aarch64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
#
# Copyright (c) 2018 ARM Limited
#
# 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}/configuration_aarch64.yaml"

describe_filter_flag="docker.Describe"
context_filter_flag="docker.Context"
it_filter_flag="docker.It"

# value for '-focus' in ginkgo
_focus_options=()

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

main()
{
# build focus option based on Describe block
filter_and_build "${describe_filter_flag}"

# build focus option based on context block
filter_and_build "${context_filter_flag}"

# build focus option based on it block
filter_and_build "${it_filter_flag}"

focus_options=$(IFS= ; echo "${_focus_options[*]}")

echo "${focus_options%|}"

}

main
32 changes: 32 additions & 0 deletions .ci/filter_test_aarch64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
#
# Copyright (c) 2018 ARM Limited
#
# 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}/configuration_aarch64.yaml"

test_filter_flag="test"

_test_union=()

main()
{
array_test=$("${GOPATH_LOCAL}/bin/yq" read "${test_config_file}" "${test_filter_flag}")
[ "${array_test}" = "null" ] && array_test="" && 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
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
# SPDX-License-Identifier: Apache-2.0
#

# The time limit in seconds for each test
TIMEOUT ?= 60
# get arch
ARCH := $(shell bash -c arch)

ARCH_FILE_SUFFIX = -options.mk
ARCH_FILE = $(ARCH)$(ARCH_FILE_SUFFIX)

# Load architecture-dependent settings
include $(ARCH_FILE)

default: checkcommits

Expand All @@ -24,7 +30,7 @@ else
./ginkgo -v functional/ -- -runtime=${RUNTIME} -timeout=${TIMEOUT}
endif

integration: ginkgo
docker: ginkgo
ifeq ($(RUNTIME),)
$(error RUNTIME is not set)
else
Expand Down Expand Up @@ -60,7 +66,7 @@ openshift:
bash -f .ci/install_bats.sh
bash -f integration/openshift/run_openshift_tests.sh

test: functional integration crio docker-compose openshift kubernetes swarm cri-containerd
test: ${UNION}

check: checkcommits log-parser

Expand Down
13 changes: 13 additions & 0 deletions aarch64-options.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# Copyright (c) 2018 ARM Limited
#
# SPDX-License-Identifier: Apache-2.0

# The time limit in seconds for each test
TIMEOUT := 120

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

# value of '-focus' in ginkgo command for docker integration tests
FOCUS := $(shell bash -f .ci/filter_docker_aarch64.sh)
15 changes: 15 additions & 0 deletions x86_64-options.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) 2017-2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#

# The time limit in seconds for each test
TIMEOUT := 60

# union for 'make test'
UNION := 'functional docker crio docker-compose openshift kubernetes swarm cri-containerd'

# value of '-focus' in ginkgo command for docker integration tests
FOCUS :=

0 comments on commit f701c68

Please sign in to comment.