Skip to content

Commit

Permalink
testsuite/server: add copy object default retention test
Browse files Browse the repository at this point in the history
Updates #514

Change-Id: Iafc9e5dc6526e0a614f696250aed45a30cd30878
  • Loading branch information
halkyon committed Dec 5, 2024
1 parent 68286b0 commit cd2a3b3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
4 changes: 2 additions & 2 deletions testsuite/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ require (
github.com/stretchr/testify v1.9.0
github.com/zeebo/errs v1.4.0
go.uber.org/zap v1.27.0
storj.io/common v0.0.0-20241119131735-4ff8230c41d4
storj.io/common v0.0.0-20241122160459-7ebb6c97b77d
storj.io/edge v0.0.0-00010101000000-000000000000
storj.io/minio v0.0.0-20241126095350-0039fe402364
storj.io/storj v1.118.7
storj.io/storj v1.119.0-rc
storj.io/uplink v1.13.2-0.20241106140533-61d511a04894
)

Expand Down
8 changes: 4 additions & 4 deletions testsuite/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2764,8 +2764,8 @@ sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2
sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0=
storj.io/common v0.0.0-20211102144601-401a79f0706a/go.mod h1:a2Kw7Uipu929OFANfWKLHRoD0JfhgssikEvimd6hbSQ=
storj.io/common v0.0.0-20220719163320-cd2ef8e1b9b0/go.mod h1:mCYV6Ud5+cdbuaxdPD5Zht/HYaIn0sffnnws9ErkrMQ=
storj.io/common v0.0.0-20241119131735-4ff8230c41d4 h1:Ld9/yzRdDLgnHTVR6+ezdkPiMj0xrzIeOocFILSywb8=
storj.io/common v0.0.0-20241119131735-4ff8230c41d4/go.mod h1:CpSUpwG0nOkKMfDI/mqdogMccFP+zFvbTq6LbUCtUPQ=
storj.io/common v0.0.0-20241122160459-7ebb6c97b77d h1:mSt6sU+Av4d9NARKbLOBWLyPnetvWfwn6f7zT11xQqk=
storj.io/common v0.0.0-20241122160459-7ebb6c97b77d/go.mod h1:CpSUpwG0nOkKMfDI/mqdogMccFP+zFvbTq6LbUCtUPQ=
storj.io/dotworld v0.0.0-20210324183515-0d11aeccd840 h1:oqMwoF6vaOrCe92SKRyr8cc2WSjLYAd8fjpAHA7rNqY=
storj.io/dotworld v0.0.0-20210324183515-0d11aeccd840/go.mod h1:KU9YvEgRrMMiWLvH8pzn1UkoCoxggKIPvQxmNdx7aXQ=
storj.io/drpc v0.0.26/go.mod h1:ofQUDPQbbIymRDKE0tms48k8bLP5Y+dsI9CbXGv3gko=
Expand All @@ -2784,8 +2784,8 @@ storj.io/monkit-jaeger v0.0.0-20240221095020-52b0792fa6cd h1:XkLxAvogynNQu/1gM/F
storj.io/monkit-jaeger v0.0.0-20240221095020-52b0792fa6cd/go.mod h1:nwyyJiAFAPRu81qBfAE5cBGkVXROYSNJu9pGXLtStHE=
storj.io/picobuf v0.0.3 h1:xAUPB5ZUGfxkqd3bnw3zp01kkWb9wlhg4vtZWUs2S9A=
storj.io/picobuf v0.0.3/go.mod h1:4V4xelV1RSCck5GgmkL/Txw9l6IfX3XcBzegmL5Kudo=
storj.io/storj v1.118.7 h1:FJX+YaPksZPKsQnUpOuL8b01eWLuawhVOuBDISne9mE=
storj.io/storj v1.118.7/go.mod h1:/5N7TJPppoVFvCNMVsFI9tq/FcNjZyMwxeeY3pY6RUM=
storj.io/storj v1.119.0-rc h1:BMbEag/lO4M+se2FDsIFPD9OkEbWkxOL6QIDawuFEUo=
storj.io/storj v1.119.0-rc/go.mod h1:rxP1RQr/2TQgSlF0HvvN9N+qLHL2pxA+dpOf2UHPl1M=
storj.io/uplink v1.7.1/go.mod h1:pKqsMpNMIAz//2TXzUGOR6tpu3iyabvXV4VWINj4jaY=
storj.io/uplink v1.13.2-0.20241106140533-61d511a04894 h1:gHi9zQ8fyNRiSf65yAQzcImhNMsmpSO/BLjhpXKVd6s=
storj.io/uplink v1.13.2-0.20241106140533-61d511a04894/go.mod h1:etv+GK4sedWhq3l9xGIF2scgLyXVzlH68btfMpzZKiw=
Expand Down
38 changes: 38 additions & 0 deletions testsuite/server/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,44 @@ func TestObjectLock(t *testing.T) {
require.Equal(t, legalHoldOn, *getResp.ObjectLockLegalHoldStatus)
})

t.Run("copy object default retention", func(t *testing.T) {
srcBucket, dstBucket := testrand.BucketName(), testrand.BucketName()
require.NoError(t, createBucket(ctx, client, srcBucket, false, false))
require.NoError(t, createBucket(ctx, client, dstBucket, true, true))

defaultDays := int64(5)
defaultMode := s3.ObjectLockRetentionModeCompliance

_, err := putObjectLockConfiguration(ctx, client, dstBucket, "Enabled", &s3.ObjectLockRule{
DefaultRetention: &s3.DefaultRetention{
Days: &defaultDays,
Mode: &defaultMode,
},
})
require.NoError(t, err)

_, err = putObject(ctx, client, srcBucket, objKey1, nil)
require.NoError(t, err)

copyResp, err := copyObject(ctx, client, srcBucket, objKey1, "", dstBucket, objKey1)
require.NoError(t, err)

objInfo, err := getObject(ctx, client, dstBucket, objKey1, *copyResp.VersionId)
require.NoError(t, err)

require.Equal(t, defaultMode, *objInfo.ObjectLockMode)
require.WithinDuration(t, time.Now().AddDate(0, 0, int(defaultDays)), *objInfo.ObjectLockRetainUntilDate, time.Minute)

copyResp, err = copyObjectWithRetention(ctx, client, srcBucket, objKey1, "", dstBucket, objKey2, s3.ObjectLockModeCompliance, &retainUntil)
require.NoError(t, err)

objInfo, err = getObject(ctx, client, dstBucket, objKey2, *copyResp.VersionId)
require.NoError(t, err)

require.Equal(t, s3.ObjectLockModeCompliance, *objInfo.ObjectLockMode)
require.WithinDuration(t, retainUntil, *objInfo.ObjectLockRetainUntilDate, time.Minute)
})

runRetentionModeTest("mixed locked and unlocked versions", func(t *testing.T, mode string) {
lockedPutResp, err := putObjectWithRetention(ctx, client, bucket, objKey1, mode, retainUntil)
require.NoError(t, err)
Expand Down

0 comments on commit cd2a3b3

Please sign in to comment.