run.sh 1.9 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. 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
  42. $OCC app:enable 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 -f junit -f pretty $TAGS $SCENARIO_TO_RUN
  49. RESULT=$?
  50. kill $PHPPID
  51. kill $PHPPID_FED
  52. if [ "$INSTALLED" == "true" ]; then
  53. $OCC files_external:delete -y $ID_STORAGE
  54. #Disable external storage app
  55. $OCC app:disable files_external
  56. $OCC app:disable 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