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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. # create readiness notification socket
  25. notify_sock=$(readlink -f "$thisFolder"/dockerContainerCeph.$EXECUTOR_NUMBER.swift.sock)
  26. mkfifo "$notify_sock"
  27. port=5034
  28. user=test
  29. pass=testing
  30. tenant=testenant
  31. region=testregion
  32. service=testceph
  33. container=`docker run -d \
  34. -e KEYSTONE_PUBLIC_PORT=${port} \
  35. -e KEYSTONE_ADMIN_USER=${user} \
  36. -e KEYSTONE_ADMIN_PASS=${pass} \
  37. -e KEYSTONE_ADMIN_TENANT=${tenant} \
  38. -e KEYSTONE_ENDPOINT_REGION=${region} \
  39. -e KEYSTONE_SERVICE=${service} \
  40. -e OSD_SIZE=300 \
  41. -v "$notify_sock":/run/notifyme.sock \
  42. --privileged \
  43. ${docker_image}`
  44. host=$(docker inspect --format="{{.NetworkSettings.IPAddress}}" "$container")
  45. echo "${docker_image} container: $container"
  46. # 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)
  47. echo $container >> $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift
  48. echo -n "Waiting for ceph initialization"
  49. ready=$(timeout 600 cat "$notify_sock")
  50. if [[ $ready != 'READY=1' ]]; then
  51. echo "[ERROR] Waited 600 seconds, no response" >&2
  52. docker logs $container
  53. exit 1
  54. fi
  55. sleep 1
  56. cat > $thisFolder/swift.config.php <<DELIM
  57. <?php
  58. \$CONFIG = array (
  59. 'objectstore' => array(
  60. 'class' => 'OC\\Files\\ObjectStore\\Swift',
  61. 'arguments' => array(
  62. 'username' => '$user',
  63. 'password' => '$pass',
  64. 'container' => 'owncloud-autotest$EXECUTOR_NUMBER',
  65. 'autocreate' => true,
  66. 'region' => '$region',
  67. 'url' => 'http://$host:$port/v2.0',
  68. 'tenantName' => '$tenant',
  69. 'serviceName' => '$service',
  70. ),
  71. ),
  72. );
  73. DELIM
  74. if [ -n "$DEBUG" ]; then
  75. echo "############## DEBUG info ###############"
  76. echo "### Docker info"
  77. docker info
  78. echo "### Docker images"
  79. docker images
  80. echo "### current mountpoints"
  81. mount
  82. echo "### contents of $thisFolder/swift.config.php"
  83. cat $thisFolder/swift.config.php
  84. echo "### contents of $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift"
  85. cat $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift
  86. echo "############## DEBUG info end ###########"
  87. fi