From a5c3b2123fed32b00b32e0d389cc17308530d379 Mon Sep 17 00:00:00 2001 From: Benedikt <beneritter@gmail.com> Date: Wed, 23 Mar 2016 09:58:33 +0100 Subject: [PATCH] Pass test project to test script --- Makefile | 3 ++- test/run | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index f417b6a..4f4e73b 100644 --- a/Makefile +++ b/Makefile @@ -6,4 +6,5 @@ build: .PHONY: test test: docker build -t $(IMAGE_NAME)-candidate . - IMAGE_NAME=$(IMAGE_NAME)-candidate test/run + IMAGE_NAME=$(IMAGE_NAME)-candidate test/run test-app + IMAGE_NAME=$(IMAGE_NAME)-candidate test/run test-app-mvnw diff --git a/test/run b/test/run index 57e39bd..fa0aee6 100755 --- a/test/run +++ b/test/run @@ -8,6 +8,11 @@ # IMAGE_NAME=${IMAGE_NAME-codecentric/springboot-maven3-centos-candidate} +if [ $# -eq 0 ]; then + echo "ERROR: No test project name has been passed." + exit 1 +fi +test_project=${1} test_dir="$(readlink -zf $(dirname "${BASH_SOURCE[0]}"))" image_dir=$(readlink -zf ${test_dir}/..) scripts_url="file://${image_dir}/.sti/bin" @@ -37,7 +42,7 @@ container_ip() { } run_s2i_build() { - s2i build ${sti_args} file://${test_dir}/test-app ${IMAGE_NAME} ${IMAGE_NAME}-testapp + s2i build ${sti_args} file://${test_dir}/${test_project} ${IMAGE_NAME} ${IMAGE_NAME}-${test_project} } prepare() { @@ -48,7 +53,7 @@ prepare() { # TODO: STI build require the application is a valid 'GIT' repository, we # should remove this restriction in the future when a file:// is used. info "Build the test application image" - pushd ${test_dir}/test-app >/dev/null + pushd ${test_dir}/${test_project} >/dev/null git init git config user.email "build@localhost" && git config user.name "builder" git add -A && git commit -m "Sample commit" @@ -56,7 +61,7 @@ prepare() { } run_test_application() { - docker run --rm --cidfile=${cid_file} -p ${test_port} ${IMAGE_NAME}-testapp + docker run --rm --cidfile=${cid_file} -p ${test_port} ${IMAGE_NAME}-${test_project} } cleanup() { @@ -66,16 +71,16 @@ cleanup() { docker stop $(cat $cid_file) fi fi - if image_exists ${IMAGE_NAME}-testapp; then - docker rmi ${IMAGE_NAME}-testapp + if image_exists ${IMAGE_NAME}-${test_project}; then + docker rmi ${IMAGE_NAME}-${test_project} fi - rm -rf ${test_dir}/test-app/.git + rm -rf ${test_dir}/${test_project}/.git } check_result() { local result="$1" if [[ "$result" != "0" ]]; then - info "TEST FAILED (${result})" + info "TEST FAILED for ${test_project} (${result})" cleanup exit $result fi -- GitLab