run.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/usr/bin/env bash
  2. OC_PATH=../../
  3. OCC=${OC_PATH}occ
  4. SCENARIO_TO_RUN=$1
  5. HIDE_OC_LOGS=$2
  6. INSTALLED=$($OCC status | grep installed: | cut -d " " -f 5)
  7. if [ "$INSTALLED" == "true" ]; then
  8. # Disable bruteforce protection because the integration tests do trigger them
  9. $OCC config:system:set auth.bruteforce.protection.enabled --value false --type bool
  10. else
  11. if [ "$SCENARIO_TO_RUN" != "setup_features/setup.feature" ]; then
  12. echo "Nextcloud instance needs to be installed" >&2
  13. exit 1
  14. fi
  15. fi
  16. composer install
  17. # avoid port collision on jenkins - use $EXECUTOR_NUMBER
  18. if [ -z "$EXECUTOR_NUMBER" ]; then
  19. EXECUTOR_NUMBER=0
  20. fi
  21. PORT=$((8080 + $EXECUTOR_NUMBER))
  22. echo $PORT
  23. php -S localhost:$PORT -t ../.. &
  24. PHPPID=$!
  25. echo $PHPPID
  26. PORT_FED=$((8180 + $EXECUTOR_NUMBER))
  27. echo $PORT_FED
  28. php -S localhost:$PORT_FED -t ../.. &
  29. PHPPID_FED=$!
  30. echo $PHPPID_FED
  31. export TEST_SERVER_URL="http://localhost:$PORT/ocs/"
  32. export TEST_SERVER_FED_URL="http://localhost:$PORT_FED/ocs/"
  33. if [ "$INSTALLED" == "true" ]; then
  34. #Enable external storage app
  35. $OCC app:enable files_external
  36. mkdir -p work/local_storage
  37. OUTPUT_CREATE_STORAGE=`$OCC files_external:create local_storage local null::null -c datadir=./build/integration/work/local_storage`
  38. ID_STORAGE=`echo $OUTPUT_CREATE_STORAGE | tr ' ' '\n' | tail -n1`
  39. $OCC files_external:option $ID_STORAGE enable_sharing true
  40. fi
  41. vendor/bin/behat --strict -f junit -f pretty $SCENARIO_TO_RUN
  42. RESULT=$?
  43. kill $PHPPID
  44. kill $PHPPID_FED
  45. if [ "$INSTALLED" == "true" ]; then
  46. $OCC files_external:delete -y $ID_STORAGE
  47. #Disable external storage app
  48. $OCC app:disable files_external
  49. fi
  50. if [ -z $HIDE_OC_LOGS ]; then
  51. tail "${OC_PATH}/data/nextcloud.log"
  52. fi
  53. echo "runsh: Exit code: $RESULT"
  54. exit $RESULT