diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2021-01-22 14:34:02 +0100 |
---|---|---|
committer | Vincent Petry <vincent@nextcloud.com> | 2021-11-05 09:48:52 +0100 |
commit | 51317a8b922bfecf4ab021ff4514b1926a118568 (patch) | |
tree | b97b401fbfaa8d2fb4743f1c74d62c47e2da6600 /build/integration/features/bootstrap/FederationContext.php | |
parent | 9497a7c4ff77cf44d8b1fb875070d60b6404c449 (diff) | |
download | nextcloud-server-51317a8b922bfecf4ab021ff4514b1926a118568.tar.gz nextcloud-server-51317a8b922bfecf4ab021ff4514b1926a118568.zip |
Add integration tests for federated shares from unavailable servers
The federated server needs to be stopped during the tests, so it is now
stopped in the FederationContext for each scenario instead of just once
in the run.sh script.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'build/integration/features/bootstrap/FederationContext.php')
-rw-r--r-- | build/integration/features/bootstrap/FederationContext.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/build/integration/features/bootstrap/FederationContext.php b/build/integration/features/bootstrap/FederationContext.php index a4472c54b1b..423708adc10 100644 --- a/build/integration/features/bootstrap/FederationContext.php +++ b/build/integration/features/bootstrap/FederationContext.php @@ -41,10 +41,30 @@ class FederationContext implements Context, SnippetAcceptingContext { use CommandLine; /** @var string */ + private static $phpFederatedServerPid = ''; + + /** @var string */ private $lastAcceptedRemoteShareId; /** * @BeforeScenario + * @AfterScenario + * + * The server is started also after the scenarios to ensure that it is + * properly cleaned up if stopped. + */ + public function startFederatedServer() { + if (self::$phpFederatedServerPid !== '') { + return; + } + + $port = getenv('PORT_FED'); + + self::$phpFederatedServerPid = exec('php -S localhost:' . $port . ' -t ../../ >/dev/null & echo $!'); + } + + /** + * @BeforeScenario */ public function cleanupRemoteStorages() { // Ensure that dangling remote storages from previous tests will not @@ -157,6 +177,19 @@ class FederationContext implements Context, SnippetAcceptingContext { $this->sendingToWith('DELETE', "/apps/files_sharing/api/v1/remote_shares/" . $this->lastAcceptedRemoteShareId, null); } + /** + * @When /^remote server is stopped$/ + */ + public function remoteServerIsStopped() { + if (self::$phpFederatedServerPid === '') { + return; + } + + exec('kill ' . self::$phpFederatedServerPid); + + self::$phpFederatedServerPid = ''; + } + protected function resetAppConfigs() { $this->deleteServerConfig('files_sharing', 'incoming_server2server_group_share_enabled'); $this->deleteServerConfig('files_sharing', 'outgoing_server2server_group_share_enabled'); |