run.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/usr/bin/env bash
  2. OC_PATH=../../
  3. OCC=${OC_PATH}occ
  4. TAGS=""
  5. if [ "$1" = "--tags" ]; then
  6. TAGS="--tags=$2"
  7. shift 2
  8. fi
  9. SCENARIO_TO_RUN=$1
  10. HIDE_OC_LOGS=$2
  11. INSTALLED=$($OCC status | grep installed: | cut -d " " -f 5)
  12. if [ "$INSTALLED" == "true" ]; then
  13. # Disable bruteforce protection because the integration tests do trigger them
  14. $OCC config:system:set auth.bruteforce.protection.enabled --value false --type bool
  15. # Allow local remote urls otherwise we can not share
  16. $OCC config:system:set allow_local_remote_servers --value true --type bool
  17. else
  18. if [ "$SCENARIO_TO_RUN" != "setup_features/setup.feature" ]; then
  19. echo "Nextcloud instance needs to be installed" >&2
  20. exit 1
  21. fi
  22. fi
  23. NC_DATADIR=$($OCC config:system:get datadirectory)
  24. composer install
  25. # avoid port collision on jenkins - use $EXECUTOR_NUMBER
  26. if [ -z "$EXECUTOR_NUMBER" ]; then
  27. EXECUTOR_NUMBER=0
  28. fi
  29. PORT=$((8080 + $EXECUTOR_NUMBER))
  30. echo $PORT
  31. echo "" > phpserver.log
  32. PHP_CLI_SERVER_WORKERS=2 php -S localhost:$PORT -t ../.. &> phpserver.log &
  33. PHPPID=$!
  34. echo $PHPPID
  35. # Output filtered php server logs
  36. tail -f phpserver.log | grep --line-buffered -v -E ":[0-9]+ Accepted$" | grep --line-buffered -v -E ":[0-9]+ Closing$" &
  37. # The federated server is started and stopped by the tests themselves
  38. PORT_FED=$((8180 + $EXECUTOR_NUMBER))
  39. echo $PORT_FED
  40. export PORT_FED
  41. export TEST_SERVER_URL="http://localhost:$PORT/ocs/"
  42. export TEST_SERVER_FED_URL="http://localhost:$PORT_FED/ocs/"
  43. if [ "$INSTALLED" == "true" ]; then
  44. #Enable external storage app
  45. $OCC app:enable files_external user_ldap
  46. mkdir -p work/local_storage
  47. OUTPUT_CREATE_STORAGE=`$OCC files_external:create local_storage local null::null -c datadir=$PWD/work/local_storage`
  48. ID_STORAGE=`echo $OUTPUT_CREATE_STORAGE | tr ' ' '\n' | tail -n1`
  49. $OCC files_external:option $ID_STORAGE enable_sharing true
  50. fi
  51. vendor/bin/behat --strict --colors -f junit -f pretty $TAGS $SCENARIO_TO_RUN
  52. RESULT=$?
  53. kill $PHPPID
  54. if [ "$INSTALLED" == "true" ]; then
  55. $OCC files_external:delete -y $ID_STORAGE
  56. #Disable external storage app
  57. $OCC app:disable files_external user_ldap
  58. fi
  59. if [ -z $HIDE_OC_LOGS ]; then
  60. tail "${NC_DATADIR}/nextcloud.log"
  61. fi
  62. echo "runsh: Exit code: $RESULT"
  63. exit $RESULT