mirror of
https://github.com/owncloud/ocis.git
synced 2026-10-23 23:29:02 +03:00
Bump reva to pick up the fix for upload sessions whose node metadata can no
longer be read. Such sessions can never finish postprocessing, stay in
processing state indefinitely and keep consuming the quota of their space.
Cleaning them previously removed the uploaded bytes without releasing the quota.
Wire up the new Orphaned session filter so operators can list the affected
sessions and remove them with --clean:
ocis storage-users uploads sessions --orphaned
ocis storage-users uploads sessions --orphaned --clean
Signed-off-by: Julian Koberg <julian.koberg@kiteworks.com>
106 lines
3.3 KiB
Go
106 lines
3.3 KiB
Go
package command
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/owncloud/reva/v2/pkg/storage"
|
|
"github.com/test-go/testify/require"
|
|
)
|
|
|
|
func TestBuildInfo(t *testing.T) {
|
|
testCases := []struct {
|
|
alias string
|
|
filter storage.UploadSessionFilter
|
|
expectedInfo string
|
|
}{
|
|
{
|
|
alias: "empty filter",
|
|
filter: storage.UploadSessionFilter{},
|
|
expectedInfo: "Sessions:",
|
|
},
|
|
{
|
|
alias: "processing",
|
|
filter: storage.UploadSessionFilter{Processing: boolPtr(true)},
|
|
expectedInfo: "Processing sessions:",
|
|
},
|
|
{
|
|
alias: "processing and not expired",
|
|
filter: storage.UploadSessionFilter{Processing: boolPtr(true), Expired: boolPtr(false)},
|
|
expectedInfo: "Processing, not expired sessions:",
|
|
},
|
|
{
|
|
alias: "processing and expired",
|
|
filter: storage.UploadSessionFilter{Processing: boolPtr(true), Expired: boolPtr(true)},
|
|
expectedInfo: "Processing, expired sessions:",
|
|
},
|
|
{
|
|
alias: "with id",
|
|
filter: storage.UploadSessionFilter{ID: strPtr("123")},
|
|
expectedInfo: "Session with id '123':",
|
|
},
|
|
{
|
|
alias: "processing, not expired and not virus infected",
|
|
filter: storage.UploadSessionFilter{Processing: boolPtr(true), Expired: boolPtr(false), HasVirus: boolPtr(false)},
|
|
expectedInfo: "Processing, not expired, not virusinfected sessions:",
|
|
},
|
|
{
|
|
alias: "not virusinfected",
|
|
filter: storage.UploadSessionFilter{HasVirus: boolPtr(false)},
|
|
expectedInfo: "Not virusinfected sessions:",
|
|
},
|
|
{
|
|
alias: "expired and virusinfected",
|
|
filter: storage.UploadSessionFilter{Expired: boolPtr(true), HasVirus: boolPtr(true)},
|
|
expectedInfo: "Expired, virusinfected sessions:",
|
|
},
|
|
{
|
|
alias: "expired and not virus infected",
|
|
filter: storage.UploadSessionFilter{Expired: boolPtr(true), HasVirus: boolPtr(false)},
|
|
expectedInfo: "Expired, not virusinfected sessions:",
|
|
},
|
|
{
|
|
alias: "processing, not expired, virus infected and with id (note: this makes no sense)",
|
|
filter: storage.UploadSessionFilter{Processing: boolPtr(true), Expired: boolPtr(false), HasVirus: boolPtr(true), ID: strPtr("123")},
|
|
expectedInfo: "Processing, not expired, virusinfected session with id '123':",
|
|
},
|
|
{
|
|
alias: "orphaned",
|
|
filter: storage.UploadSessionFilter{Orphaned: boolPtr(true)},
|
|
expectedInfo: "Orphaned sessions:",
|
|
},
|
|
{
|
|
alias: "not orphaned",
|
|
filter: storage.UploadSessionFilter{Orphaned: boolPtr(false)},
|
|
expectedInfo: "Not orphaned sessions:",
|
|
},
|
|
{
|
|
alias: "processing and orphaned",
|
|
filter: storage.UploadSessionFilter{Processing: boolPtr(true), Orphaned: boolPtr(true)},
|
|
expectedInfo: "Processing, orphaned sessions:",
|
|
},
|
|
{
|
|
alias: "expired, not virus infected and orphaned",
|
|
filter: storage.UploadSessionFilter{Expired: boolPtr(true), HasVirus: boolPtr(false), Orphaned: boolPtr(true)},
|
|
expectedInfo: "Expired, not virusinfected, orphaned sessions:",
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
alias := tc.alias
|
|
filter := tc.filter
|
|
expectedInfo := tc.expectedInfo
|
|
|
|
t.Run(alias, func(t *testing.T) {
|
|
require.Equal(t, expectedInfo, buildInfo(filter))
|
|
})
|
|
}
|
|
}
|
|
|
|
func boolPtr(b bool) *bool {
|
|
return &b
|
|
}
|
|
|
|
func strPtr(s string) *string {
|
|
return &s
|
|
}
|