run.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 "" > phpserver.log
  37. php -S localhost:$PORT -t ../.. &> phpserver.log &
  38. PHPPID=$!
  39. echo $PHPPID
  40. # Output filtered php server logs
  41. tail -f phpserver.log | grep --line-buffered -v -E ":[0-9]+ Accepted$" | grep --line-buffered -v -E ":[0-9]+ Closing$" &
  42. # The federated server is started and stopped by the tests themselves
  43. PORT_FED=$((8180 + $EXECUTOR_NUMBER))
  44. echo $PORT_FED
  45. export PORT_FED
  46. export TEST_SERVER_URL="http://localhost:$PORT/ocs/"
  47. export TEST_SERVER_FED_URL="http://localhost:$PORT_FED/ocs/"
  48. if [ "$INSTALLED" == "true" ]; then
  49. #Enable external storage app
  50. $OCC app:enable files_external user_ldap
  51. mkdir -p work/local_storage
  52. OUTPUT_CREATE_STORAGE=`$OCC files_external:create local_storage local null::null -c datadir=$PWD/work/local_storage`
  53. ID_STORAGE=`echo $OUTPUT_CREATE_STORAGE | tr ' ' '\n' | tail -n1`
  54. $OCC files_external:option $ID_STORAGE enable_sharing true
  55. fi
  56. vendor/bin/behat --strict --colors -f junit -f pretty $TAGS $SCENARIO_TO_RUN
  57. RESULT=$?
  58. kill $PHPPID
  59. if [ "$INSTALLED" == "true" ]; then
  60. $OCC files_external:delete -y $ID_STORAGE
  61. #Disable external storage app
  62. $OCC app:disable files_external user_ldap
  63. fi
  64. if [ -z $HIDE_OC_LOGS ]; then
  65. tail "${NC_DATADIR}/nextcloud.log"
  66. fi
  67. echo "runsh: Exit code: $RESULT"
  68. exit $RESULT