start-amazons3-ceph.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/usr/bin/env bash
  2. #
  3. # SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
  4. # SPDX-License-Identifier: AGPL-3.0-only
  5. #
  6. # This script start a docker container to test the files_external tests
  7. # against. It will also change the files_external config to use the docker
  8. # container as testing environment. This is reverted in the stop step.W
  9. #
  10. # Set environment variable DEBUG to print config file
  11. #
  12. if ! command -v docker >/dev/null 2>&1; then
  13. echo "No docker executable found - skipped docker setup"
  14. exit 0;
  15. fi
  16. echo "Docker executable found - setup docker"
  17. docker_image=xenopathic/ceph-keystone
  18. echo "Fetch recent ${docker_image} docker image"
  19. docker pull ${docker_image}
  20. # retrieve current folder to place the config in the parent folder
  21. thisFolder=`echo $0 | replace "env/start-amazons3-ceph.sh" ""`
  22. if [ -z "$thisFolder" ]; then
  23. thisFolder="."
  24. fi;
  25. # create readiness notification socket
  26. notify_sock=$(readlink -f "$thisFolder"/dockerContainerCeph.$EXECUTOR_NUMBER.amazons3.sock)
  27. rm -f "$notify_sock" # in case an unfinished test left one behind
  28. mkfifo "$notify_sock"
  29. user=test
  30. accesskey=aaabbbccc
  31. secretkey=cccbbbaaa
  32. bucket=testbucket
  33. port=80
  34. container=`docker run -d \
  35. -e RGW_CIVETWEB_PORT=$port \
  36. -v "$notify_sock":/run/notifyme.sock \
  37. ${docker_image}`
  38. host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container`
  39. echo "${docker_image} container: $container"
  40. # 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)
  41. echo $container >> $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.amazons3
  42. echo -n "Waiting for ceph initialization"
  43. ready=$(timeout 60 cat "$notify_sock")
  44. if [[ $ready != 'READY=1' ]]; then
  45. echo "[ERROR] Waited 60 seconds, no response" >&2
  46. exit 1
  47. fi
  48. sleep 1
  49. echo "Create ceph user"
  50. docker exec $container radosgw-admin user create \
  51. --uid="$user" --display-name="$user" \
  52. --access-key="$accesskey" --secret="$secretkey" \
  53. >/dev/null
  54. cat > $thisFolder/config.amazons3.php <<DELIM
  55. <?php
  56. return array(
  57. 'run'=>true,
  58. 'bucket'=>'$bucket',
  59. 'hostname'=>'$host',
  60. 'port'=>'$port',
  61. 'key'=>'$accesskey',
  62. 'secret'=>'$secretkey',
  63. 'use_ssl'=>false,
  64. 'use_path_style'=>true,
  65. );
  66. DELIM
  67. if [ -n "$DEBUG" ]; then
  68. cat $thisFolder/config.amazons3.php
  69. cat $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.amazons3
  70. fi