You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

start-swift-ceph.sh 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/bash
  2. #
  3. # ownCloud
  4. #
  5. # This script start a docker container to test the files_external tests
  6. # against. It will also change the files_external config to use the docker
  7. # container as testing environment. This is reverted in the stop step.W
  8. #
  9. # Set environment variable DEBUG to print config file
  10. #
  11. # @author Morris Jobke
  12. # @author Robin McCorkell
  13. # @copyright 2015 ownCloud
  14. if ! command -v docker >/dev/null 2>&1; then
  15. echo "No docker executable found - skipped docker setup"
  16. exit 0;
  17. fi
  18. echo "Docker executable found - setup docker"
  19. docker_image=xenopathic/ceph-keystone
  20. echo "Fetch recent ${docker_image} docker image"
  21. docker pull ${docker_image}
  22. # retrieve current folder to place the config in the parent folder
  23. thisFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  24. port=5034
  25. user=test
  26. pass=testing
  27. tenant=testenant
  28. region=testregion
  29. service=testceph
  30. container=`docker run -d \
  31. -e KEYSTONE_PUBLIC_PORT=${port} \
  32. -e KEYSTONE_ADMIN_USER=${user} \
  33. -e KEYSTONE_ADMIN_PASS=${pass} \
  34. -e KEYSTONE_ADMIN_TENANT=${tenant} \
  35. -e KEYSTONE_ENDPOINT_REGION=${region} \
  36. -e KEYSTONE_SERVICE=${service} \
  37. -e OSD_SIZE=300 \
  38. -v ${thisFolder}/entrypoint.sh:/entrypoint.sh \
  39. --privileged \
  40. --entrypoint /entrypoint.sh ${docker_image}`
  41. host=$(docker inspect --format="{{.NetworkSettings.IPAddress}}" "$container")
  42. echo "${docker_image} container: $container"
  43. # 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)
  44. echo $container >> $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift
  45. echo -n "Waiting for ceph initialization"
  46. starttime=$(date +%s)
  47. # support for GNU netcat and BSD netcat
  48. while ! (nc -c -w 1 ${host} 80 </dev/null >&/dev/null \
  49. || nc -w 1 ${host} 80 </dev/null >&/dev/null); do
  50. sleep 1
  51. echo -n '.'
  52. if (( $(date +%s) > starttime + 160 )); then
  53. echo
  54. echo "[ERROR] Waited 120 seconds, no response" >&2
  55. exit 1
  56. fi
  57. done
  58. echo
  59. sleep 20 # the keystone server also needs some time to fully initialize
  60. cat > $thisFolder/swift.config.php <<DELIM
  61. <?php
  62. \$CONFIG = array (
  63. 'objectstore' => array(
  64. 'class' => 'OC\\Files\\ObjectStore\\Swift',
  65. 'arguments' => array(
  66. 'username' => '$user',
  67. 'password' => '$pass',
  68. 'container' => 'owncloud-autotest$EXECUTOR_NUMBER',
  69. 'autocreate' => true,
  70. 'region' => '$region',
  71. 'url' => 'http://$host:$port/v2.0',
  72. 'tenantName' => '$tenant',
  73. 'serviceName' => '$service',
  74. ),
  75. ),
  76. );
  77. DELIM
  78. if [ -n "$DEBUG" ]; then
  79. echo "############## DEBUG info ###############"
  80. echo "### Docker info"
  81. docker info
  82. echo "### Docker images"
  83. docker images
  84. echo "### current mountpoints"
  85. mount
  86. echo "### contents of $thisFolder/swift.config.php"
  87. cat $thisFolder/swift.config.php
  88. echo "### contents of $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift"
  89. cat $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift
  90. echo "############## DEBUG info end ###########"
  91. fi