Skip to content

Commit

Permalink
add a way to run multiple test suites
Browse files Browse the repository at this point in the history
also in multiple environments

Required-by: s2i-ruby-container#167

Signed-off-by: Tomas Tomecek <[email protected]>
  • Loading branch information
TomasTomecek committed Apr 16, 2018
1 parent 62b4498 commit 29e2c27
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
6 changes: 4 additions & 2 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ endif

SKIP_SQUASH ?= 1
DOCKER_BUILD_CONTEXT ?= .
TEST_SUITES ?= test/run

script_env = \
SKIP_SQUASH=$(SKIP_SQUASH) \
Expand All @@ -42,7 +43,8 @@ script_env = \
CLEAN_AFTER=$(CLEAN_AFTER) \
DOCKER_BUILD_CONTEXT=$(DOCKER_BUILD_CONTEXT) \
OPENSHIFT_NAMESPACES="$(OPENSHIFT_NAMESPACES)" \
CUSTOM_REPO="$(CUSTOM_REPO)"
CUSTOM_REPO="$(CUSTOM_REPO)" \
TEST_SUITES="$(TEST_SUITES)"

# TODO: switch to 'build: build-all' once parallel builds are relatively safe
.PHONY: build build-serial build-all
Expand All @@ -64,7 +66,7 @@ $(VERSIONS): % : %/root/help.1
.PHONY: test check
check: test

test: script_env += TEST_MODE=true
test: script_env += TEST_MODE=local

# The tests should ideally depend on $IMAGE_ID only, but see PR#19 for more info
# while we need to depend on 'tag' instead of 'build'.
Expand Down
24 changes: 21 additions & 3 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,28 @@ for dir in ${VERSIONS}; do
# Kept also IMAGE_NAME as some tests might still use that.
export IMAGE_NAME=$(docker inspect -f "{{.Config.Labels.name}}" $IMAGE_ID)

if [ -n "${TEST_MODE}" ]; then
VERSION=$dir test/run
fi
for test_script in ${TEST_SUITES}; do
if [ "${TEST_MODE}" == "container" ]; then
docker run \
--net=host \
-e VERSION=$dir \
-e IMAGE_NAME \
--rm -v /dev:/dev:ro \
-v /var/lib/docker:/var/lib/docker:ro \
--security-opt label=disable \
--cap-add SYS_ADMIN \
-ti \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${PWD}:/src \
-w /src \
docker.io/modularitycontainers/conu \
$test_script
elif [ "${TEST_MODE}" == "local" ]; then
VERSION=$dir $test_script
fi
done

# FIXME: deprecate TEST_OPENSHIFT_MODE and use TEST_SUITES instead?
if [ -n "${TEST_OPENSHIFT_MODE}" ]; then
if [[ -x test/run-openshift ]]; then
VERSION=$dir test/run-openshift
Expand Down

0 comments on commit 29e2c27

Please sign in to comment.