summaryrefslogtreecommitdiffstats
path: root/tests/acceptance/features/core
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2017-05-03 12:53:02 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2017-05-03 23:18:40 +0200
commitb10478ff19be0e4c38f8ff6b0c31f1a40eda0043 (patch)
tree0da20e4f2571c176818ed62d26c8622d8234579f /tests/acceptance/features/core
parente355e953b54f0b610539176b5a3c70812efb66c7 (diff)
downloadnextcloud-server-b10478ff19be0e4c38f8ff6b0c31f1a40eda0043.tar.gz
nextcloud-server-b10478ff19be0e4c38f8ff6b0c31f1a40eda0043.zip
Try again to start browser sessions when they fail
Starting a session for an Actor can fail, typically, due to a timeout connecting with the web browser. Now if the session fails to start it will be tried again up to "actorTimeoutMultiplier" times in total before giving up. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests/acceptance/features/core')
-rw-r--r--tests/acceptance/features/core/ActorContext.php28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/acceptance/features/core/ActorContext.php b/tests/acceptance/features/core/ActorContext.php
index c62ebb5e74f..d6fb63694ec 100644
--- a/tests/acceptance/features/core/ActorContext.php
+++ b/tests/acceptance/features/core/ActorContext.php
@@ -40,7 +40,8 @@ use Behat\MinkExtension\Context\RawMinkContext;
*
* By default no multiplier for the find timeout is set in the Actors. However,
* it can be customized using the "actorTimeoutMultiplier" parameter of the
- * ActorContext in "behat.yml".
+ * ActorContext in "behat.yml". This parameter also affects the overall timeout
+ * to start a session for an Actor before giving up.
*
* Every actor used in the scenarios must have a corresponding Mink session
* declared in "behat.yml" with the same name as the actor. All used sessions
@@ -98,6 +99,31 @@ class ActorContext extends RawMinkContext {
}
/**
+ * Returns the session with the given name.
+ *
+ * If the session is not started it is started before returning it; if the
+ * session fails to start (typically due to a timeout connecting with the
+ * web browser) it will be tried again up to $actorTimeoutMultiplier times
+ * in total (rounded up to the next integer) before giving up.
+ *
+ * @param string|null $sname the name of the session to get, or null for the
+ * default session.
+ * @return \Behat\Mink\Session the session.
+ */
+ public function getSession($name = null) {
+ for ($i = 0; $i < ($this->actorTimeoutMultiplier - 1); $i++) {
+ try {
+ return parent::getSession($name);
+ } catch (\Behat\Mink\Exception\DriverException $exception) {
+ echo "Exception when getting " . ($name == null? "default session": "session '$name'") . ": " . $exception->getMessage() . "\n";
+ echo "Trying again\n";
+ }
+ }
+
+ return parent::getSession($name);
+ }
+
+ /**
* @BeforeScenario
*
* Initializes the Actors for the new Scenario with the default Actor.