From 4fe775e4ab00dafebcba94ca0539a3ea61fdce70 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sat, 17 Feb 2018 21:49:19 +0545 Subject: [PATCH 1/2] Retry when doing upload overwrite in UI tests --- .../ui/features/bootstrap/FeatureContext.php | 18 +++++++++ tests/ui/features/bootstrap/FilesContext.php | 39 +++++++++++++++++++ .../ui/features/bootstrap/SharingContext.php | 2 +- tests/ui/features/bootstrap/bootstrap.php | 2 + tests/ui/features/lib/FilesPage.php | 4 +- tests/ui/features/lib/FilesPageBasic.php | 2 +- tests/ui/features/lib/PublicLinkFilesPage.php | 4 +- .../federationSharing.feature | 2 +- .../shareByPublicLink.feature | 2 +- .../shareWithGroups.feature | 4 +- .../shareWithUsers.feature | 4 +- tests/ui/features/upload/upload.feature | 24 ++++++------ .../features/upload/uploadEdgecases.feature | 6 +-- 13 files changed, 86 insertions(+), 27 deletions(-) diff --git a/tests/ui/features/bootstrap/FeatureContext.php b/tests/ui/features/bootstrap/FeatureContext.php index 4086afda5364..4aa6d2a8e5f7 100644 --- a/tests/ui/features/bootstrap/FeatureContext.php +++ b/tests/ui/features/bootstrap/FeatureContext.php @@ -27,6 +27,7 @@ use Behat\MinkExtension\Context\RawMinkContext; use Page\LoginPage; use Page\OwncloudPage; +use SensioLabs\Behat\PageObjectExtension\PageObject\Exception\ElementNotFoundException; use TestHelpers\AppConfigHelper; use TestHelpers\SetupHelper; use TestHelpers\UploadHelper; @@ -174,6 +175,23 @@ public function getCurrentPageObject() { return $this->currentPageObject; } + /** + * @Then no notification should be displayed + * @return void + */ + public function noNotificationShouldBeDisplayed() { + try { + $notificationText = $this->owncloudPage->getNotificationText(); + PHPUnit_Framework_Assert::assertEquals( + '', + $notificationText, + "Expecting no notifications but got $notificationText" + ); + } catch (ElementNotFoundException $e) { + // if there is no notification element, then good + } + } + /** * @Then a notification should be displayed with the text :notificationText * @param string $notificationText expected notification text diff --git a/tests/ui/features/bootstrap/FilesContext.php b/tests/ui/features/bootstrap/FilesContext.php index 57e9db566bdf..baf131674b59 100644 --- a/tests/ui/features/bootstrap/FilesContext.php +++ b/tests/ui/features/bootstrap/FilesContext.php @@ -461,6 +461,45 @@ public function iUploadOverwritingTheFile($name) { $this->iClickTheButton("Continue"); } + /** + * @When I upload overwriting the file :name and retry if the file is locked + * @param string $name + * @return void + */ + public function iUploadOverwritingTheFileRetry($name) { + $previousNotificationsCount = 0; + + for ($retryCounter = 0; $retryCounter < STANDARDRETRYCOUNT; $retryCounter++) { + $this->iUploadTheFile($name); + $this->choiceInUploadConflict("new"); + $this->iClickTheButton("Continue"); + + try { + $notifications = $this->filesPage->getNotifications(); + } catch (ElementNotFoundException $e) { + $notifications = []; + } + + $currentNotificationsCount = count($notifications); + + if ($currentNotificationsCount > $previousNotificationsCount) { + $message = "Upload overwriting $name and got $currentNotificationsCount notifications including " . end($notifications) . "\n"; + echo $message; + error_log($message); + $previousNotificationsCount = $currentNotificationsCount; + usleep(STANDARDSLEEPTIMEMICROSEC); + } else { + break; + } + } + + if ($retryCounter > 0) { + $message = "INFORMATION: retried to upload overwriting file $name $retryCounter times"; + echo $message; + error_log($message); + } + } + /** * @When I upload the file :name keeping both new and existing files * @param string $name diff --git a/tests/ui/features/bootstrap/SharingContext.php b/tests/ui/features/bootstrap/SharingContext.php index 7f857f3967d2..aa2f720c2f7a 100644 --- a/tests/ui/features/bootstrap/SharingContext.php +++ b/tests/ui/features/bootstrap/SharingContext.php @@ -89,7 +89,7 @@ private function addToListOfCreatedPublicLinks($name, $url) { * @return void */ public function theFileFolderIsSharedWithTheUser( - $folder, $remote, $user, $maxRetries = 5, $quiet = false + $folder, $remote, $user, $maxRetries = STANDARDRETRYCOUNT, $quiet = false ) { $this->filesPage->waitTillPageIsloaded($this->getSession()); try { diff --git a/tests/ui/features/bootstrap/bootstrap.php b/tests/ui/features/bootstrap/bootstrap.php index d3417bab04c1..768c46ad2f7b 100644 --- a/tests/ui/features/bootstrap/bootstrap.php +++ b/tests/ui/features/bootstrap/bootstrap.php @@ -38,3 +38,5 @@ const STANDARDUIWAITTIMEOUTMILLISEC = 10000; // Minimum timeout for use in code that needs to wait for the UI const MINIMUMUIWAITTIMEOUTMILLISEC = 500; +// Default number of times to retry where retries are useful +const STANDARDRETRYCOUNT = 5; diff --git a/tests/ui/features/lib/FilesPage.php b/tests/ui/features/lib/FilesPage.php index d30b3fe2c134..d5fb2ad5f934 100644 --- a/tests/ui/features/lib/FilesPage.php +++ b/tests/ui/features/lib/FilesPage.php @@ -241,7 +241,7 @@ public function renameFile( $fromFileName, $toFileName, Session $session, - $maxRetries = 5 + $maxRetries = STANDARDRETRYCOUNT ) { if (is_array($toFileName)) { $toFileName = implode($toFileName); @@ -281,7 +281,7 @@ public function renameFile( * @return void */ public function moveFileTo( - $name, $destination, Session $session, $maxRetries = 5 + $name, $destination, Session $session, $maxRetries = STANDARDRETRYCOUNT ) { $toMoveFileRow = $this->findFileRowByName($name, $session); $destinationFileRow = $this->findFileRowByName($destination, $session); diff --git a/tests/ui/features/lib/FilesPageBasic.php b/tests/ui/features/lib/FilesPageBasic.php index 556f54f8caf4..820cc13f112e 100644 --- a/tests/ui/features/lib/FilesPageBasic.php +++ b/tests/ui/features/lib/FilesPageBasic.php @@ -263,7 +263,7 @@ public function openFile($name, Session $session) { * @param int $maxRetries * @return void */ - public function deleteFile($name, Session $session, $maxRetries = 5) { + public function deleteFile($name, Session $session, $maxRetries = STANDARDRETRYCOUNT) { $this->initAjaxCounters($session); $this->resetSumStartedAjaxRequests($session); diff --git a/tests/ui/features/lib/PublicLinkFilesPage.php b/tests/ui/features/lib/PublicLinkFilesPage.php index 270dc6df10b9..91b3c176f923 100644 --- a/tests/ui/features/lib/PublicLinkFilesPage.php +++ b/tests/ui/features/lib/PublicLinkFilesPage.php @@ -128,7 +128,7 @@ public function renameFile( $fromFileName, $toFileName, Session $session, - $maxRetries = 5 + $maxRetries = STANDARDRETRYCOUNT ) { throw new \Exception("not implemented"); } @@ -143,7 +143,7 @@ public function renameFile( * @return void */ public function moveFileTo( - $name, $destination, Session $session, $maxRetries = 5 + $name, $destination, Session $session, $maxRetries = STANDARDRETRYCOUNT ) { throw new \Exception("not implemented"); } diff --git a/tests/ui/features/sharingExternalOther/federationSharing.feature b/tests/ui/features/sharingExternalOther/federationSharing.feature index b2512b016cf1..9fdedcd98d1a 100644 --- a/tests/ui/features/sharingExternalOther/federationSharing.feature +++ b/tests/ui/features/sharingExternalOther/federationSharing.feature @@ -41,7 +41,7 @@ So that other users have access to these files And I relogin with username "user1" and password "1234" to "http://%remote_server%" And the offered remote shares are accepted And I open the folder "simple-folder (2)" - And I upload overwriting the file "lorem.txt" + And I upload overwriting the file "lorem.txt" and retry if the file is locked And I relogin with username "user2" and password "1234" to "%base_url%" And I open the folder "simple-folder" Then the file "lorem.txt" should be listed diff --git a/tests/ui/features/sharingExternalOther/shareByPublicLink.feature b/tests/ui/features/sharingExternalOther/shareByPublicLink.feature index 788375a6e595..53e3694b9537 100644 --- a/tests/ui/features/sharingExternalOther/shareByPublicLink.feature +++ b/tests/ui/features/sharingExternalOther/shareByPublicLink.feature @@ -72,6 +72,6 @@ So that public sharing is limited according to organization policy When I open the folder "simple-folder (2)" Then the file "lorem.txt" should be listed And the content of "lorem.txt" should be the same as the original "simple-folder/lorem.txt" - When I upload overwriting the file "lorem.txt" + When I upload overwriting the file "lorem.txt" and retry if the file is locked Then the file "lorem.txt" should be listed And the content of "lorem.txt" should be the same as the local "lorem.txt" \ No newline at end of file diff --git a/tests/ui/features/sharingInternalGroupsUsers/shareWithGroups.feature b/tests/ui/features/sharingInternalGroupsUsers/shareWithGroups.feature index 467f9cdfb32a..cfc07797cb28 100644 --- a/tests/ui/features/sharingInternalGroupsUsers/shareWithGroups.feature +++ b/tests/ui/features/sharingInternalGroupsUsers/shareWithGroups.feature @@ -40,7 +40,7 @@ So that those groups can access the files and folders And I relogin with username "user1" and password "1234" Then the content of "new-lorem.txt" should not be the same as the local "new-lorem.txt" # overwrite the received shared file - When I upload overwriting the file "new-lorem.txt" + When I upload overwriting the file "new-lorem.txt" and retry if the file is locked Then the file "new-lorem.txt" should be listed And the content of "new-lorem.txt" should be the same as the local "new-lorem.txt" # unshare the received shared file @@ -61,7 +61,7 @@ So that those groups can access the files and folders And I open the folder "new-simple-folder" Then the content of "lorem.txt" should not be the same as the local "lorem.txt" # overwrite an existing file in the received share - When I upload overwriting the file "lorem.txt" + When I upload overwriting the file "lorem.txt" and retry if the file is locked Then the file "lorem.txt" should be listed And the content of "lorem.txt" should be the same as the local "lorem.txt" # upload a new file into the received share diff --git a/tests/ui/features/sharingInternalGroupsUsers/shareWithUsers.feature b/tests/ui/features/sharingInternalGroupsUsers/shareWithUsers.feature index 039f97a07687..653180dc9a1e 100644 --- a/tests/ui/features/sharingInternalGroupsUsers/shareWithUsers.feature +++ b/tests/ui/features/sharingInternalGroupsUsers/shareWithUsers.feature @@ -32,7 +32,7 @@ So that those users can access the files and folders And I relogin with username "user1" and password "1234" Then the content of "new-lorem.txt" should not be the same as the local "new-lorem.txt" # overwrite the received shared file - When I upload overwriting the file "new-lorem.txt" + When I upload overwriting the file "new-lorem.txt" and retry if the file is locked Then the file "new-lorem.txt" should be listed And the content of "new-lorem.txt" should be the same as the local "new-lorem.txt" # unshare the received shared file @@ -50,7 +50,7 @@ So that those users can access the files and folders And I open the folder "new-simple-folder" Then the content of "lorem.txt" should not be the same as the local "lorem.txt" # overwrite an existing file in the received share - When I upload overwriting the file "lorem.txt" + When I upload overwriting the file "lorem.txt" and retry if the file is locked Then the file "lorem.txt" should be listed And the content of "lorem.txt" should be the same as the local "lorem.txt" # upload a new file into the received share diff --git a/tests/ui/features/upload/upload.feature b/tests/ui/features/upload/upload.feature index 08de73cea481..d42b135561f6 100644 --- a/tests/ui/features/upload/upload.feature +++ b/tests/ui/features/upload/upload.feature @@ -14,34 +14,33 @@ So that I can store files in ownCloud Scenario: simple upload of a file that does not exist before When I upload the file "new-lorem.txt" - Then the file "new-lorem.txt" should be listed + Then no notification should be displayed + And the file "new-lorem.txt" should be listed And the content of "new-lorem.txt" should be the same as the local "new-lorem.txt" Scenario: chunking upload And a file with the size of "30000000" bytes and the name "big-video.mp4" exists When I upload the file "big-video.mp4" - Then the file "big-video.mp4" should be listed + Then no notification should be displayed + And the file "big-video.mp4" should be listed And the content of "big-video.mp4" should be the same as the local "big-video.mp4" Scenario: conflict with a chunked file And a file with the size of "30000000" bytes and the name "big-video.mp4" exists When I rename the file "lorem.txt" to "big-video.mp4" - And I upload the file "big-video.mp4" - And I choose to keep the new files - And I click the "Continue" button + And I upload overwriting the file "big-video.mp4" and retry if the file is locked Then the file "big-video.mp4" should be listed And the content of "big-video.mp4" should be the same as the local "big-video.mp4" Scenario: upload a new file into a sub folder When I open the folder "simple-folder" And I upload the file "new-lorem.txt" - Then the file "new-lorem.txt" should be listed + Then no notification should be displayed + And the file "new-lorem.txt" should be listed And the content of "new-lorem.txt" should be the same as the local "new-lorem.txt" Scenario: overwrite an existing file - When I upload the file "lorem.txt" - And I choose to keep the new files - And I click the "Continue" button + When I upload overwriting the file "lorem.txt" and retry if the file is locked Then no dialog should be displayed And the file "lorem.txt" should be listed And the content of "lorem.txt" should be the same as the local "lorem.txt" @@ -53,6 +52,7 @@ So that I can store files in ownCloud And I choose to keep the existing files And I click the "Continue" button Then no dialog should be displayed + And no notification should be displayed And the file "lorem.txt" should be listed And the content of "lorem.txt" should not have changed And the file "lorem (2).txt" should be listed @@ -62,15 +62,14 @@ So that I can store files in ownCloud When I upload the file "lorem.txt" And I click the "Cancel" button Then no dialog should be displayed + And no notification should be displayed And the file "lorem.txt" should be listed And the content of "lorem.txt" should not have changed And the file "lorem (2).txt" should not be listed Scenario: overwrite an existing file in a sub-folder When I open the folder "simple-folder" - When I upload the file "lorem.txt" - And I choose to keep the new files - And I click the "Continue" button + And I upload overwriting the file "lorem.txt" and retry if the file is locked Then the file "lorem.txt" should be listed And the content of "lorem.txt" should be the same as the local "lorem.txt" @@ -81,6 +80,7 @@ So that I can store files in ownCloud And I choose to keep the existing files And I click the "Continue" button Then no dialog should be displayed + And no notification should be displayed And the file "lorem.txt" should be listed And the content of "lorem.txt" should not have changed And the file "lorem (2).txt" should be listed diff --git a/tests/ui/features/upload/uploadEdgecases.feature b/tests/ui/features/upload/uploadEdgecases.feature index 9898757f541e..d7be6a59c3d0 100644 --- a/tests/ui/features/upload/uploadEdgecases.feature +++ b/tests/ui/features/upload/uploadEdgecases.feature @@ -52,15 +52,15 @@ that is not academically correct but saves a lot of time | "strängé नेपाली folder" | Scenario: overwrite an existing file - When I upload overwriting the file "'single'quotes.txt" + When I upload overwriting the file "'single'quotes.txt" and retry if the file is locked Then the file "'single'quotes.txt" should be listed And the content of "'single'quotes.txt" should be the same as the local "'single'quotes.txt" - When I upload overwriting the file "strängé filename (duplicate #2 &).txt" + When I upload overwriting the file "strängé filename (duplicate #2 &).txt" and retry if the file is locked Then the file "strängé filename (duplicate #2 &).txt" should be listed And the content of "strängé filename (duplicate #2 &).txt" should be the same as the local "strängé filename (duplicate #2 &).txt" - When I upload overwriting the file "zzzz-must-be-last-file-in-folder.txt" + When I upload overwriting the file "zzzz-must-be-last-file-in-folder.txt" and retry if the file is locked Then the file "zzzz-must-be-last-file-in-folder.txt" should be listed And the content of "zzzz-must-be-last-file-in-folder.txt" should be the same as the local "zzzz-must-be-last-file-in-folder.txt" From b1079c9cf27fb41ee17529a303f108cb27e72c09 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 18 Feb 2018 10:33:16 +0545 Subject: [PATCH 2/2] Run UI upload suite 10 more times --- .drone.yml | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/.drone.yml b/.drone.yml index 7d09e39b4616..2c6686b360f8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -348,6 +348,66 @@ matrix: TEST_SUITE: coverage FILES_EXTERNAL_TYPE: webdav + - PHP_VERSION: 7.1 + TEST_SUITE: selenium + BEHAT_SUITE: upload + DB_TYPE: mariadb + USE_SERVER: true + + - PHP_VERSION: 7.1 + TEST_SUITE: selenium + BEHAT_SUITE: upload + DB_TYPE: mariadb + USE_SERVER: true + + - PHP_VERSION: 7.1 + TEST_SUITE: selenium + BEHAT_SUITE: upload + DB_TYPE: mariadb + USE_SERVER: true + + - PHP_VERSION: 7.1 + TEST_SUITE: selenium + BEHAT_SUITE: upload + DB_TYPE: mariadb + USE_SERVER: true + + - PHP_VERSION: 7.1 + TEST_SUITE: selenium + BEHAT_SUITE: upload + DB_TYPE: mariadb + USE_SERVER: true + + - PHP_VERSION: 7.1 + TEST_SUITE: selenium + BEHAT_SUITE: upload + DB_TYPE: mariadb + USE_SERVER: true + + - PHP_VERSION: 7.1 + TEST_SUITE: selenium + BEHAT_SUITE: upload + DB_TYPE: mariadb + USE_SERVER: true + + - PHP_VERSION: 7.1 + TEST_SUITE: selenium + BEHAT_SUITE: upload + DB_TYPE: mariadb + USE_SERVER: true + + - PHP_VERSION: 7.1 + TEST_SUITE: selenium + BEHAT_SUITE: upload + DB_TYPE: mariadb + USE_SERVER: true + + - PHP_VERSION: 7.1 + TEST_SUITE: selenium + BEHAT_SUITE: upload + DB_TYPE: mariadb + USE_SERVER: true + - PHP_VERSION: 7.1 TEST_SUITE: selenium BEHAT_SUITE: other