mirror of
https://github.com/minio/minio.git
synced 2024-12-29 08:33:21 -05:00
44a9339c0a
- Rename MaxNoncurrentVersions tag to NewerNoncurrentVersions Note: We apply overlapping NewerNoncurrentVersions rules such that we honor the highest among applicable limits. e.g if 2 overlapping rules are configured with 2 and 3 noncurrent versions to be retained, we will retain 3. - Expire newer noncurrent versions after noncurrent days - MinIO extension: allow noncurrent days to be zero, allowing expiry of noncurrent version as soon as more than configured NewerNoncurrentVersions are present. - Allow NewerNoncurrentVersions rules on object-locked buckets - No x-amz-expiration when NewerNoncurrentVersions configured - ComputeAction should skip rules with NewerNoncurrentVersions > 0 - Add unit tests for lifecycle.ComputeAction - Support lifecycle rules with MaxNoncurrentVersions - Extend ExpectedExpiryTime to work with zero days - Fix all-time comparisons to be relative to UTC
83 lines
2.1 KiB
Go
83 lines
2.1 KiB
Go
// Copyright (c) 2015-2021 MinIO, Inc.
|
|
//
|
|
// This file is part of MinIO Object Storage stack
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
package lifecycle
|
|
|
|
import "testing"
|
|
|
|
func Test_NoncurrentVersionsExpiration_Validation(t *testing.T) {
|
|
testcases := []struct {
|
|
n NoncurrentVersionExpiration
|
|
err error
|
|
}{
|
|
{
|
|
n: NoncurrentVersionExpiration{
|
|
NoncurrentDays: 0,
|
|
NewerNoncurrentVersions: 0,
|
|
set: true,
|
|
},
|
|
err: errXMLNotWellFormed,
|
|
},
|
|
{
|
|
n: NoncurrentVersionExpiration{
|
|
NoncurrentDays: 90,
|
|
NewerNoncurrentVersions: 0,
|
|
set: true,
|
|
},
|
|
err: nil,
|
|
},
|
|
{
|
|
n: NoncurrentVersionExpiration{
|
|
NoncurrentDays: 90,
|
|
NewerNoncurrentVersions: 2,
|
|
set: true,
|
|
},
|
|
err: nil,
|
|
},
|
|
{
|
|
n: NoncurrentVersionExpiration{
|
|
NoncurrentDays: -1,
|
|
set: true,
|
|
},
|
|
err: errXMLNotWellFormed,
|
|
},
|
|
{
|
|
n: NoncurrentVersionExpiration{
|
|
NoncurrentDays: 90,
|
|
NewerNoncurrentVersions: -2,
|
|
set: true,
|
|
},
|
|
err: errXMLNotWellFormed,
|
|
},
|
|
// MinIO extension: supports zero NoncurrentDays when NewerNoncurrentVersions > 0
|
|
{
|
|
n: NoncurrentVersionExpiration{
|
|
NoncurrentDays: 0,
|
|
NewerNoncurrentVersions: 5,
|
|
set: true,
|
|
},
|
|
err: nil,
|
|
},
|
|
}
|
|
|
|
for i, tc := range testcases {
|
|
if got := tc.n.Validate(); got != tc.err {
|
|
t.Fatalf("%d: expected %v but got %v", i+1, tc.err, got)
|
|
}
|
|
}
|
|
}
|