Merge pull request #5804 from nextcloud/12-backport-5800

[stable12] Enable acceptance tests again on Drone 0.7
This commit is contained in:
Morris Jobke 2017-07-20 13:07:59 +02:00 committed by GitHub
commit ad1c6a0fc2
4 changed files with 110 additions and 17 deletions

View File

@ -459,21 +459,21 @@ pipeline:
acceptance-access-levels:
image: nextcloudci/php7.0:php7.0-7
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/php7.0:php7.0-7
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/php7.0:php7.0-7
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
@ -564,12 +564,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

View File

@ -35,13 +35,21 @@
* 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 {
/**
* @var string
*/
private $nextcloudServerDomain;
/**
* @var string
*/
@ -50,7 +58,9 @@ class NextcloudTestServerLocalHelper implements NextcloudTestServerHelper {
/**
* 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";
}
/**

View File

@ -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

View File

@ -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