diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-07-20 11:31:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-20 11:31:48 +0200 |
commit | ac969cfbb6ec65150f296bcba1685ecffa5c73e7 (patch) | |
tree | 9a3afac107c61b83198357a33926a3f22f08a0da | |
parent | 5e468c0bbaf6b9838a1b92bcb04836dccff7b532 (diff) | |
parent | 94144269de6d2318d7e018642a65d01872625b48 (diff) | |
download | nextcloud-server-ac969cfbb6ec65150f296bcba1685ecffa5c73e7.tar.gz nextcloud-server-ac969cfbb6ec65150f296bcba1685ecffa5c73e7.zip |
Merge pull request #5800 from nextcloud/enable-acceptance-tests-again-on-drone-0.7
Enable acceptance tests again on Drone 0.7
-rw-r--r-- | .drone.yml | 18 | ||||
-rw-r--r-- | tests/acceptance/features/core/NextcloudTestServerLocalHelper.php | 22 | ||||
-rwxr-xr-x | tests/acceptance/installAndConfigureServer.sh | 12 | ||||
-rwxr-xr-x | tests/acceptance/run-local.sh | 75 |
4 files changed, 110 insertions, 17 deletions
diff --git a/.drone.yml b/.drone.yml index b8750e66f5e..50726e412cc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -469,21 +469,21 @@ pipeline: acceptance-access-levels: image: nextcloudci/integration-php7.0:integration-php7.0-4 commands: - - tests/acceptance/run-local.sh --timeout-multiplier 10 allow-git-repository-modifications features/access-levels.feature + - tests/acceptance/run-local.sh --timeout-multiplier 10 --nextcloud-server-domain acceptance-access-levels --selenium-server selenium:4444 allow-git-repository-modifications features/access-levels.feature when: matrix: TESTS-ACCEPTANCE: access-levels acceptance-app-files: image: nextcloudci/integration-php7.0:integration-php7.0-4 commands: - - tests/acceptance/run-local.sh --timeout-multiplier 10 allow-git-repository-modifications features/app-files.feature + - tests/acceptance/run-local.sh --timeout-multiplier 10 --nextcloud-server-domain acceptance-app-files --selenium-server selenium:4444 allow-git-repository-modifications features/app-files.feature when: matrix: TESTS-ACCEPTANCE: app-files acceptance-login: image: nextcloudci/integration-php7.0:integration-php7.0-4 commands: - - tests/acceptance/run-local.sh --timeout-multiplier 10 allow-git-repository-modifications features/login.feature + - tests/acceptance/run-local.sh --timeout-multiplier 10 --nextcloud-server-domain acceptance-login --selenium-server selenium:4444 allow-git-repository-modifications features/login.feature when: matrix: TESTS-ACCEPTANCE: login @@ -574,12 +574,12 @@ matrix: - TESTS: integration-transfer-ownership-features - TESTS: integration-ldap-features - TESTS: integration-trashbin -# - TESTS: acceptance -# TESTS-ACCEPTANCE: access-levels -# - TESTS: acceptance -# TESTS-ACCEPTANCE: app-files -# - TESTS: acceptance -# TESTS-ACCEPTANCE: login + - TESTS: acceptance + TESTS-ACCEPTANCE: access-levels + - TESTS: acceptance + TESTS-ACCEPTANCE: app-files + - TESTS: acceptance + TESTS-ACCEPTANCE: login - TESTS: jsunit - TESTS: syntax-php5.6 - TESTS: syntax-php7.0 diff --git a/tests/acceptance/features/core/NextcloudTestServerLocalHelper.php b/tests/acceptance/features/core/NextcloudTestServerLocalHelper.php index 32b5330c61a..b11a9ae8217 100644 --- a/tests/acceptance/features/core/NextcloudTestServerLocalHelper.php +++ b/tests/acceptance/features/core/NextcloudTestServerLocalHelper.php @@ -35,9 +35,12 @@ * the Nextcloud server; the last commit in that Git repository must provide the * initial state for the Nextcloud server expected by the acceptance tests. * - * The Nextcloud server is available at "127.0.0.1", so it is expected to see - * "127.0.0.1" as a trusted domain (which would be the case if it was installed - * by running "occ maintenance:install"). The base URL to access the Nextcloud + * The Nextcloud server is available at "$nextcloudServerDomain", which can be + * optionally specified when the NextcloudTestServerLocalHelper is created; if + * no value is given "127.0.0.1" is used by default. In any case, the value of + * "$nextcloudServerDomain" must be seen as a trusted domain by the Nextcloud + * server (which would be the case for "127.0.0.1" if it was installed by + * running "occ maintenance:install"). The base URL to access the Nextcloud * server can be got from "getBaseUrl". */ class NextcloudTestServerLocalHelper implements NextcloudTestServerHelper { @@ -45,12 +48,19 @@ class NextcloudTestServerLocalHelper implements NextcloudTestServerHelper { /** * @var string */ + private $nextcloudServerDomain; + + /** + * @var string + */ private $phpServerPid; /** * Creates a new NextcloudTestServerLocalHelper. */ - public function __construct() { + public function __construct($nextcloudServerDomain = "127.0.0.1") { + $this->nextcloudServerDomain = $nextcloudServerDomain; + $this->phpServerPid = ""; } @@ -77,7 +87,7 @@ class NextcloudTestServerLocalHelper implements NextcloudTestServerHelper { // execOrException is not used because the server is started in the // background, so the command will always succeed even if the server // itself fails. - $this->phpServerPid = exec("php -S 127.0.0.1:80 -t ../../ >/dev/null 2>&1 & echo $!"); + $this->phpServerPid = exec("php -S " . $this->nextcloudServerDomain . ":80 -t ../../ >/dev/null 2>&1 & echo $!"); $timeout = 60; if (!Utils::waitForServer($this->getBaseUrl(), $timeout)) { @@ -100,7 +110,7 @@ class NextcloudTestServerLocalHelper implements NextcloudTestServerHelper { * @return string the base URL of the Nextcloud test server. */ public function getBaseUrl() { - return "http://127.0.0.1/index.php"; + return "http://" . $this->nextcloudServerDomain . "/index.php"; } /** diff --git a/tests/acceptance/installAndConfigureServer.sh b/tests/acceptance/installAndConfigureServer.sh index 2fbdf821f77..c61faeda238 100755 --- a/tests/acceptance/installAndConfigureServer.sh +++ b/tests/acceptance/installAndConfigureServer.sh @@ -25,6 +25,18 @@ set -o errexit +NEXTCLOUD_SERVER_DOMAIN="" +if [ "$1" = "--nextcloud-server-domain" ]; then + NEXTCLOUD_SERVER_DOMAIN=$2 + + shift 2 +fi + php occ maintenance:install --admin-pass=admin OC_PASS=123456acb php occ user:add --password-from-env user0 + +if [ "$NEXTCLOUD_SERVER_DOMAIN" != "" ]; then + # Default first trusted domain is "localhost"; replace it with given domain. + php occ config:system:set trusted_domains 0 --value="$NEXTCLOUD_SERVER_DOMAIN" +fi diff --git a/tests/acceptance/run-local.sh b/tests/acceptance/run-local.sh index 93c11e810f8..e2270be3854 100755 --- a/tests/acceptance/run-local.sh +++ b/tests/acceptance/run-local.sh @@ -54,6 +54,26 @@ if [ "$1" = "--timeout-multiplier" ]; then shift 2 fi +# "--nextcloud-server-domain XXX" option can be provided to set the domain used +# by the Selenium server to access the Nextcloud server. +DEFAULT_NEXTCLOUD_SERVER_DOMAIN="127.0.0.1" +NEXTCLOUD_SERVER_DOMAIN="$DEFAULT_NEXTCLOUD_SERVER_DOMAIN" +if [ "$1" = "--nextcloud-server-domain" ]; then + NEXTCLOUD_SERVER_DOMAIN=$2 + + shift 2 +fi + +# "--selenium-server XXX" option can be provided to set the domain and port used +# by the acceptance tests to access the Selenium server. +DEFAULT_SELENIUM_SERVER="127.0.0.1:4444" +SELENIUM_SERVER="$DEFAULT_SELENIUM_SERVER" +if [ "$1" = "--selenium-server" ]; then + SELENIUM_SERVER=$2 + + shift 2 +fi + # Safety parameter to prevent executing this script by mistake and messing with # the Git repository. if [ "$1" != "allow-git-repository-modifications" ]; then @@ -80,12 +100,63 @@ if [ "$TIMEOUT_MULTIPLIER" != "" ]; then sed --in-place "s/$ORIGINAL/$REPLACEMENT/" config/behat.yml fi +if [ "$NEXTCLOUD_SERVER_DOMAIN" != "$DEFAULT_NEXTCLOUD_SERVER_DOMAIN" ]; then + # Although Behat documentation states that using the BEHAT_PARAMS + # environment variable "You can set any value for any option that is + # available in a behat.yml file" this is currently not true for the + # constructor parameters of contexts (see + # https://github.com/Behat/Behat/issues/983). Thus, the default "behat.yml" + # configuration file has to be adjusted to provide the appropriate + # parameters for NextcloudTestServerContext. + ORIGINAL="\ + - NextcloudTestServerContext" + REPLACEMENT="\ + - NextcloudTestServerContext:\n\ + nextcloudTestServerHelperParameters:\n\ + - $NEXTCLOUD_SERVER_DOMAIN" + sed --in-place "s/$ORIGINAL/$REPLACEMENT/" config/behat.yml +fi + +if [ "$SELENIUM_SERVER" != "$DEFAULT_SELENIUM_SERVER" ]; then + # Set the Selenium server to be used by Mink; this extends the default + # configuration from "config/behat.yml". + export BEHAT_PARAMS=' +{ + "extensions": { + "Behat\\MinkExtension": { + "sessions": { + "default": { + "selenium2": { + "wd_host": "http://'"$SELENIUM_SERVER"'/wd/hub" + } + }, + "John": { + "selenium2": { + "wd_host": "http://'"$SELENIUM_SERVER"'/wd/hub" + } + }, + "Jane": { + "selenium2": { + "wd_host": "http://'"$SELENIUM_SERVER"'/wd/hub" + } + } + } + } + } +}' +fi + composer install cd ../../ +INSTALL_AND_CONFIGURE_SERVER_PARAMETERS="" +if [ "$NEXTCLOUD_SERVER_domain" != "$DEFAULT_NEXTCLOUD_SERVER_DOMAIN" ]; then + INSTALL_AND_CONFIGURE_SERVER_PARAMETERS+="--nextcloud-server-domain $NEXTCLOUD_SERVER_DOMAIN" +fi + echo "Installing and configuring Nextcloud server" -tests/acceptance/installAndConfigureServer.sh +tests/acceptance/installAndConfigureServer.sh $INSTALL_AND_CONFIGURE_SERVER_PARAMETERS echo "Saving the default state so acceptance tests can reset to it" find . -name ".gitignore" -exec rm --force {} \; @@ -95,6 +166,6 @@ cd tests/acceptance # Ensure that the Selenium server is ready before running the tests. echo "Waiting for Selenium" -timeout 60s bash -c "while ! curl 127.0.0.1:4444 >/dev/null 2>&1; do sleep 1; done" +timeout 60s bash -c "while ! curl $SELENIUM_SERVER >/dev/null 2>&1; do sleep 1; done" vendor/bin/behat $SCENARIO_TO_RUN |