start-swift-ceph.sh 2.8 KB

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