1
0

run.sh 2.0 KB

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