run.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. PHP_CLI_SERVER_WORKERS=2 php -S localhost:$PORT -t ../.. &
  32. PHPPID=$!
  33. echo $PHPPID
  34. # The federated server is started and stopped by the tests themselves
  35. PORT_FED=$((8180 + $EXECUTOR_NUMBER))
  36. echo $PORT_FED
  37. export PORT_FED
  38. export TEST_SERVER_URL="http://localhost:$PORT/ocs/"
  39. export TEST_SERVER_FED_URL="http://localhost:$PORT_FED/ocs/"
  40. if [ "$INSTALLED" == "true" ]; then
  41. #Enable external storage app
  42. $OCC app:enable files_external user_ldap
  43. mkdir -p work/local_storage
  44. OUTPUT_CREATE_STORAGE=`$OCC files_external:create local_storage local null::null -c datadir=$PWD/work/local_storage`
  45. ID_STORAGE=`echo $OUTPUT_CREATE_STORAGE | tr ' ' '\n' | tail -n1`
  46. $OCC files_external:option $ID_STORAGE enable_sharing true
  47. fi
  48. vendor/bin/behat --strict --colors -f junit -f pretty $TAGS $SCENARIO_TO_RUN
  49. RESULT=$?
  50. kill $PHPPID
  51. if [ "$INSTALLED" == "true" ]; then
  52. $OCC files_external:delete -y $ID_STORAGE
  53. #Disable external storage app
  54. $OCC app:disable files_external user_ldap
  55. fi
  56. if [ -z $HIDE_OC_LOGS ]; then
  57. tail "${NC_DATADIR}/nextcloud.log"
  58. fi
  59. echo "runsh: Exit code: $RESULT"
  60. exit $RESULT