summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRobin McCorkell <rmccorkell@owncloud.com>2015-09-23 22:33:39 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-10-20 14:45:16 +0200
commit8467dbfa91921ccb0262161360edbf339f6b7daa (patch)
tree120855ef6ef2419794e35b7063eded324c99ec43 /apps
parent70f4e9413fc4b7f676ecdb6b437751182a07dc56 (diff)
downloadnextcloud-server-8467dbfa91921ccb0262161360edbf339f6b7daa.tar.gz
nextcloud-server-8467dbfa91921ccb0262161360edbf339f6b7daa.zip
Detect Docker initialization properly
Use netcat to check when the port opens, rather than an arbitrary timeout. Hard limit of 60 seconds in case something breaks
Diffstat (limited to 'apps')
-rwxr-xr-xapps/files_external/tests/env/start-amazons3-ceph.sh18
-rwxr-xr-xapps/files_external/tests/env/start-ftp-morrisjobke.sh19
-rwxr-xr-xapps/files_external/tests/env/start-sftp-atmoz.sh20
-rwxr-xr-xapps/files_external/tests/env/start-smb-silvershell.sh19
-rwxr-xr-xapps/files_external/tests/env/start-swift-ceph.sh18
-rwxr-xr-xapps/files_external/tests/env/start-webdav-ownCloud.sh26
6 files changed, 96 insertions, 24 deletions
diff --git a/apps/files_external/tests/env/start-amazons3-ceph.sh b/apps/files_external/tests/env/start-amazons3-ceph.sh
index ad0fedba989..f2beb0bd714 100755
--- a/apps/files_external/tests/env/start-amazons3-ceph.sh
+++ b/apps/files_external/tests/env/start-amazons3-ceph.sh
@@ -49,9 +49,21 @@ echo "${docker_image} container: $container"
# put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host)
echo $container >> $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.amazons3
-# TODO find a way to determine the successful initialization inside the docker container
-echo "Waiting 20 seconds for ceph initialization ... "
-sleep 20
+echo -n "Waiting for ceph initialization"
+starttime=$(date +%s)
+# support for GNU netcat and BSD netcat
+while ! (nc -c -w 1 ${host} ${port} </dev/null >&/dev/null \
+ || nc -w 1 ${host} ${port} </dev/null >&/dev/null); do
+ sleep 1
+ echo -n '.'
+ if (( $(date +%s) > starttime + 60 )); then
+ echo
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+ fi
+done
+echo
+sleep 1
echo "Create ceph user"
docker exec $container radosgw-admin user create \
diff --git a/apps/files_external/tests/env/start-ftp-morrisjobke.sh b/apps/files_external/tests/env/start-ftp-morrisjobke.sh
index 14112d7f803..35e3eafb839 100755
--- a/apps/files_external/tests/env/start-ftp-morrisjobke.sh
+++ b/apps/files_external/tests/env/start-ftp-morrisjobke.sh
@@ -54,12 +54,25 @@ echo "ftp container: $container"
# put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host)
echo $container >> $thisFolder/dockerContainerMorrisJobke.$EXECUTOR_NUMBER.ftp
+echo -n "Waiting for ftp initialization"
+starttime=$(date +%s)
+# support for GNU netcat and BSD netcat
+while ! (nc -c -w 1 ${host} 21 </dev/null >&/dev/null \
+ || nc -w 1 ${host} 21 </dev/null >&/dev/null); do
+ sleep 1
+ echo -n '.'
+ if (( $(date +%s) > starttime + 60 )); then
+ echo
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+ fi
+done
+echo
+sleep 1
+
if [ -n "$DEBUG" ]; then
cat $thisFolder/config.ftp.php
cat $thisFolder/dockerContainerMorrisJobke.$EXECUTOR_NUMBER.ftp
fi
-# TODO find a way to determine the successful initialization inside the docker container
-echo "Waiting 5 seconds for ftp initialization ... "
-sleep 5
diff --git a/apps/files_external/tests/env/start-sftp-atmoz.sh b/apps/files_external/tests/env/start-sftp-atmoz.sh
index 91eb5747c54..c4ef81b8357 100755
--- a/apps/files_external/tests/env/start-sftp-atmoz.sh
+++ b/apps/files_external/tests/env/start-sftp-atmoz.sh
@@ -54,15 +54,27 @@ echo "sftp container: $container"
# put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host)
echo $container >> $thisFolder/dockerContainerAtmoz.$EXECUTOR_NUMBER.sftp
+echo -n "Waiting for sftp initialization"
+starttime=$(date +%s)
+# support for GNU netcat and BSD netcat
+while ! (nc -c -w 1 ${host} 22 </dev/null >&/dev/null \
+ || nc -w 1 ${host} 22 </dev/null >&/dev/null); do
+ sleep 1
+ echo -n '.'
+ if (( $(date +%s) > starttime + 60 )); then
+ echo
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+ fi
+done
+echo
+sleep 1
+
if [ -n "$DEBUG" ]; then
cat $thisFolder/config.sftp.php
cat $thisFolder/dockerContainerAtmoz.$EXECUTOR_NUMBER.sftp
fi
-# TODO find a way to determine the successful initialization inside the docker container
-echo "Waiting 5 seconds for sftp initialization ... "
-sleep 5
-
# create folder "upload" with correct permissions
docker exec $container bash -c "mkdir /home/$user/upload && chown $user:users /home/$user/upload"
diff --git a/apps/files_external/tests/env/start-smb-silvershell.sh b/apps/files_external/tests/env/start-smb-silvershell.sh
index c45807cc4c8..e2aa025c711 100755
--- a/apps/files_external/tests/env/start-smb-silvershell.sh
+++ b/apps/files_external/tests/env/start-smb-silvershell.sh
@@ -52,12 +52,25 @@ echo "samba container: $container"
# put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host)
echo $container >> $thisFolder/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb
+echo -n "Waiting for samba initialization"
+starttime=$(date +%s)
+# support for GNU netcat and BSD netcat
+while ! (nc -c -w 1 ${host} 445 </dev/null >&/dev/null \
+ || nc -w 1 ${host} 445 </dev/null >&/dev/null); do
+ sleep 1
+ echo -n '.'
+ if (( $(date +%s) > starttime + 60 )); then
+ echo
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+ fi
+done
+echo
+sleep 1
+
if [ -n "$DEBUG" ]; then
cat $thisFolder/config.smb.php
cat $thisFolder/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb
fi
-# TODO find a way to determine the successful initialization inside the docker container
-echo "Waiting 5 seconds for smbd initialization ... "
-sleep 5
diff --git a/apps/files_external/tests/env/start-swift-ceph.sh b/apps/files_external/tests/env/start-swift-ceph.sh
index c2e7d4c1ae1..a8305eee5a2 100755
--- a/apps/files_external/tests/env/start-swift-ceph.sh
+++ b/apps/files_external/tests/env/start-swift-ceph.sh
@@ -56,9 +56,21 @@ echo "${docker_image} container: $container"
# put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host)
echo $container >> $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift
-# TODO find a way to determine the successful initialization inside the docker container
-echo "Waiting 20 seconds for ceph initialization ... "
-sleep 20
+echo -n "Waiting for ceph initialization"
+starttime=$(date +%s)
+# support for GNU netcat and BSD netcat
+while ! (nc -c -w 1 ${host} 80 </dev/null >&/dev/null \
+ || nc -w 1 ${host} 80 </dev/null >&/dev/null); do
+ sleep 1
+ echo -n '.'
+ if (( $(date +%s) > starttime + 60 )); then
+ echo
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+ fi
+done
+echo
+sleep 1
cat > $thisFolder/config.swift.php <<DELIM
<?php
diff --git a/apps/files_external/tests/env/start-webdav-ownCloud.sh b/apps/files_external/tests/env/start-webdav-ownCloud.sh
index 6bf9142ee53..6e3904f2bad 100755
--- a/apps/files_external/tests/env/start-webdav-ownCloud.sh
+++ b/apps/files_external/tests/env/start-webdav-ownCloud.sh
@@ -46,20 +46,30 @@ fi
container=`docker run -P $parameter -d -e ADMINLOGIN=test -e ADMINPWD=test morrisjobke/owncloud`
-# TODO find a way to determine the successful initialization inside the docker container
-echo "Waiting 30 seconds for ownCloud initialization ... "
-sleep 30
-
-# get mapped port on host for internal port 80 - output is IP:PORT - we need to extract the port with 'cut'
-port=`docker port $container 80 | cut -f 2 -d :`
-
+host=`docker inspect $container | grep IPAddress | cut -d '"' -f 4`
+
+echo -n "Waiting for ownCloud initialization"
+starttime=$(date +%s)
+# support for GNU netcat and BSD netcat
+while ! (nc -c -w 1 ${host} 80 </dev/null >&/dev/null \
+ || nc -w 1 ${host} 80 </dev/null >&/dev/null); do
+ sleep 1
+ echo -n '.'
+ if (( $(date +%s) > starttime + 60 )); then
+ echo
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+ fi
+done
+echo
+sleep 1
cat > $thisFolder/config.webdav.php <<DELIM
<?php
return array(
'run'=>true,
- 'host'=>'localhost:$port/owncloud/remote.php/webdav/',
+ 'host'=>'${host}:80/owncloud/remote.php/webdav/',
'user'=>'test',
'password'=>'test',
'root'=>'',