diff --git a/Makefile b/Makefile index f417b6a443ca325a46580645212eaccca5c1c95a..4f4e73baa2d7e41afd592f137a62562bb92c2515 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 57e39bdcec6cb591a8c960e0c1a23c53c627c4bb..fa0aee6d940be0232ef91df1778e4c73ac1ffba6 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