start-amazons3-ceph.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/usr/bin/env 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=`echo $0 | replace "env/start-amazons3-ceph.sh" ""`
  24. if [ -z "$thisFolder" ]; then
  25. thisFolder="."
  26. fi;
  27. # create readiness notification socket
  28. notify_sock=$(readlink -f "$thisFolder"/dockerContainerCeph.$EXECUTOR_NUMBER.amazons3.sock)
  29. rm -f "$notify_sock" # in case an unfinished test left one behind
  30. mkfifo "$notify_sock"
  31. user=test
  32. accesskey=aaabbbccc
  33. secretkey=cccbbbaaa
  34. bucket=testbucket
  35. port=80
  36. container=`docker run -d \
  37. -e RGW_CIVETWEB_PORT=$port \
  38. -v "$notify_sock":/run/notifyme.sock \
  39. ${docker_image}`
  40. host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container`
  41. echo "${docker_image} container: $container"
  42. # 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)
  43. echo $container >> $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.amazons3
  44. echo -n "Waiting for ceph initialization"
  45. ready=$(timeout 60 cat "$notify_sock")
  46. if [[ $ready != 'READY=1' ]]; then
  47. echo "[ERROR] Waited 60 seconds, no response" >&2
  48. exit 1
  49. fi
  50. sleep 1
  51. echo "Create ceph user"
  52. docker exec $container radosgw-admin user create \
  53. --uid="$user" --display-name="$user" \
  54. --access-key="$accesskey" --secret="$secretkey" \
  55. >/dev/null
  56. cat > $thisFolder/config.amazons3.php <<DELIM
  57. <?php
  58. return array(
  59. 'run'=>true,
  60. 'bucket'=>'$bucket',
  61. 'hostname'=>'$host',
  62. 'port'=>'$port',
  63. 'key'=>'$accesskey',
  64. 'secret'=>'$secretkey',
  65. 'use_ssl'=>false,
  66. 'use_path_style'=>true,
  67. );
  68. DELIM
  69. if [ -n "$DEBUG" ]; then
  70. cat $thisFolder/config.amazons3.php
  71. cat $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.amazons3
  72. fi