From 5084fe225676a1148e7d22cc6ae8778f03cf7e10 Mon Sep 17 00:00:00 2001 From: ofreax Date: Fri, 17 Jul 2015 09:23:24 +0200 Subject: [PATCH] new test helper --- test/test_helper.bash | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/test/test_helper.bash b/test/test_helper.bash index 31bdd43..21217c5 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -2,7 +2,7 @@ setup() { IMAGE_NAME="$NAME:$VERSION" } -# function relative to the current container / image +# function relative to the current container / image build_image() { #disable outputs docker build -t $IMAGE_NAME $BATS_TEST_DIRNAME/../image &> /dev/null @@ -34,12 +34,16 @@ is_service_running() { is_service_running_by_cid $CONTAINER_ID $1 } +is_file_exists() { + is_file_exists_by_cid $CONTAINER_ID $1 +} + wait_service() { wait_service_by_cid $CONTAINER_ID $@ } -# generic functions +# generic functions get_container_ip_by_cid() { local IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $1) echo "$IP" @@ -50,7 +54,7 @@ start_containers_by_cid() { do #disable outputs docker start $cid &> /dev/null - done + done } stop_containers_by_cid() { @@ -58,7 +62,7 @@ stop_containers_by_cid() { do #disable outputs docker stop $cid &> /dev/null - done + done } remove_containers_by_cid() { @@ -66,7 +70,7 @@ remove_containers_by_cid() { do #disable outputs docker rm $cid &> /dev/null - done + done } clear_containers_by_cid() { @@ -78,12 +82,18 @@ is_service_running_by_cid() { docker exec $1 ps cax | grep $2 > /dev/null } +is_file_exists_by_cid() { + docker exec $1 cat "/etc/my_init_startup_files_completed" > /dev/null 2>&1 +} + wait_service_by_cid() { cid=$1 + sleep 1 + # first wait image init end - while ! is_service_running_by_cid $cid syslog-ng + while ! is_file_exists_by_cid $cid /etc/my_init_startup_files_completed do sleep 1 done @@ -98,4 +108,4 @@ wait_service_by_cid() { done sleep 5 -} \ No newline at end of file +}