run.sh 1.9 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. else
  16. if [ "$SCENARIO_TO_RUN" != "setup_features/setup.feature" ]; then
  17. echo "Nextcloud instance needs to be installed" >&2
  18. exit 1
  19. fi
  20. fi
  21. NC_DATADIR=$($OCC config:system:get datadirectory)
  22. composer install
  23. # avoid port collision on jenkins - use $EXECUTOR_NUMBER
  24. if [ -z "$EXECUTOR_NUMBER" ]; then
  25. EXECUTOR_NUMBER=0
  26. fi
  27. PORT=$((8080 + $EXECUTOR_NUMBER))
  28. echo $PORT
  29. php -S localhost:$PORT -t ../.. &
  30. PHPPID=$!
  31. echo $PHPPID
  32. PORT_FED=$((8180 + $EXECUTOR_NUMBER))
  33. echo $PORT_FED
  34. php -S localhost:$PORT_FED -t ../.. &
  35. PHPPID_FED=$!
  36. echo $PHPPID_FED
  37. export TEST_SERVER_URL="http://localhost:$PORT/ocs/"
  38. export TEST_SERVER_FED_URL="http://localhost:$PORT_FED/ocs/"
  39. if [ "$INSTALLED" == "true" ]; then
  40. #Enable external storage app
  41. $OCC app:enable files_external user_ldap
  42. mkdir -p work/local_storage
  43. OUTPUT_CREATE_STORAGE=`$OCC files_external:create local_storage local null::null -c datadir=$PWD/work/local_storage`
  44. ID_STORAGE=`echo $OUTPUT_CREATE_STORAGE | tr ' ' '\n' | tail -n1`
  45. $OCC files_external:option $ID_STORAGE enable_sharing true
  46. fi
  47. vendor/bin/behat --strict -f junit -f pretty $TAGS $SCENARIO_TO_RUN
  48. RESULT=$?
  49. kill $PHPPID
  50. kill $PHPPID_FED
  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