1
0

run.sh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/usr/bin/env bash
  2. #
  3. # SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. # SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
  5. # SPDX-License-Identifier: AGPL-3.0-only
  6. #
  7. OC_PATH=../../
  8. OCC=${OC_PATH}occ
  9. TAGS=""
  10. if [ "$1" = "--tags" ]; then
  11. TAGS="--tags=$2"
  12. shift 2
  13. fi
  14. SCENARIO_TO_RUN=$1
  15. HIDE_OC_LOGS=$2
  16. INSTALLED=$($OCC status | grep installed: | cut -d " " -f 5)
  17. if [ "$INSTALLED" == "true" ]; then
  18. # Disable bruteforce protection because the integration tests do trigger them
  19. $OCC config:system:set auth.bruteforce.protection.enabled --value false --type bool
  20. # Allow local remote urls otherwise we can not share
  21. $OCC config:system:set allow_local_remote_servers --value true --type bool
  22. else
  23. if [ "$SCENARIO_TO_RUN" != "setup_features/setup.feature" ]; then
  24. echo "Nextcloud instance needs to be installed" >&2
  25. exit 1
  26. fi
  27. fi
  28. NC_DATADIR=$($OCC config:system:get datadirectory)
  29. composer install
  30. # avoid port collision on jenkins - use $EXECUTOR_NUMBER
  31. if [ -z "$EXECUTOR_NUMBER" ]; then
  32. EXECUTOR_NUMBER=0
  33. fi
  34. PORT=$((8080 + $EXECUTOR_NUMBER))
  35. echo $PORT
  36. echo "" > "${NC_DATADIR}/nextcloud.log"
  37. echo "" > phpserver.log
  38. PHP_CLI_SERVER_WORKERS=2 php -S localhost:$PORT -t ../.. &> phpserver.log &
  39. PHPPID=$!
  40. echo $PHPPID
  41. # Output filtered php server logs
  42. tail -f phpserver.log | grep --line-buffered -v -E ":[0-9]+ Accepted$" | grep --line-buffered -v -E ":[0-9]+ Closing$" &
  43. LOGPID=$!
  44. echo $LOGPID
  45. function cleanup() {
  46. kill $PHPPID
  47. kill $LOGPID
  48. }
  49. trap cleanup EXIT
  50. # The federated server is started and stopped by the tests themselves
  51. PORT_FED=$((8180 + $EXECUTOR_NUMBER))
  52. echo $PORT_FED
  53. export PORT_FED
  54. export TEST_SERVER_URL="http://localhost:$PORT/ocs/"
  55. export TEST_SERVER_FED_URL="http://localhost:$PORT_FED/ocs/"
  56. if [ "$INSTALLED" == "true" ]; then
  57. #Enable external storage app
  58. $OCC app:enable files_external user_ldap
  59. mkdir -p work/local_storage
  60. OUTPUT_CREATE_STORAGE=`$OCC files_external:create local_storage local null::null -c datadir=$PWD/work/local_storage`
  61. ID_STORAGE=`echo $OUTPUT_CREATE_STORAGE | tr ' ' '\n' | tail -n1`
  62. $OCC files_external:option $ID_STORAGE enable_sharing true
  63. fi
  64. vendor/bin/behat --strict --colors -f junit -f pretty $TAGS $SCENARIO_TO_RUN
  65. RESULT=$?
  66. if [ "$INSTALLED" == "true" ]; then
  67. $OCC files_external:delete -y $ID_STORAGE
  68. #Disable external storage app
  69. $OCC app:disable files_external user_ldap
  70. fi
  71. if [ -z $HIDE_OC_LOGS ]; then
  72. tail "${NC_DATADIR}/nextcloud.log"
  73. fi
  74. echo "runsh: Exit code: $RESULT"
  75. exit $RESULT