From 795f1fa6c8663e6fbf2596aa93b372fe438a3223 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Mon, 16 Jun 2025 18:08:12 +0545 Subject: [PATCH] test: fix restarting upload sessions Signed-off-by: Saw-jan --- tests/acceptance/bootstrap/FeatureContext.php | 3 +- tests/acceptance/bootstrap/WebDav.php | 40 ++++++++++++++++++ ...ected-failures-localAPI-on-OCIS-storage.md | 3 +- .../features/cliCommands/trashBin.feature | 4 +- .../cliCommands/uploadSessions.feature | 42 +++++++++++++++---- 5 files changed, 80 insertions(+), 12 deletions(-) diff --git a/tests/acceptance/bootstrap/FeatureContext.php b/tests/acceptance/bootstrap/FeatureContext.php index ce95cbd725b..b32e7ed76a3 100644 --- a/tests/acceptance/bootstrap/FeatureContext.php +++ b/tests/acceptance/bootstrap/FeatureContext.php @@ -3006,7 +3006,8 @@ class FeatureContext extends BehatVariablesContext { } /** - * @Given the system waits for :arg1 seconds + * @Given the administrator has waited for :seconds seconds + * @When the administrator waits for :seconds seconds * * @param string $seconds * diff --git a/tests/acceptance/bootstrap/WebDav.php b/tests/acceptance/bootstrap/WebDav.php index 2245ddd3b1f..cff050b6a1b 100644 --- a/tests/acceptance/bootstrap/WebDav.php +++ b/tests/acceptance/bootstrap/WebDav.php @@ -1035,6 +1035,46 @@ trait WebDav { $this->checkDownloadedContentMatches($content->getRaw(), '', $response); } + /** + * @When for user :user file :fileName of space :space should be in postprocessing + * + * @param string $user + * @param string $fileName + * @param string $space + * + * @return void + */ + public function forUserFileShouldBeInPostprocessing( + string $user, + string $fileName, + string $space, + ): void { + $user = $this->getActualUsername($user); + $password = $this->getPasswordForUser($user); + $davPathVersion = $this->getDavPathVersion(); + $suffixPath = $user; + if ($davPathVersion === WebDavHelper::DAV_VERSION_SPACES) { + $spaceId = $this->spacesContext->getSpaceIdByName($user, $space); + $suffixPath = $spaceId; + } + $davPath = WebDavHelper::getDavPath($davPathVersion, $suffixPath, "files"); + $fullUrl = $this->getBaseUrl() . "/$davPath/$fileName"; + $response = HttpRequestHelper::sendRequestOnce( + $fullUrl, + "GET", + $user, + $password, + ); + Assert::assertEquals( + 425, + $response->getStatusCode(), + __METHOD__ + . " : File '$fileName' not in postprocessing." + . " Expected status code to be '425', but got '" + . $response->getStatusCode() . "'" + ); + } + /** * @When user :user downloads file :fileName using the WebDAV API * @When user :user tries to download file :fileName using the WebDAV API diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index a20f3db6f67..42efa76d325 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -382,6 +382,7 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiActivities/activitiesByFileId.feature:2015](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiActivities/activitiesByFileId.feature#L2015) #### [Activity. no event for deleting a file using file-id](https://github.com/owncloud/ocis/issues/10328) + - [apiActivities/activitiesByFileId.feature:2190](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiActivities/activitiesByFileId.feature#L2190) #### Uploaders are not allowed to `MOVE` @@ -394,7 +395,7 @@ The expected failures in this file are from features in the owncloud/ocis repo. #### [[CLI] Error while resuming an upload](https://github.com/owncloud/ocis/issues/11290) -- [cliCommands/uploadSessions.feature:156](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/cliCommands/uploadSessions.feature#L156) +- [cliCommands/uploadSessions.feature:173](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/cliCommands/uploadSessions.feature#L173) Note: always have an empty line at the end of this file. The bash script that processes this file requires that the last line has a newline on the end. diff --git a/tests/acceptance/features/cliCommands/trashBin.feature b/tests/acceptance/features/cliCommands/trashBin.feature index 42ac43b151f..a0f0f24e10c 100644 --- a/tests/acceptance/features/cliCommands/trashBin.feature +++ b/tests/acceptance/features/cliCommands/trashBin.feature @@ -108,7 +108,7 @@ Feature: trashbin And user "Alice" has created a folder "uploadFolder" in space "Newspace" And user "Alice" has uploaded a file inside space "Newspace" with content "hello world" to "text.txt" And user "Alice" has removed the file "text.txt" from space "Newspace" - And the system waits for "1" seconds + And the administrator waits for "1" seconds When the administrator purges the expired trash resources Then there should be no trashed resources of space "Personal" owned by user "Alice" And there should be "1" trashed resources of space "Newspace" owned by user "Alice": @@ -130,7 +130,7 @@ Feature: trashbin And user "Alice" has created a folder "uploadFolder" in space "Newspace" And user "Alice" has uploaded a file inside space "Newspace" with content "hello world" to "text.txt" And user "Alice" has removed the file "text.txt" from space "Newspace" - And the system waits for "1" seconds + And the administrator waits for "1" seconds When the administrator purges the expired trash resources Then there should be no trashed resources of space "Newspace" owned by user "Alice" And there should be "1" trashed resources of space "Personal" owned by user "Alice": diff --git a/tests/acceptance/features/cliCommands/uploadSessions.feature b/tests/acceptance/features/cliCommands/uploadSessions.feature index 50913b1d4a2..853a758c961 100644 --- a/tests/acceptance/features/cliCommands/uploadSessions.feature +++ b/tests/acceptance/features/cliCommands/uploadSessions.feature @@ -29,7 +29,7 @@ Feature: List upload sessions via CLI command | ANTIVIRUS_INFECTED_FILE_HANDLING | abort | And user "Alice" has uploaded file "filesForUpload/filesWithVirus/eicar.com" to "/virusFile.txt" And the config "POSTPROCESSING_DELAY" has been set to "10s" - And the system waits for "5" seconds + And the administrator has waited for "2" seconds And user "Alice" has uploaded file with content "uploaded content" to "/file1.txt" And user "Alice" has uploaded file with content "uploaded content" to "/file2.txt" When the administrator lists all the upload sessions with flag "processing" @@ -88,27 +88,44 @@ Feature: List upload sessions via CLI command Scenario: restart upload sessions that are in postprocessing - Given user "Alice" has uploaded file with content "upload content" to "/file1.txt" - And the config "POSTPROCESSING_DELAY" has been set to "10s" + Given the config "POSTPROCESSING_DELAY" has been set to "3s" + And user "Alice" has uploaded file with content "upload content" to "/file1.txt" And user "Alice" has uploaded file with content "upload content" to "/file2.txt" + And the administrator has waited for "1" seconds + And the administrator has stopped the server + And the administrator has started the server + When the administrator waits for "3" seconds + Then for user "Alice" file "file1.txt" of space "Personal" should be in postprocessing + And for user "Alice" file "file2.txt" of space "Personal" should be in postprocessing When the administrator restarts the upload sessions that are in postprocessing Then the command should be successful And the CLI response should contain these entries: | file2.txt | - And the CLI response should not contain these entries: | file1.txt | + When the administrator waits for "3" seconds + Then the content of file "file1.txt" for user "Alice" should be "upload content" + And the content of file "file2.txt" for user "Alice" should be "upload content" Scenario: restart upload sessions of a single file - Given the config "POSTPROCESSING_DELAY" has been set to "10s" - And user "Alice" has uploaded file with content "upload content" to "/file1.txt" - And user "Alice" has uploaded file with content "upload content" to "/file2.txt" + Given the config "POSTPROCESSING_DELAY" has been set to "3s" + And user "Alice" has uploaded file with content "uploaded content" to "file1.txt" + And user "Alice" has uploaded file with content "uploaded content" to "file2.txt" + And the administrator has waited for "1" seconds + And the administrator has stopped the server + And the administrator has started the server + When the administrator waits for "3" seconds + Then for user "Alice" file "file1.txt" of space "Personal" should be in postprocessing + And for user "Alice" file "file2.txt" of space "Personal" should be in postprocessing When the administrator restarts the upload sessions of file "file1.txt" Then the command should be successful And the CLI response should contain these entries: | file1.txt | And the CLI response should not contain these entries: | file2.txt | + When the administrator waits for "3" seconds + Then for user "Alice" file "file2.txt" of space "Personal" should be in postprocessing + And the content of file "file1.txt" for user "Alice" should be "uploaded content" Scenario: clean all upload sessions that are not in post-processing @@ -154,11 +171,20 @@ Feature: List upload sessions via CLI command @issue-11290 Scenario: resume all upload sessions - Given the config "POSTPROCESSING_DELAY" has been set to "10s" + Given the following configs have been set: + | config | value | + | POSTPROCESSING_STEPS | virusscan,delay | + | ANTIVIRUS_INFECTED_FILE_HANDLING | abort | + | POSTPROCESSING_DELAY | 3s | And user "Alice" has uploaded file with content "upload content" to "file.txt" + And the administrator has waited for "1" seconds And the administrator has stopped the server And the administrator has started the server + When the administrator waits for "3" seconds + Then for user "Alice" file "file.txt" of space "Personal" should be in postprocessing When the administrator resumes all the upload sessions using the CLI Then the command should be successful And the CLI response should contain these entries: | file.txt | + When the administrator waits for "3" seconds + Then the content of file "file.txt" for user "Alice" should be "upload content"