Skip to content
Snippets Groups Projects
Commit a5c3b212 authored by Benedikt's avatar Benedikt
Browse files

Pass test project to test script

parent 1cd17456
No related branches found
No related tags found
No related merge requests found
...@@ -6,4 +6,5 @@ build: ...@@ -6,4 +6,5 @@ build:
.PHONY: test .PHONY: test
test: test:
docker build -t $(IMAGE_NAME)-candidate . 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
...@@ -8,6 +8,11 @@ ...@@ -8,6 +8,11 @@
# #
IMAGE_NAME=${IMAGE_NAME-codecentric/springboot-maven3-centos-candidate} 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]}"))" test_dir="$(readlink -zf $(dirname "${BASH_SOURCE[0]}"))"
image_dir=$(readlink -zf ${test_dir}/..) image_dir=$(readlink -zf ${test_dir}/..)
scripts_url="file://${image_dir}/.sti/bin" scripts_url="file://${image_dir}/.sti/bin"
...@@ -37,7 +42,7 @@ container_ip() { ...@@ -37,7 +42,7 @@ container_ip() {
} }
run_s2i_build() { 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() { prepare() {
...@@ -48,7 +53,7 @@ prepare() { ...@@ -48,7 +53,7 @@ prepare() {
# TODO: STI build require the application is a valid 'GIT' repository, we # TODO: STI build require the application is a valid 'GIT' repository, we
# should remove this restriction in the future when a file:// is used. # should remove this restriction in the future when a file:// is used.
info "Build the test application image" info "Build the test application image"
pushd ${test_dir}/test-app >/dev/null pushd ${test_dir}/${test_project} >/dev/null
git init git init
git config user.email "build@localhost" && git config user.name "builder" git config user.email "build@localhost" && git config user.name "builder"
git add -A && git commit -m "Sample commit" git add -A && git commit -m "Sample commit"
...@@ -56,7 +61,7 @@ prepare() { ...@@ -56,7 +61,7 @@ prepare() {
} }
run_test_application() { 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() { cleanup() {
...@@ -66,16 +71,16 @@ cleanup() { ...@@ -66,16 +71,16 @@ cleanup() {
docker stop $(cat $cid_file) docker stop $(cat $cid_file)
fi fi
fi fi
if image_exists ${IMAGE_NAME}-testapp; then if image_exists ${IMAGE_NAME}-${test_project}; then
docker rmi ${IMAGE_NAME}-testapp docker rmi ${IMAGE_NAME}-${test_project}
fi fi
rm -rf ${test_dir}/test-app/.git rm -rf ${test_dir}/${test_project}/.git
} }
check_result() { check_result() {
local result="$1" local result="$1"
if [[ "$result" != "0" ]]; then if [[ "$result" != "0" ]]; then
info "TEST FAILED (${result})" info "TEST FAILED for ${test_project} (${result})"
cleanup cleanup
exit $result exit $result
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment