run.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/usr/bin/env bash
  2. CONTAINER_NAME=${CONTAINER_NAME:-s3test-instance}
  3. CONF_FILE=${CONF_FILE:-s3tests.conf}
  4. WEED_BIN=${WEED_BIN:-../../../weed/weed}
  5. TEST_RAW_OUTPUT_FILE=${TEST_RAW_OUTPUT_FILE:-compat.raw.txt}
  6. TEST_PROCESSED_OUTPUT_FILE=${TEST_PROCESSED_OUTPUT_FILE:-compat.summary.txt}
  7. # Set up debugging for this bash script if DEBUG is set
  8. if [ -n "${DEBUG}" ]; then
  9. echo -e "DEBUG set [${DEBUG}], enabling debugging output...";
  10. set -ex
  11. fi
  12. # Reset from possible previous test run
  13. killall -9 weed || echo "already stopped"
  14. rm -Rf tmp
  15. mkdir tmp
  16. docker stop $CONTAINER_NAME || echo "already stopped"
  17. # Ensure ulimit is set to reasonable value
  18. ulimit -n 10000
  19. # Start weed w/ filer + s3 in the background
  20. $WEED_BIN server \
  21. -filer \
  22. -s3 \
  23. -volume.max 0 \
  24. -master.volumeSizeLimitMB 5 \
  25. -dir "$(pwd)/tmp" \
  26. 1>&2>weed.log &
  27. # Wait for master to start up
  28. echo -e "\n[info] waiting for master @ 9333...";
  29. until curl --output /dev/null --silent --head --fail http://127.0.0.1:9333; do
  30. printf '.';
  31. sleep 5;
  32. done
  33. sleep 3;
  34. # Wait for s3 to start up
  35. echo -e "\n[info] waiting for S3 @ 8333...";
  36. until curl --output /dev/null --silent --fail http://127.0.0.1:8333; do
  37. printf '.';
  38. sleep 5;
  39. done
  40. sleep 3;
  41. # Determine whether docker net
  42. DOCKER_NET_HOST_ARGS=""
  43. if [ -n "${DOCKER_NET_HOST}" ]; then
  44. DOCKER_NET_HOST_ARGS="--net=host"
  45. echo -e "\n[info] setting docker to het nost"
  46. fi
  47. echo -e "\n[warn] You may have to run with UNFILTERED=y to disable output filtering, if you get the broken pipe error";
  48. echo -e "\n[info] running tests with unfiltered output...";
  49. docker run \
  50. --name $CONTAINER_NAME \
  51. --rm \
  52. ${DOCKER_NET_HOST_ARGS} \
  53. -e S3TEST_CONF=$CONF_FILE \
  54. -v "$(pwd)"/$CONF_FILE:/s3-tests/s3tests.conf \
  55. -it \
  56. s3tests \
  57. ./virtualenv/bin/nosetests \
  58. s3tests_boto3/functional/test_s3.py \
  59. -v \
  60. -a 'resource=object,!bucket-policy,!versioning,!encryption' \
  61. | tee ${TEST_RAW_OUTPUT_FILE}
  62. # If the summary logs are present, process them
  63. if [ -f "${TEST_RAW_OUTPUT_FILE}" ]; then
  64. cat ${TEST_RAW_OUTPUT_FILE} | sed -n -e '/botocore.hooks/!p;//q' | tee ${TEST_PROCESSED_OUTPUT_FILE}
  65. echo -e "\n[info] ✅ Successfully wrote processed output @ [${TEST_PROCESSED_OUTPUT_FILE}]";
  66. if [ -z "${TEST_KEEP_RAW_OUTPUT}" ]; then
  67. echo -e "\n[info] removing test raw output file @ [${TEST_RAW_OUTPUT_FILE}] (to disable this, set TEST_KEEP_RAW_OUTPUT=y)...";
  68. rm -rf ${TEST_RAW_OUTPUT_FILE};
  69. fi
  70. else
  71. echo -e "\n[warn] failed to find raw output @ [${TEST_RAW_OUTPUT_FILE}]";
  72. fi
  73. echo -e "\n[info] stopping [${CONTAINER_NAME}] container...";
  74. docker stop $CONTAINER_NAME || echo "[info] already stopped";
  75. echo -e "\n[info] stopping seaweedfs processes (all, via kill -9)...";
  76. killall -9 weed;