new test helper

This commit is contained in:
ofreax 2015-07-17 09:23:24 +02:00
parent 345188086e
commit 5084fe2256
1 changed files with 17 additions and 7 deletions

View File

@ -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
}
}