1
0

start-swift-ceph.sh 3.2 KB

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