File tree Expand file tree Collapse file tree 2 files changed +7
-39
lines changed Expand file tree Collapse file tree 2 files changed +7
-39
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ load test_helper
1313 tmp_file=" $BATS_TMPDIR /docker-test"
1414
1515 run_image
16- wait_service apache2 php5-fpm
16+ wait_process apache2 php5-fpm
1717 curl --silent --insecure https://$CONTAINER_IP >> $tmp_file
1818 run grep -c " Use the menu to the left to navigate" $tmp_file
1919 rm $tmp_file
@@ -36,10 +36,10 @@ load test_helper
3636 run_image -e PHPLDAPADMIN_LDAP_HOSTS=$LDAP_IP
3737
3838 # wait openldap
39- wait_service_by_cid $LDAP_CID slapd
39+ wait_process_by_cid $LDAP_CID slapd
4040
4141 # wait phpLDAPadmin container apache2 service
42- wait_service apache2 php5-fpm
42+ wait_process apache2 php5-fpm
4343
4444 curl -L --silent --insecure -c $BATS_TMPDIR /cookie.txt https://$CONTAINER_IP >> $tmp_file
4545
Original file line number Diff line number Diff line change @@ -30,19 +30,10 @@ clear_container() {
3030 remove_containers_by_cid $CONTAINER_ID
3131}
3232
33- is_service_running () {
34- is_service_running_by_cid $CONTAINER_ID $1
33+ wait_process () {
34+ wait_process_by_cid $CONTAINER_ID $@
3535}
3636
37- is_file_exists () {
38- is_file_exists_by_cid $CONTAINER_ID $1
39- }
40-
41- wait_service () {
42- wait_service_by_cid $CONTAINER_ID $@
43- }
44-
45-
4637# generic functions
4738get_container_ip_by_cid () {
4839 local IP=$( docker inspect -f " {{ .NetworkSettings.IPAddress }}" $1 )
@@ -78,30 +69,7 @@ clear_containers_by_cid() {
7869 remove_containers_by_cid $@
7970}
8071
81- is_service_running_by_cid () {
82- docker exec $1 ps cax | grep $2 > /dev/null
83- }
84-
85- is_file_exists_by_cid () {
86- docker exec $1 cat $2 > /dev/null 2>&1
87- }
88-
89- wait_service_by_cid () {
90-
72+ wait_process_by_cid () {
9173 cid=$1
92-
93- # first wait image init end
94- while ! is_file_exists_by_cid $cid /container/run/state/startup-done
95- do
96- sleep 0.5
97- done
98-
99- for service in " ${@: 2} "
100- do
101- # wait service
102- while ! is_service_running_by_cid $cid $service
103- do
104- sleep 0.5
105- done
106- done
74+ docker exec $cid /container/tool/wait-process ${@: 2}
10775}
You can’t perform that action at this time.
0 commit comments