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>
This commit is contained in:
parent
c570a37939
commit
cfee9a2625
|
@ -40,9 +40,29 @@ class FederationContext implements Context, SnippetAcceptingContext {
|
||||||
use AppConfiguration;
|
use AppConfiguration;
|
||||||
use CommandLine;
|
use CommandLine;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
private static $phpFederatedServerPid = '';
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $lastAcceptedRemoteShareId;
|
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
|
* @BeforeScenario
|
||||||
*/
|
*/
|
||||||
|
@ -157,6 +177,19 @@ class FederationContext implements Context, SnippetAcceptingContext {
|
||||||
$this->sendingToWith('DELETE', "/apps/files_sharing/api/v1/remote_shares/" . $this->lastAcceptedRemoteShareId, null);
|
$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() {
|
protected function resetAppConfigs() {
|
||||||
$this->deleteServerConfig('files_sharing', 'incoming_server2server_group_share_enabled');
|
$this->deleteServerConfig('files_sharing', 'incoming_server2server_group_share_enabled');
|
||||||
$this->deleteServerConfig('files_sharing', 'outgoing_server2server_group_share_enabled');
|
$this->deleteServerConfig('files_sharing', 'outgoing_server2server_group_share_enabled');
|
||||||
|
|
|
@ -318,6 +318,54 @@ Feature: federated
|
||||||
| type | file |
|
| type | file |
|
||||||
| file_id | A_NUMBER |
|
| file_id | A_NUMBER |
|
||||||
|
|
||||||
|
Scenario: List federated share from another server no longer reachable
|
||||||
|
Given Using server "LOCAL"
|
||||||
|
And user "user0" exists
|
||||||
|
Given Using server "REMOTE"
|
||||||
|
And user "user1" exists
|
||||||
|
# Rename file so it has a unique name in the target server (as the target
|
||||||
|
# server may have its own /textfile0.txt" file)
|
||||||
|
And User "user1" copies file "/textfile0.txt" to "/remote-share.txt"
|
||||||
|
And User "user1" from server "REMOTE" shares "/remote-share.txt" with user "user0" from server "LOCAL"
|
||||||
|
And Using server "LOCAL"
|
||||||
|
And User "user0" from server "LOCAL" accepts last pending share
|
||||||
|
And remote server is stopped
|
||||||
|
When As an "user0"
|
||||||
|
And sending "GET" to "/apps/files_sharing/api/v1/remote_shares"
|
||||||
|
Then the list of returned shares has 1 shares
|
||||||
|
And remote share 0 is returned with
|
||||||
|
| remote | http://localhost:8180/ |
|
||||||
|
| name | /remote-share.txt |
|
||||||
|
| owner | user1 |
|
||||||
|
| user | user0 |
|
||||||
|
| mountpoint | /remote-share.txt |
|
||||||
|
|
||||||
|
Scenario: List federated share from another server no longer reachable after caching the file entry
|
||||||
|
Given Using server "LOCAL"
|
||||||
|
And user "user0" exists
|
||||||
|
Given Using server "REMOTE"
|
||||||
|
And user "user1" exists
|
||||||
|
# Rename file so it has a unique name in the target server (as the target
|
||||||
|
# server may have its own /textfile0.txt" file)
|
||||||
|
And User "user1" copies file "/textfile0.txt" to "/remote-share.txt"
|
||||||
|
And User "user1" from server "REMOTE" shares "/remote-share.txt" with user "user0" from server "LOCAL"
|
||||||
|
And Using server "LOCAL"
|
||||||
|
And User "user0" from server "LOCAL" accepts last pending share
|
||||||
|
# Checking that the file exists caches the file entry, which causes an
|
||||||
|
# exception to be thrown when getting the file info if the remote server is
|
||||||
|
# unreachable.
|
||||||
|
And as "user0" the file "/remote-share.txt" exists
|
||||||
|
And remote server is stopped
|
||||||
|
When As an "user0"
|
||||||
|
And sending "GET" to "/apps/files_sharing/api/v1/remote_shares"
|
||||||
|
Then the list of returned shares has 1 shares
|
||||||
|
And remote share 0 is returned with
|
||||||
|
| remote | http://localhost:8180/ |
|
||||||
|
| name | /remote-share.txt |
|
||||||
|
| owner | user1 |
|
||||||
|
| user | user0 |
|
||||||
|
| mountpoint | /remote-share.txt |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Scenario: Delete federated share with another server
|
Scenario: Delete federated share with another server
|
||||||
|
@ -382,6 +430,30 @@ Feature: federated
|
||||||
And sending "GET" to "/apps/files_sharing/api/v1/shares"
|
And sending "GET" to "/apps/files_sharing/api/v1/shares"
|
||||||
And the list of returned shares has 0 shares
|
And the list of returned shares has 0 shares
|
||||||
|
|
||||||
|
Scenario: Delete federated share from another server no longer reachable
|
||||||
|
Given Using server "LOCAL"
|
||||||
|
And user "user0" exists
|
||||||
|
Given Using server "REMOTE"
|
||||||
|
And user "user1" exists
|
||||||
|
# Rename file so it has a unique name in the target server (as the target
|
||||||
|
# server may have its own /textfile0.txt" file)
|
||||||
|
And User "user1" copies file "/textfile0.txt" to "/remote-share.txt"
|
||||||
|
And User "user1" from server "REMOTE" shares "/remote-share.txt" with user "user0" from server "LOCAL"
|
||||||
|
And Using server "LOCAL"
|
||||||
|
And User "user0" from server "LOCAL" accepts last pending share
|
||||||
|
And as "user0" the file "/remote-share.txt" exists
|
||||||
|
And As an "user0"
|
||||||
|
And sending "GET" to "/apps/files_sharing/api/v1/remote_shares"
|
||||||
|
And the list of returned shares has 1 shares
|
||||||
|
And remote server is stopped
|
||||||
|
When user "user0" deletes last accepted remote share
|
||||||
|
Then the OCS status code should be "100"
|
||||||
|
And the HTTP status code should be "200"
|
||||||
|
And as "user0" the file "/remote-share.txt" does not exist
|
||||||
|
And As an "user0"
|
||||||
|
And sending "GET" to "/apps/files_sharing/api/v1/remote_shares"
|
||||||
|
And the list of returned shares has 0 shares
|
||||||
|
|
||||||
Scenario: Delete federated share file from another server
|
Scenario: Delete federated share file from another server
|
||||||
Given Using server "LOCAL"
|
Given Using server "LOCAL"
|
||||||
And user "user0" exists
|
And user "user0" exists
|
||||||
|
@ -410,3 +482,26 @@ Feature: federated
|
||||||
And As an "user1"
|
And As an "user1"
|
||||||
And sending "GET" to "/apps/files_sharing/api/v1/shares"
|
And sending "GET" to "/apps/files_sharing/api/v1/shares"
|
||||||
And the list of returned shares has 0 shares
|
And the list of returned shares has 0 shares
|
||||||
|
|
||||||
|
Scenario: Delete federated share file from another server no longer reachable
|
||||||
|
Given Using server "LOCAL"
|
||||||
|
And user "user0" exists
|
||||||
|
Given Using server "REMOTE"
|
||||||
|
And user "user1" exists
|
||||||
|
# Rename file so it has a unique name in the target server (as the target
|
||||||
|
# server may have its own /textfile0.txt" file)
|
||||||
|
And User "user1" copies file "/textfile0.txt" to "/remote-share.txt"
|
||||||
|
And User "user1" from server "REMOTE" shares "/remote-share.txt" with user "user0" from server "LOCAL"
|
||||||
|
And Using server "LOCAL"
|
||||||
|
And User "user0" from server "LOCAL" accepts last pending share
|
||||||
|
And as "user0" the file "/remote-share.txt" exists
|
||||||
|
And As an "user0"
|
||||||
|
And sending "GET" to "/apps/files_sharing/api/v1/remote_shares"
|
||||||
|
And the list of returned shares has 1 shares
|
||||||
|
And remote server is stopped
|
||||||
|
When User "user0" deletes file "/remote-share.txt"
|
||||||
|
Then the HTTP status code should be "204"
|
||||||
|
And as "user0" the file "/remote-share.txt" does not exist
|
||||||
|
And As an "user0"
|
||||||
|
And sending "GET" to "/apps/files_sharing/api/v1/remote_shares"
|
||||||
|
And the list of returned shares has 0 shares
|
||||||
|
|
|
@ -38,11 +38,10 @@ php -S localhost:$PORT -t ../.. &
|
||||||
PHPPID=$!
|
PHPPID=$!
|
||||||
echo $PHPPID
|
echo $PHPPID
|
||||||
|
|
||||||
|
# The federated server is started and stopped by the tests themselves
|
||||||
PORT_FED=$((8180 + $EXECUTOR_NUMBER))
|
PORT_FED=$((8180 + $EXECUTOR_NUMBER))
|
||||||
echo $PORT_FED
|
echo $PORT_FED
|
||||||
php -S localhost:$PORT_FED -t ../.. &
|
export PORT_FED
|
||||||
PHPPID_FED=$!
|
|
||||||
echo $PHPPID_FED
|
|
||||||
|
|
||||||
export TEST_SERVER_URL="http://localhost:$PORT/ocs/"
|
export TEST_SERVER_URL="http://localhost:$PORT/ocs/"
|
||||||
export TEST_SERVER_FED_URL="http://localhost:$PORT_FED/ocs/"
|
export TEST_SERVER_FED_URL="http://localhost:$PORT_FED/ocs/"
|
||||||
|
@ -65,7 +64,6 @@ vendor/bin/behat --strict -f junit -f pretty $TAGS $SCENARIO_TO_RUN
|
||||||
RESULT=$?
|
RESULT=$?
|
||||||
|
|
||||||
kill $PHPPID
|
kill $PHPPID
|
||||||
kill $PHPPID_FED
|
|
||||||
|
|
||||||
if [ "$INSTALLED" == "true" ]; then
|
if [ "$INSTALLED" == "true" ]; then
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue