mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-11-26 10:07:34 -05:00
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
56 lines
3.6 KiB
Gherkin
56 lines
3.6 KiB
Gherkin
@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"
|