mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-11-26 10:07:34 -05:00
test: 1419: acceptance tests for the revision cleanup
A new cliCommands feature, cleanupFileVersions.feature, tests the
"storage-users revisions cleanup" command against a running server,
checking the remaining versions through the WebDAV versions API:
- keeping the newest version of every file in all spaces
- a dry run, which deletes nothing
- only a folder within the personal space (--space with --path)
- only a project space (--space)
- the JSON output (--json)
- no strategy while the configured one is disabled: exit code 1
- a timeout: exit code 2, nothing deleted
- a strategy without spaces after its commas ("auto,1"), as the CLI
wrapper splits commands on spaces
- a folder by its path on disk (--fs-path), posix only
- the configured strategy (STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY),
which cleans up a file whenever it gets a new version: without
background workers, and with them, the default
- the configured strategy for uploads with TUS, as the web UI and the
clients upload
- the age of a version, which is the time its content was written:
uploads with an older modification time (X-OC-Mtime) make versions
that "30d" deletes right away, while "1,30d" keeps the newest one
- restoring a version with the strategy "0": the content from before
the restore is kept, so that the restore can be undone
A second feature, collaborativePosix/cleanupFileVersions.feature, tests
the versions that changes on the POSIX filesystem create, with
STORAGE_USERS_POSIX_ENABLE_FS_REVISIONS: the configured strategy cleans
up a file whenever a change on disk creates a version, with and without
background workers, and the command deletes such versions. The
collaborativePosix suite doesn't run in the CI for now
(https://github.com/opencloud-eu/opencloud/issues/2036), so these
scenarios are ready for when it does again; they pass locally. The
suite gets the FilesVersionsContext, whose steps its existing version
scenarios already use.
New steps: in CliContext, running the command for all spaces, a space,
a path within a space, a path on the POSIX filesystem, or with flags
only; checking the exact exit code; and checking the objects of a JSON
output, which "the command output should contain" can't match as it
contains quotes. In FilesVersionsContext, a number of versions that is
checked until it matches, for the cleanup that runs in the background
after postprocessing. In WebDav, the Given form of an upload with
content and a modification time.
Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
1 parent
26a7b4f903
commit
9c99eeae36
6 files changed
+518
No files matched your search
@@ -336,6 +336,165 @@ class CliContext implements Context {
|
||||
$this->featureContext->setResponse(CliHelper::runCommand($body));
|
||||
}
|
||||
|
||||
/**
|
||||
* runs the revisions cleanup command with the files to clean up and further flags
|
||||
*
|
||||
* @param string $scope the flags that select the files, e.g. "--all"
|
||||
* @param string $flags e.g. "--strategy 1 --dry-run"
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function cleanUpFileVersions(string $scope, string $flags): void {
|
||||
$command = \trim("storage-users revisions cleanup $scope $flags");
|
||||
$body = [
|
||||
"command" => $command
|
||||
];
|
||||
$this->featureContext->setResponse(CliHelper::runCommand($body));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $flags
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[When('the administrator cleans up the file versions using the CLI with flags :flags')]
|
||||
public function theAdministratorCleansUpTheFileVersionsUsingTheCliWithFlags(string $flags): void {
|
||||
$this->cleanUpFileVersions("", $flags);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $flags
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[When('the administrator cleans up the file versions of all spaces using the CLI with flags :flags')]
|
||||
public function theAdministratorCleansUpTheFileVersionsOfAllSpacesUsingTheCliWithFlags(string $flags): void {
|
||||
$this->cleanUpFileVersions("--all", $flags);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $space
|
||||
* @param string $user
|
||||
* @param string $flags
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[When('the administrator cleans up the file versions of space :space of user :user using the CLI with flags :flags')]
|
||||
public function theAdministratorCleansUpTheFileVersionsOfSpaceUsingTheCliWithFlags(
|
||||
string $space,
|
||||
string $user,
|
||||
string $flags
|
||||
): void {
|
||||
$spaceId = $this->spacesContext->getSpaceIdByName($user, $space);
|
||||
$this->cleanUpFileVersions("--space $spaceId", $flags);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $space
|
||||
* @param string $user
|
||||
* @param string $flags
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[When('the administrator cleans up the file versions of :path in space :space of user :user using the CLI with flags :flags')]
|
||||
public function theAdministratorCleansUpTheFileVersionsOfPathInSpaceUsingTheCliWithFlags(
|
||||
string $path,
|
||||
string $space,
|
||||
string $user,
|
||||
string $flags
|
||||
): void {
|
||||
$spaceId = $this->spacesContext->getSpaceIdByName($user, $space);
|
||||
$this->cleanUpFileVersions("--space $spaceId --path $path", $flags);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $user
|
||||
* @param string $flags
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[When('the administrator cleans up the file versions of :path of user :user by its path on the POSIX filesystem using the CLI with flags :flags')]
|
||||
public function theAdministratorCleansUpTheFileVersionsByPathOnPosixUsingTheCliWithFlags(
|
||||
string $path,
|
||||
string $user,
|
||||
string $flags
|
||||
): void {
|
||||
$userUuid = $this->featureContext->getAttributeOfCreatedUser($user, 'id');
|
||||
$fsPath = $this->getUsersStoragePath() . "/$userUuid/" . \ltrim($path, '/');
|
||||
$this->cleanUpFileVersions("--fs-path $fsPath", $flags);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $exitCode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[Then('the command should exit with code :exitCode')]
|
||||
public function theCommandShouldExitWithCode(int $exitCode): void {
|
||||
$response = $this->featureContext->getResponse();
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
|
||||
|
||||
$jsonResponse = $this->featureContext->getJsonDecodedResponse($response);
|
||||
Assert::assertSame(
|
||||
$exitCode,
|
||||
$jsonResponse["exitCode"],
|
||||
"Expected exit code $exitCode, but got " . $jsonResponse["exitCode"]
|
||||
. ". Message: " . $jsonResponse["message"]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks the output of a command that prints JSON objects, one per line, e.g. with --json,
|
||||
* for an object with a "type" and the given values
|
||||
*
|
||||
* @param string $type
|
||||
* @param TableNode $table with the columns "key" and "value"
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[Then('the JSON output of the command should contain an object of type :type with:')]
|
||||
public function theJsonOutputOfTheCommandShouldContainAnObjectOfTypeWith(string $type, TableNode $table): void {
|
||||
$response = $this->featureContext->getResponse();
|
||||
$message = $this->featureContext->getJsonDecodedResponse($response)["message"];
|
||||
$expected = [];
|
||||
foreach ($table->getHash() as $row) {
|
||||
$expected[$row['key']] = $this->featureContext->substituteInLineCodes($row['value']);
|
||||
}
|
||||
|
||||
// other lines, e.g. log messages, are not JSON objects
|
||||
foreach (\preg_split('/\r?\n/', $message) as $line) {
|
||||
$object = \json_decode(\trim($line), true);
|
||||
if (!\is_array($object) || ($object["type"] ?? null) !== $type) {
|
||||
continue;
|
||||
}
|
||||
$matches = true;
|
||||
foreach ($expected as $key => $value) {
|
||||
$actual = $object[$key] ?? null;
|
||||
if (\is_bool($actual)) {
|
||||
$actual = $actual ? "true" : "false";
|
||||
}
|
||||
if ((string)$actual !== $value) {
|
||||
$matches = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($matches) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Assert::fail(
|
||||
"No JSON object of type '$type' with " . \json_encode($expected) . " in the output:\n$message"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return void
|
||||
|
||||
@@ -84,6 +84,36 @@ class FilesVersionsContext implements Context {
|
||||
$this->featureContext->setResponse($this->getFileVersions($user, $file));
|
||||
}
|
||||
|
||||
/**
|
||||
* for changes that happen in the background, e.g. the revision cleanup after postprocessing
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $user
|
||||
* @param int $number
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
#[Then('the number of versions of file :file for user :user should eventually be :number')]
|
||||
public function theNumberOfVersionsOfFileForUserShouldEventuallyBe(string $file, string $user, int $number): void {
|
||||
$actualNumber = null;
|
||||
for ($attempt = 0; $attempt < 20; $attempt++) {
|
||||
$response = $this->getFileVersions($user, $file);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(207, '', $response);
|
||||
$responseXmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
$actualNumber = \count($responseXmlObject->xpath("//d:getlastmodified"));
|
||||
if ($actualNumber === $number) {
|
||||
return;
|
||||
}
|
||||
\usleep(500000);
|
||||
}
|
||||
Assert::assertEquals(
|
||||
$number,
|
||||
$actualNumber,
|
||||
"Expected number of versions of file '$file' was '$number', but got '$actualNumber' after 10 seconds"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
|
||||
@@ -2371,6 +2371,36 @@ trait WebDav {
|
||||
$this->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $user
|
||||
* @param string|null $content
|
||||
* @param string $mtime e.g. "-60 days", anything DateTime accepts
|
||||
* @param string $destination
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
#[Given('user :user has uploaded a file with content :content and mtime :mtime to :destination')]
|
||||
public function userHasUploadedAFileWithContentAndMtimeTo(
|
||||
string $user,
|
||||
?string $content,
|
||||
string $mtime,
|
||||
string $destination
|
||||
): void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$mtime = new DateTime($mtime);
|
||||
$mtime = $mtime->format('U');
|
||||
$response = $this->makeDavRequest(
|
||||
$user,
|
||||
"PUT",
|
||||
$destination,
|
||||
["X-OC-Mtime" => $mtime],
|
||||
$content
|
||||
);
|
||||
$this->theHTTPStatusCodeShouldBe(["201", "204"], "", $response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $user
|
||||
* @param string $checksum
|
||||
|
||||
@@ -493,6 +493,7 @@ default:
|
||||
- OcConfigContext:
|
||||
- SharingNgContext:
|
||||
- PublicWebDavContext:
|
||||
- FilesVersionsContext:
|
||||
|
||||
coreApiMain:
|
||||
paths:
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
@env-config
|
||||
Feature: clean up old file versions according to a cleanup strategy
|
||||
As an administrator
|
||||
I want to delete old file versions according to a cleanup strategy
|
||||
So that files that are not changed anymore don't keep all their old versions
|
||||
|
||||
# The strategies are written without spaces, as the CLI wrapper splits commands on spaces;
|
||||
# "2,auto,10" is the same as "2, auto, 10".
|
||||
|
||||
Background:
|
||||
Given user "Alice" has been created with default attributes
|
||||
|
||||
|
||||
Scenario: keep only the newest version of every file in all spaces
|
||||
Given user "Alice" has uploaded file with content "version 1" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 3" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 4" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 1" to "anotherFile.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "anotherFile.txt"
|
||||
When the administrator cleans up the file versions of all spaces using the CLI with flags "--strategy 1"
|
||||
Then the command should be successful
|
||||
And the command output should contain "/textfile.txt: deleted 2 of 3 revisions"
|
||||
And the command output should not contain "/anotherFile.txt"
|
||||
And the command output should contain "deleted 2 revisions"
|
||||
When user "Alice" gets the number of versions of file "textfile.txt"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "1"
|
||||
When user "Alice" gets the number of versions of file "anotherFile.txt"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "1"
|
||||
And the content of file "textfile.txt" for user "Alice" should be "version 4"
|
||||
|
||||
|
||||
Scenario: a dry run only prints what would be deleted
|
||||
Given user "Alice" has uploaded file with content "version 1" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 3" to "textfile.txt"
|
||||
When the administrator cleans up the file versions of all spaces using the CLI with flags "-s 0 --dry-run"
|
||||
Then the command should be successful
|
||||
And the command output should contain "/textfile.txt: would delete 2 of 2 revisions"
|
||||
When user "Alice" gets the number of versions of file "textfile.txt"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "2"
|
||||
|
||||
|
||||
Scenario: clean up only a folder within the personal space
|
||||
Given user "Alice" has created folder "folder"
|
||||
And user "Alice" has uploaded file with content "version 1" to "folder/inFolder.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "folder/inFolder.txt"
|
||||
And user "Alice" has uploaded file with content "version 3" to "folder/inFolder.txt"
|
||||
And user "Alice" has uploaded file with content "version 1" to "outside.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "outside.txt"
|
||||
And user "Alice" has uploaded file with content "version 3" to "outside.txt"
|
||||
When the administrator cleans up the file versions of "/folder" in space "Personal" of user "Alice" using the CLI with flags "-s 0"
|
||||
Then the command should be successful
|
||||
And the command output should contain "/folder/inFolder.txt: deleted 2 of 2 revisions"
|
||||
When user "Alice" gets the number of versions of file "folder/inFolder.txt"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "0"
|
||||
When user "Alice" gets the number of versions of file "outside.txt"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "2"
|
||||
|
||||
|
||||
Scenario: clean up only a project space
|
||||
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||
And using spaces DAV path
|
||||
And user "Alice" has created a space "projectSpace" with the default quota using the Graph API
|
||||
And user "Alice" has uploaded file with content "version 1" to "personal.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "personal.txt"
|
||||
And user "Alice" has uploaded file with content "version 3" to "personal.txt"
|
||||
And user "Alice" has uploaded a file inside space "projectSpace" with content "version 1" to "project.txt"
|
||||
And user "Alice" has uploaded a file inside space "projectSpace" with content "version 2" to "project.txt"
|
||||
And user "Alice" has uploaded a file inside space "projectSpace" with content "version 3" to "project.txt"
|
||||
And we save it into "PROJECT_FILEID"
|
||||
When the administrator cleans up the file versions of space "projectSpace" of user "Alice" using the CLI with flags "-s 0"
|
||||
Then the command should be successful
|
||||
And the command output should contain "/project.txt: deleted 2 of 2 revisions"
|
||||
When user "Alice" gets the number of versions of file "project.txt" using file-id "<<PROJECT_FILEID>>"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "0"
|
||||
When user "Alice" gets the number of versions of file "personal.txt"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "2"
|
||||
|
||||
|
||||
Scenario: print the results as JSON
|
||||
Given user "Alice" has uploaded file with content "version 1" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 3" to "textfile.txt"
|
||||
When the administrator cleans up the file versions of all spaces using the CLI with flags "-s 0 --json"
|
||||
Then the command should be successful
|
||||
And the JSON output of the command should contain an object of type "file" with:
|
||||
| key | value |
|
||||
| path | /textfile.txt |
|
||||
| dry_run | false |
|
||||
| revisions | 2 |
|
||||
| deleted | 2 |
|
||||
| failed | 0 |
|
||||
And the JSON output of the command should contain an object of type "summary" with:
|
||||
| key | value |
|
||||
| deleted | 2 |
|
||||
| failed | 0 |
|
||||
|
||||
|
||||
Scenario: a cleanup without a strategy fails when the configured one is disabled
|
||||
Given user "Alice" has uploaded file with content "version 1" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "textfile.txt"
|
||||
When the administrator cleans up the file versions using the CLI with flags "--all"
|
||||
Then the command should exit with code "1"
|
||||
And the command output should contain "no strategy"
|
||||
When user "Alice" gets the number of versions of file "textfile.txt"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "1"
|
||||
|
||||
|
||||
Scenario: a cleanup stopped by its timeout exits with code 2
|
||||
Given user "Alice" has uploaded file with content "version 1" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "textfile.txt"
|
||||
When the administrator cleans up the file versions of all spaces using the CLI with flags "-s 0 --timeout 1ns"
|
||||
Then the command should exit with code "2"
|
||||
And the command output should contain "stopped after the timeout of 1ns"
|
||||
When user "Alice" gets the number of versions of file "textfile.txt"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "1"
|
||||
|
||||
|
||||
Scenario: a strategy without spaces after its commas
|
||||
Given user "Alice" has uploaded file with content "version 1" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 3" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 4" to "textfile.txt"
|
||||
When the administrator cleans up the file versions of all spaces using the CLI with flags "-s auto,1"
|
||||
Then the command should be successful
|
||||
And the command output should contain "/textfile.txt: deleted 2 of 3 revisions"
|
||||
When user "Alice" gets the number of versions of file "textfile.txt"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "1"
|
||||
|
||||
@skipOnOpencloud-decomposed-Storage @skipOnOpencloud-decomposeds3-Storage
|
||||
Scenario: clean up a folder given by its path on the POSIX filesystem
|
||||
Given user "Alice" has created folder "folder"
|
||||
And user "Alice" has uploaded file with content "version 1" to "folder/inFolder.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "folder/inFolder.txt"
|
||||
And user "Alice" has uploaded file with content "version 3" to "folder/inFolder.txt"
|
||||
And user "Alice" has uploaded file with content "version 1" to "outside.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "outside.txt"
|
||||
And user "Alice" has uploaded file with content "version 3" to "outside.txt"
|
||||
When the administrator cleans up the file versions of "folder" of user "Alice" by its path on the POSIX filesystem using the CLI with flags "-s 0"
|
||||
Then the command should be successful
|
||||
And the command output should contain "/folder/inFolder.txt: deleted 2 of 2 revisions"
|
||||
When user "Alice" gets the number of versions of file "folder/inFolder.txt"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "0"
|
||||
When user "Alice" gets the number of versions of file "outside.txt"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "2"
|
||||
|
||||
|
||||
Scenario: the configured strategy cleans up a file whenever it gets a new version
|
||||
Given the following configs have been set:
|
||||
| config | value |
|
||||
| STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY | 2 |
|
||||
| STORAGE_USERS_REVISIONS_CLEANUP_ASYNC | false |
|
||||
And user "Alice" has uploaded file with content "version 1" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 3" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 4" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 5" to "textfile.txt"
|
||||
Then the number of versions of file "textfile.txt" for user "Alice" should eventually be "2"
|
||||
And the content of file "textfile.txt" for user "Alice" should be "version 5"
|
||||
|
||||
|
||||
Scenario: the configured strategy cleans up in the background by default
|
||||
Given the following configs have been set:
|
||||
| config | value |
|
||||
| STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY | 2 |
|
||||
And user "Alice" has uploaded file with content "version 1" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 3" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 4" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 5" to "textfile.txt"
|
||||
Then the number of versions of file "textfile.txt" for user "Alice" should eventually be "2"
|
||||
And the content of file "textfile.txt" for user "Alice" should be "version 5"
|
||||
|
||||
|
||||
Scenario: the configured strategy cleans up a file uploaded with TUS
|
||||
Given the following configs have been set:
|
||||
| config | value |
|
||||
| STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY | 2 |
|
||||
And user "Alice" has uploaded a file with content "version 1" to "textfile.txt" via TUS inside of the space "Personal"
|
||||
And user "Alice" has uploaded a file with content "version 2" to "textfile.txt" via TUS inside of the space "Personal"
|
||||
And user "Alice" has uploaded a file with content "version 3" to "textfile.txt" via TUS inside of the space "Personal"
|
||||
And user "Alice" has uploaded a file with content "version 4" to "textfile.txt" via TUS inside of the space "Personal"
|
||||
And user "Alice" has uploaded a file with content "version 5" to "textfile.txt" via TUS inside of the space "Personal"
|
||||
Then the number of versions of file "textfile.txt" for user "Alice" should eventually be "2"
|
||||
And the content of file "textfile.txt" for user "Alice" should be "version 5"
|
||||
|
||||
# The age of a version is the time its content was written, i.e. the modification time the
|
||||
# file had before it was changed, not the time of that change: "version 1" is 60 days old
|
||||
# as soon as it becomes a version.
|
||||
Scenario Outline: the configured strategy measures the age of a version by the time its content was written
|
||||
Given the following configs have been set:
|
||||
| config | value |
|
||||
| STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY | <strategy> |
|
||||
| STORAGE_USERS_REVISIONS_CLEANUP_ASYNC | false |
|
||||
And user "Alice" has uploaded a file with content "version 1" and mtime "-60 days" to "textfile.txt"
|
||||
And user "Alice" has uploaded a file with content "version 2" and mtime "-50 days" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 3" to "textfile.txt"
|
||||
When user "Alice" gets the number of versions of file "textfile.txt"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "<versions>"
|
||||
And the content of file "textfile.txt" for user "Alice" should be "version 3"
|
||||
Examples:
|
||||
| strategy | versions |
|
||||
| 30d | 0 |
|
||||
| 1,30d | 1 |
|
||||
| 90d | 2 |
|
||||
|
||||
# A restore makes the content from before the restore a version, which the cleanup keeps
|
||||
# whatever the strategy, so that the restore can be undone. The restored version itself
|
||||
# becomes the current content and is no longer a version.
|
||||
Scenario: restoring a version keeps the content from before the restore, so that the restore can be undone
|
||||
Given user "Alice" has uploaded file with content "version 1" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 3" to "textfile.txt"
|
||||
And the following configs have been set:
|
||||
| config | value |
|
||||
| STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY | 0 |
|
||||
| STORAGE_USERS_REVISIONS_CLEANUP_ASYNC | false |
|
||||
When user "Alice" restores version index "1" of file "textfile.txt" using the WebDAV API
|
||||
Then the HTTP status code should be "204"
|
||||
And the content of file "textfile.txt" for user "Alice" should be "version 2"
|
||||
When user "Alice" gets the number of versions of file "textfile.txt"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "1"
|
||||
When user "Alice" restores version index "1" of file "textfile.txt" using the WebDAV API
|
||||
Then the HTTP status code should be "204"
|
||||
And the content of file "textfile.txt" for user "Alice" should be "version 3"
|
||||
When user "Alice" gets the number of versions of file "textfile.txt"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "1"
|
||||
@@ -0,0 +1,55 @@
|
||||
@env-config @skipOnOpencloud-decomposed-Storage @skipOnOpencloud-decomposeds3-Storage
|
||||
Feature: clean up old file versions that changes on the POSIX filesystem created
|
||||
As an administrator
|
||||
I want versions created by changes on the POSIX filesystem to be cleaned up like any other version
|
||||
So that files that are changed directly on disk don't keep all their old versions
|
||||
|
||||
# With STORAGE_USERS_POSIX_ENABLE_FS_REVISIONS, a change on disk turns the previous content into a
|
||||
# version. That needs a copy of the previous content, which posix only keeps of content it wrote
|
||||
# or picked up while the setting was on, so it is set before the files are uploaded.
|
||||
|
||||
Background:
|
||||
Given the following configs have been set:
|
||||
| config | value |
|
||||
| STORAGE_USERS_POSIX_WATCH_FS | true |
|
||||
| STORAGE_USERS_POSIX_ENABLE_FS_REVISIONS | true |
|
||||
And user "Alice" has been created with default attributes
|
||||
|
||||
# The strategy is only set after the uploads, so that the file has 3 versions when it is changed
|
||||
# on disk: only the cleanup that the change on disk triggers can bring it down to 1.
|
||||
Scenario Outline: the configured strategy cleans up a file whenever a change on disk creates a version
|
||||
Given user "Alice" has uploaded file with content "version 1" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 2" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 3" to "textfile.txt"
|
||||
And user "Alice" has uploaded file with content "version 4" to "textfile.txt"
|
||||
And the following configs have been set:
|
||||
| config | value |
|
||||
| STORAGE_USERS_REVISIONS_CLEANUP_STRATEGY | 1 |
|
||||
| STORAGE_USERS_REVISIONS_CLEANUP_ASYNC | <async> |
|
||||
When the administrator puts the content " changed on disk" into the file "textfile.txt" in the POSIX storage folder of user "Alice"
|
||||
Then the command should be successful
|
||||
And as "Alice" the final content of file "textfile.txt" should be "version 4 changed on disk"
|
||||
And the number of versions of file "textfile.txt" for user "Alice" should eventually be "1"
|
||||
And the content of version index "1" of file "textfile.txt" for user "Alice" should be "version 4"
|
||||
Examples:
|
||||
| async |
|
||||
| true |
|
||||
| false |
|
||||
|
||||
|
||||
Scenario: the cleanup command deletes versions that changes on disk created
|
||||
Given user "Alice" has uploaded file with content "version 1" to "textfile.txt"
|
||||
When the administrator puts the content ", changed on disk" into the file "textfile.txt" in the POSIX storage folder of user "Alice"
|
||||
Then the command should be successful
|
||||
And as "Alice" the final content of file "textfile.txt" should be "version 1, changed on disk"
|
||||
When the administrator puts the content ", changed again" into the file "textfile.txt" in the POSIX storage folder of user "Alice"
|
||||
Then the command should be successful
|
||||
And as "Alice" the final content of file "textfile.txt" should be "version 1, changed on disk, changed again"
|
||||
And the number of versions of file "textfile.txt" for user "Alice" should eventually be "2"
|
||||
When the administrator cleans up the file versions of all spaces using the CLI with flags "-s 0"
|
||||
Then the command should be successful
|
||||
And the command output should contain "/textfile.txt: deleted 2 of 2 revisions"
|
||||
When user "Alice" gets the number of versions of file "textfile.txt"
|
||||
Then the HTTP status code should be "207"
|
||||
And the number of versions should be "0"
|
||||
And the content of file "textfile.txt" for user "Alice" should be "version 1, changed on disk, changed again"
|
||||
Reference in new issue
Block a user