1
0

start-swift-ceph.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. # debian 8 default comes without loaded loop module. please run "sudo modprobe loop" if you get an error here:
  23. lsmod | grep '^loop' || { echo "Error: kernel module loop not loaded. Needed by docker image ${docker_image}"; exit 1; }
  24. # retrieve current folder to place the config in the parent folder
  25. thisFolder=`echo $0 | sed 's#env/start-swift-ceph\.sh##'`
  26. if [ -z "$thisFolder" ]; then
  27. thisFolder="."
  28. fi;
  29. # create readiness notification socket
  30. notify_sock=$(readlink -f "$thisFolder"/dockerContainerCeph.$EXECUTOR_NUMBER.swift.sock)
  31. rm -f "$notify_sock" # in case an unfinished test left one behind
  32. mkfifo "$notify_sock"
  33. port=5001
  34. user=test
  35. pass=testing
  36. tenant=testenant
  37. region=testregion
  38. service=testceph
  39. container=`docker run -d \
  40. -e KEYSTONE_PUBLIC_PORT=${port} \
  41. -e KEYSTONE_ADMIN_USER=${user} \
  42. -e KEYSTONE_ADMIN_PASS=${pass} \
  43. -e KEYSTONE_ADMIN_TENANT=${tenant} \
  44. -e KEYSTONE_ENDPOINT_REGION=${region} \
  45. -e KEYSTONE_SERVICE=${service} \
  46. -e OSD_SIZE=300 \
  47. --privileged \
  48. -v "$notify_sock":/run/notifyme.sock \
  49. ${docker_image}`
  50. host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container`
  51. echo "${docker_image} container: $container"
  52. # 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)
  53. echo $container >> $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift
  54. echo "Waiting for ceph initialization"
  55. ready=$(timeout 600 cat "$notify_sock")
  56. if [[ $ready != 'READY=1' ]]; then
  57. echo "[ERROR] Waited 600 seconds, no response" >&2
  58. docker logs $container
  59. exit 1
  60. fi
  61. if ! "$thisFolder"/env/wait-for-connection ${host} 80 600; then
  62. echo "[ERROR] Waited 600 seconds, no response" >&2
  63. docker logs $container
  64. exit 1
  65. fi
  66. echo "Waiting another 15 seconds"
  67. sleep 15
  68. cat > $thisFolder/config.swift.php <<DELIM
  69. <?php
  70. return array(
  71. 'run'=>true,
  72. 'url'=>'http://$host:$port/v2.0',
  73. 'user'=>'$user',
  74. 'tenant'=>'$tenant',
  75. 'password'=>'$pass',
  76. 'service_name'=>'$service',
  77. 'bucket'=>'swift',
  78. 'region' => '$region',
  79. );
  80. DELIM
  81. if [ -n "$DEBUG" ]; then
  82. cat $thisFolder/config.swift.php
  83. cat $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift
  84. fi