Skip to content

Commit

Permalink
Merge pull request #38929 from owncloud/fix-upload-wait
Browse files Browse the repository at this point in the history
[Tests-Only] Add new env variable to specify the wait times between uploads and deletes
  • Loading branch information
phil-davis authored Jul 1, 2021
2 parents b1efa3b + 4afb755 commit 82f2699
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ Feature: files and folders exist in the trashbin after being deleted
| new |

@local_storage
@skipOnEncryptionType:user-keys @encryption-issue-42
@skip_on_objectstore
@skipOnEncryptionType:user-keys @encryption-issue-42
@skip_on_objectstore
Scenario Outline: Deleting a folder into external storage moves it to the trashbin
Given using <dav-path> DAV path
And the administrator has invoked occ command "files:scan --all"
Expand Down
22 changes: 18 additions & 4 deletions tests/acceptance/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -4466,15 +4466,29 @@ public function findEntryFromPropfindResponse(
}

/**
* prevent creating two uploads with the same "stime" which is
* based on seconds, this prevents creation of uploads with same etag
* Prevent creating two uploads and/or deletes with the same "stime"
* That is based on seconds in some implementations.
* This prevents duplication of etags or other problems with
* trashbin/versions save/restore.
*
* Set env var UPLOAD_DELETE_WAIT_TIME to 1 to activate a 1-second pause.
* By default, there is no pause. That allows testing of implementations
* which should be able to cope with multiple upload/delete actions in the
* same second.
*
* @return void
*/
public function pauseUploadDelete() {
$time = \time();
if ($this->lastUploadDeleteTime !== null && $time - $this->lastUploadDeleteTime < 1) {
\sleep(1);
$uploadWaitTime = \getenv("UPLOAD_DELETE_WAIT_TIME");

$uploadWaitTime = $uploadWaitTime ? (int)$uploadWaitTime : 0;

if (($this->lastUploadDeleteTime !== null)
&& ($uploadWaitTime > 0)
&& (($time - $this->lastUploadDeleteTime) < $uploadWaitTime)
) {
\sleep($uploadWaitTime);
}
}

Expand Down
8 changes: 8 additions & 0 deletions tests/acceptance/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,14 @@ export IPV4_URL
export IPV6_URL
export FILES_FOR_UPLOAD="${SCRIPT_PATH}/filesForUpload/"

if [ "${TEST_OCIS}" != "true" ] && [ "${TEST_REVA}" != "true" ]
then
# We are testing on an ownCloud core server.
# Tell the tests to wait 1 second between each upload/delete action
# to avoid problems with actions that depend on timestamps in seconds.
export UPLOAD_DELETE_WAIT_TIME=1
fi

TEST_LOG_FILE=$(mktemp)
SCENARIOS_THAT_PASSED=0
SCENARIOS_THAT_FAILED=0
Expand Down

0 comments on commit 82f2699

Please sign in to comment.