Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandGouny committed Sep 2, 2016
1 parent 5028b56 commit 56b686c
Showing 1 changed file with 4 additions and 36 deletions.
40 changes: 4 additions & 36 deletions test/test_helper.bash
Expand Up @@ -30,19 +30,10 @@ clear_container() {
remove_containers_by_cid $CONTAINER_ID
}

is_service_running() {
is_service_running_by_cid $CONTAINER_ID $1
wait_process() {
wait_process_by_cid $CONTAINER_ID $@
}

is_file_exists() {
is_file_exists_by_cid $CONTAINER_ID $1
}

wait_service() {
wait_service_by_cid $CONTAINER_ID $@
}


# generic functions
get_container_ip_by_cid() {
local IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $1)
Expand Down Expand Up @@ -78,30 +69,7 @@ clear_containers_by_cid() {
remove_containers_by_cid $@
}

is_service_running_by_cid() {
docker exec $1 ps cax | grep $2 > /dev/null
}

is_file_exists_by_cid() {
docker exec $1 cat $2 > /dev/null 2>&1
}

wait_service_by_cid() {

wait_process_by_cid() {
cid=$1

# first wait image init end
while ! is_file_exists_by_cid $cid /container/run/state/startup-done
do
sleep 0.5
done

for service in "${@:2}"
do
# wait service
while ! is_service_running_by_cid $cid $service
do
sleep 0.5
done
done
docker exec $cid /container/tool/wait-process ${@:2}
}

0 comments on commit 56b686c

Please sign in to comment.