satellite/metabase: simplify BeginExactObject

There's only one value that BeginExactObject should return and there's
no point in restating that.

Also, use a clearer value for the random object version.

Change-Id: I06b26ad87d64e1b04b48458f624edd630f7f2f1d
This commit is contained in:
Egon Elbre 2023-09-15 19:30:47 +03:00 committed by Storj Robot
parent 109c0d5e37
commit c48f58e968
15 changed files with 37 additions and 122 deletions

View File

@ -111,7 +111,6 @@ func TestCommitObjectWithSegments(t *testing.T) {
},
Encryption: metabasetest.DefaultEncryption,
},
Version: 5,
}.Check(ctx, t, db)
now := time.Now()
@ -180,7 +179,6 @@ func TestCommitObjectWithSegments(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
now := time.Now()
zombieDeadline := now.Add(24 * time.Hour)
@ -219,7 +217,6 @@ func TestCommitObjectWithSegments(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
now := time.Now()
@ -328,7 +325,6 @@ func TestCommitObjectWithSegments(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
now := time.Now()
@ -424,7 +420,6 @@ func TestCommitObjectWithSegments(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
now := time.Now()
@ -548,7 +543,6 @@ func TestCommitObjectWithSegments(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
now := time.Now()
@ -672,7 +666,6 @@ func TestCommitObjectWithSegments(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
now := time.Now()
@ -796,7 +789,6 @@ func TestCommitObjectWithSegments(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
now := time.Now()

View File

@ -527,7 +527,6 @@ func TestBeginObjectExactVersion(t *testing.T) {
ObjectStream: test.ObjectStream,
Encryption: metabasetest.DefaultEncryption,
},
Version: -1,
ErrClass: test.ErrClass,
ErrText: test.ErrText,
}.Check(ctx, t, db)
@ -553,7 +552,6 @@ func TestBeginObjectExactVersion(t *testing.T) {
Encryption: metabasetest.DefaultEncryption,
EncryptedMetadata: testrand.BytesInt(32),
},
Version: metabase.DefaultVersion,
ErrClass: &metabase.ErrInvalidRequest,
ErrText: "EncryptedMetadataNonce and EncryptedMetadataEncryptedKey must be set if EncryptedMetadata is set",
}.Check(ctx, t, db)
@ -564,7 +562,6 @@ func TestBeginObjectExactVersion(t *testing.T) {
Encryption: metabasetest.DefaultEncryption,
EncryptedMetadataEncryptedKey: testrand.BytesInt(32),
},
Version: metabase.DefaultVersion,
ErrClass: &metabase.ErrInvalidRequest,
ErrText: "EncryptedMetadataNonce and EncryptedMetadataEncryptedKey must be not set if EncryptedMetadata is not set",
}.Check(ctx, t, db)
@ -582,7 +579,6 @@ func TestBeginObjectExactVersion(t *testing.T) {
ObjectStream: objectStream,
Encryption: metabasetest.DefaultEncryption,
},
Version: -1,
ErrClass: &metabase.ErrInvalidRequest,
ErrText: "Version should not be metabase.NextVersion",
}.Check(ctx, t, db)
@ -601,7 +597,6 @@ func TestBeginObjectExactVersion(t *testing.T) {
ObjectStream: objectStream,
Encryption: metabasetest.DefaultEncryption,
},
Version: 5,
}.Check(ctx, t, db)
metabasetest.Verify{
@ -637,7 +632,6 @@ func TestBeginObjectExactVersion(t *testing.T) {
ObjectStream: objectStream,
Encryption: metabasetest.DefaultEncryption,
},
Version: 5,
}.Check(ctx, t, db)
metabasetest.BeginObjectExactVersion{
@ -645,7 +639,6 @@ func TestBeginObjectExactVersion(t *testing.T) {
ObjectStream: objectStream,
Encryption: metabasetest.DefaultEncryption,
},
Version: -1,
ErrClass: &metabase.ErrObjectAlreadyExists,
}.Check(ctx, t, db)
@ -681,7 +674,6 @@ func TestBeginObjectExactVersion(t *testing.T) {
ObjectStream: objectStream,
Encryption: metabasetest.DefaultEncryption,
},
Version: 5,
}.Check(ctx, t, db)
metabasetest.CommitObject{
@ -695,7 +687,6 @@ func TestBeginObjectExactVersion(t *testing.T) {
ObjectStream: objectStream,
Encryption: metabasetest.DefaultEncryption,
},
Version: -1,
ErrClass: &metabase.ErrObjectAlreadyExists,
}.Check(ctx, t, db)
@ -725,14 +716,13 @@ func TestBeginObjectExactVersion(t *testing.T) {
now1 := time.Now()
objectStream.Version = 1
objectStream.Version = 100
metabasetest.BeginObjectExactVersion{
Opts: metabase.BeginObjectExactVersion{
ObjectStream: objectStream,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.CommitObject{
@ -741,14 +731,13 @@ func TestBeginObjectExactVersion(t *testing.T) {
},
}.Check(ctx, t, db)
objectStream.Version = 3
objectStream.Version = 300
metabasetest.BeginObjectExactVersion{
Opts: metabase.BeginObjectExactVersion{
ObjectStream: objectStream,
Encryption: metabasetest.DefaultEncryption,
},
Version: 3,
}.Check(ctx, t, db)
metabasetest.CommitObject{
@ -765,7 +754,7 @@ func TestBeginObjectExactVersion(t *testing.T) {
ProjectID: obj.ProjectID,
BucketName: obj.BucketName,
ObjectKey: obj.ObjectKey,
Version: 3,
Version: 300,
StreamID: obj.StreamID,
},
CreatedAt: now1,
@ -782,14 +771,13 @@ func TestBeginObjectExactVersion(t *testing.T) {
now1 := time.Now()
objectStream.Version = 3
objectStream.Version = 300
metabasetest.BeginObjectExactVersion{
Opts: metabase.BeginObjectExactVersion{
ObjectStream: objectStream,
Encryption: metabasetest.DefaultEncryption,
},
Version: 3,
}.Check(ctx, t, db)
metabasetest.CommitObject{
@ -798,14 +786,13 @@ func TestBeginObjectExactVersion(t *testing.T) {
},
}.Check(ctx, t, db)
objectStream.Version = 1
objectStream.Version = 100
metabasetest.BeginObjectExactVersion{
Opts: metabase.BeginObjectExactVersion{
ObjectStream: objectStream,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.CommitObject{
@ -822,7 +809,7 @@ func TestBeginObjectExactVersion(t *testing.T) {
ProjectID: obj.ProjectID,
BucketName: obj.BucketName,
ObjectKey: obj.ObjectKey,
Version: 1,
Version: 100,
StreamID: obj.StreamID,
},
CreatedAt: now1,
@ -840,7 +827,7 @@ func TestBeginObjectExactVersion(t *testing.T) {
now := time.Now()
zombieDeadline := now.Add(24 * time.Hour)
objectStream.Version = 1
objectStream.Version = 100
encryptedMetadata := testrand.BytesInt(64)
encryptedMetadataNonce := testrand.Nonce()
@ -855,18 +842,17 @@ func TestBeginObjectExactVersion(t *testing.T) {
EncryptedMetadataNonce: encryptedMetadataNonce[:],
EncryptedMetadataEncryptedKey: encryptedMetadataEncryptedKey,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.Verify{
Objects: []metabase.RawObject{
{
ObjectStream: metabase.ObjectStream{
ProjectID: obj.ProjectID,
BucketName: obj.BucketName,
ObjectKey: obj.ObjectKey,
Version: metabase.DefaultVersion,
StreamID: obj.StreamID,
ProjectID: objectStream.ProjectID,
BucketName: objectStream.BucketName,
ObjectKey: objectStream.ObjectKey,
Version: objectStream.Version,
StreamID: objectStream.StreamID,
},
CreatedAt: now,
Status: metabase.Pending,
@ -1023,7 +1009,6 @@ func TestBeginSegment(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.CommitObject{
@ -1067,7 +1052,6 @@ func TestBeginSegment(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.BeginSegment{
@ -1105,7 +1089,6 @@ func TestBeginSegment(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
for i := 0; i < 5; i++ {
@ -1319,7 +1302,6 @@ func TestCommitSegment(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.CommitSegment{
@ -1552,7 +1534,6 @@ func TestCommitSegment(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
rootPieceID := testrand.PieceID()
@ -1646,7 +1627,6 @@ func TestCommitSegment(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
rootPieceID1 := testrand.PieceID()
@ -1774,7 +1754,6 @@ func TestCommitSegment(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
metabasetest.CommitObject{
@ -1830,7 +1809,6 @@ func TestCommitSegment(t *testing.T) {
Encryption: metabasetest.DefaultEncryption,
ExpiresAt: &expectedExpiresAt,
},
Version: obj.Version,
}.Check(ctx, t, db)
metabasetest.CommitSegment{
@ -1900,7 +1878,6 @@ func TestCommitSegment(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
metabasetest.CommitSegment{
@ -2324,7 +2301,6 @@ func TestCommitInlineSegment(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.CommitInlineSegment{
@ -2424,7 +2400,6 @@ func TestCommitInlineSegment(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
encryptedKey := testrand.Bytes(32)
@ -2499,7 +2474,6 @@ func TestCommitInlineSegment(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
encryptedKey := testrand.Bytes(32)
@ -2613,7 +2587,6 @@ func TestCommitInlineSegment(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
metabasetest.CommitInlineSegment{
@ -2672,7 +2645,6 @@ func TestCommitInlineSegment(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
metabasetest.CommitInlineSegment{
@ -2734,7 +2706,6 @@ func TestCommitInlineSegment(t *testing.T) {
Encryption: metabasetest.DefaultEncryption,
ExpiresAt: &expectedExpiresAt,
},
Version: obj.Version,
}.Check(ctx, t, db)
metabasetest.CommitInlineSegment{
@ -3230,7 +3201,6 @@ func TestCommitObject(t *testing.T) {
},
Encryption: metabasetest.DefaultEncryption,
},
Version: 5,
}.Check(ctx, t, db)
now := time.Now()
@ -3300,7 +3270,6 @@ func TestCommitObject(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
now := time.Now()
@ -3413,7 +3382,6 @@ func TestCommitObject(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
now := time.Now()
@ -3520,7 +3488,6 @@ func TestCommitObject(t *testing.T) {
Opts: metabase.BeginObjectExactVersion{
ObjectStream: obj,
},
Version: 1,
}.Check(ctx, t, db)
now := time.Now()
@ -3593,7 +3560,6 @@ func TestCommitObject(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
now := time.Now()
@ -3641,7 +3607,6 @@ func TestCommitObject(t *testing.T) {
EncryptedMetadataEncryptedKey: expectedMetadataKey,
EncryptedMetadataNonce: expectedMetadataNonce,
},
Version: metabase.DefaultVersion,
}.Check(ctx, t, db)
metabasetest.CommitObject{
@ -3686,7 +3651,6 @@ func TestCommitObject(t *testing.T) {
EncryptedMetadataEncryptedKey: testrand.Bytes(32),
EncryptedMetadataNonce: testrand.Nonce().Bytes(),
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.CommitObject{
@ -3732,7 +3696,6 @@ func TestCommitObject(t *testing.T) {
EncryptedMetadataEncryptedKey: testrand.Bytes(32),
EncryptedMetadataNonce: testrand.Nonce().Bytes(),
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.CommitObject{
@ -4409,7 +4372,6 @@ func TestCommitObjectWithIncorrectPartSize(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
now := time.Now()
zombieDeadline := now.Add(24 * time.Hour)
@ -4515,7 +4477,6 @@ func TestCommitObjectWithIncorrectPartSize(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
now := time.Now()
@ -4623,7 +4584,6 @@ func TestCommitObjectWithIncorrectPartSize(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
now := time.Now()
zombieDeadline := now.Add(24 * time.Hour)
@ -4742,7 +4702,6 @@ func TestCommitObjectWithIncorrectAmountOfParts(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
now := time.Now()
zombieDeadline := now.Add(24 * time.Hour)

View File

@ -778,7 +778,7 @@ func TestFinishCopyObject(t *testing.T) {
// expected object at the location which was previously the original object
copyBackObj := originalObj
copyBackObj.Version++ // copy is placed into first available version
copyBackObj.Version = originalObj.Version + 1 // copy is placed into next version
copyBackObj.StreamID = opts.NewStreamID
for i := 0; i < 4; i++ {
@ -850,7 +850,7 @@ func TestFinishCopyObject(t *testing.T) {
}.Run(ctx, t, db)
copyBackObj := originalObj
copyBackObj.Version++ // copy is placed into first available version
copyBackObj.Version = originalObj.Version + 1 // copy is placed into next version
copyBackObj.StreamID = copyBackObjStream.StreamID
for i := 0; i < 4; i++ {
@ -888,6 +888,7 @@ func TestFinishCopyObject(t *testing.T) {
metadataNonce := testrand.Nonce()
expectedCopyObject := originalObj
expectedCopyObject.Version = 1 // it'll assign the next available version
expectedCopyObject.ObjectKey = copyStream.ObjectKey
expectedCopyObject.StreamID = copyStream.StreamID
expectedCopyObject.EncryptedMetadataEncryptedKey = testrand.Bytes(32)

View File

@ -47,7 +47,6 @@ func TestDeleteExpiredObjects(t *testing.T) {
ObjectStream: obj1,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
// pending object with expiration time in the past
@ -57,7 +56,6 @@ func TestDeleteExpiredObjects(t *testing.T) {
ExpiresAt: &pastTime,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
// pending object with expiration time in the future
@ -67,7 +65,6 @@ func TestDeleteExpiredObjects(t *testing.T) {
ExpiresAt: &futureTime,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.DeleteExpiredObjects{
@ -201,7 +198,6 @@ func TestDeleteZombieObjects(t *testing.T) {
ObjectStream: obj1,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
// zombie object with deadline time in the past
@ -211,7 +207,6 @@ func TestDeleteZombieObjects(t *testing.T) {
ZombieDeletionDeadline: &pastTime,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
// pending object with expiration time in the future
@ -221,7 +216,6 @@ func TestDeleteZombieObjects(t *testing.T) {
ZombieDeletionDeadline: &futureTime,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.DeleteZombieObjects{
@ -262,7 +256,6 @@ func TestDeleteZombieObjects(t *testing.T) {
Encryption: metabasetest.DefaultEncryption,
ZombieDeletionDeadline: &now,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.BeginSegment{
Opts: metabase.BeginSegment{
@ -351,7 +344,6 @@ func TestDeleteZombieObjects(t *testing.T) {
Encryption: metabasetest.DefaultEncryption,
// use default 24h zombie deletion deadline
},
Version: obj.Version,
}.Check(ctx, t, db)
for i := byte(0); i < 3; i++ {

View File

@ -67,7 +67,6 @@ func TestDeletePendingObject(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.DeletePendingObject{
@ -131,7 +130,6 @@ func TestDeletePendingObject(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.DeletePendingObject{
@ -171,7 +169,6 @@ func TestDeletePendingObject(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
object := metabase.RawObject{
@ -224,7 +221,6 @@ func TestDeletePendingObject(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
metabasetest.CommitInlineSegment{
@ -305,7 +301,6 @@ func TestDeletePendingObjectNew(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.DeletePendingObjectNew{
@ -369,7 +364,6 @@ func TestDeletePendingObjectNew(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.DeletePendingObjectNew{
@ -613,13 +607,12 @@ func TestDeleteObjectExactVersion(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.DeleteObjectExactVersion{
Opts: metabase.DeleteObjectExactVersion{
ObjectLocation: location,
Version: 1,
Version: obj.Version,
},
Result: metabase.DeleteObjectResult{
Objects: []metabase.Object{{
@ -653,7 +646,7 @@ func TestDeleteObjectExactVersion(t *testing.T) {
metabasetest.DeleteObjectExactVersion{
Opts: metabase.DeleteObjectExactVersion{
ObjectLocation: location,
Version: 1,
Version: obj.Version,
},
Result: metabase.DeleteObjectResult{
Objects: []metabase.Object{object},
@ -671,7 +664,7 @@ func TestDeleteObjectExactVersion(t *testing.T) {
metabasetest.DeleteObjectExactVersion{
Opts: metabase.DeleteObjectExactVersion{
ObjectLocation: location,
Version: 1,
Version: obj.Version,
},
Result: metabase.DeleteObjectResult{
Objects: []metabase.Object{object},
@ -689,7 +682,6 @@ func TestDeleteObjectExactVersion(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
metabasetest.CommitInlineSegment{
@ -716,7 +708,7 @@ func TestDeleteObjectExactVersion(t *testing.T) {
metabasetest.DeleteObjectExactVersion{
Opts: metabase.DeleteObjectExactVersion{
ObjectLocation: location,
Version: 1,
Version: obj.Version,
},
Result: metabase.DeleteObjectResult{
Objects: []metabase.Object{object},
@ -811,7 +803,6 @@ func TestDeleteObjectsAllVersions(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.DeleteObjectsAllVersions{
@ -898,7 +889,6 @@ func TestDeleteObjectsAllVersions(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
metabasetest.CommitInlineSegment{
@ -942,7 +932,6 @@ func TestDeleteObjectsAllVersions(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
metabasetest.CommitInlineSegment{
@ -1293,7 +1282,6 @@ func TestDeleteObjectLastCommitted(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
metabasetest.CommitInlineSegment{
@ -1343,11 +1331,10 @@ func TestDeleteObjectLastCommitted(t *testing.T) {
},
ZombieDeletionDeadline: &now,
},
Version: newObj.Version,
}.Check(ctx, t, db)
newObjDiffVersion := newObj
newObjDiffVersion.Version = 4
newObjDiffVersion.Version = newObj.Version * 2
committedObject, _ := metabasetest.CreateTestObject{}.Run(ctx, t, db, newObjDiffVersion, 0)

View File

@ -107,7 +107,6 @@ func TestGetObjectExactVersion(t *testing.T) {
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.GetObjectExactVersion{
@ -163,7 +162,7 @@ func TestGetObjectExactVersion(t *testing.T) {
metabasetest.GetObjectExactVersion{
Opts: metabase.GetObjectExactVersion{
ObjectLocation: location,
Version: 1,
Version: obj.Version,
},
Result: metabase.Object{
ObjectStream: obj,
@ -228,7 +227,6 @@ func TestGetObjectLastCommitted(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.GetObjectLastCommitted{
@ -340,6 +338,7 @@ func TestGetObjectLastCommitted(t *testing.T) {
t.Run("Get latest copied object version with duplicate metadata", func(t *testing.T) {
defer metabasetest.DeleteAll{}.Check(ctx, t, db)
copyObjStream := metabasetest.RandObjectStream()
copyObjStream.Version = 1 // auto assigned the first available version
originalObject := metabasetest.CreateObject(ctx, t, db, obj, 0)
copiedObj, _, _ := metabasetest.CreateObjectCopy{
@ -349,7 +348,7 @@ func TestGetObjectLastCommitted(t *testing.T) {
metabasetest.DeleteObjectExactVersion{
Opts: metabase.DeleteObjectExactVersion{
Version: 1,
Version: obj.Version,
ObjectLocation: obj.Location(),
},
Result: metabase.DeleteObjectResult{
@ -510,6 +509,7 @@ func TestGetSegmentByPosition(t *testing.T) {
objStream := metabasetest.RandObjectStream()
copyObjStream := metabasetest.RandObjectStream()
copyObjStream.ProjectID = objStream.ProjectID
copyObjStream.Version = 1 // auto assigned the first available version
obj := metabasetest.CreateObject(ctx, t, db, objStream, 1)
@ -645,13 +645,13 @@ func TestGetSegmentByPosition(t *testing.T) {
objStream := metabasetest.RandObjectStream()
copyObjStream := metabasetest.RandObjectStream()
copyObjStream.ProjectID = objStream.ProjectID
copyObjStream.Version = 1 // auto assigned the first available version
metabasetest.BeginObjectExactVersion{
Opts: metabase.BeginObjectExactVersion{
ObjectStream: objStream,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
metabasetest.CommitInlineSegment{
@ -809,13 +809,13 @@ func TestGetSegmentByPosition(t *testing.T) {
copyObjStream := metabasetest.RandObjectStream()
data := testrand.Bytes(1024)
copyObjStream.ProjectID = objStream.ProjectID
copyObjStream.Version = 1 // auto assigned the first available version
metabasetest.BeginObjectExactVersion{
Opts: metabase.BeginObjectExactVersion{
ObjectStream: objStream,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
metabasetest.CommitInlineSegment{
@ -1172,6 +1172,7 @@ func TestGetLatestObjectLastSegment(t *testing.T) {
objStream := metabasetest.RandObjectStream()
copyObjStream := metabasetest.RandObjectStream()
copyObjStream.ProjectID = objStream.ProjectID
copyObjStream.Version = 1 // auto assigned the first available version
objLocation := objStream.Location()
copyLocation := copyObjStream.Location()
@ -1180,7 +1181,6 @@ func TestGetLatestObjectLastSegment(t *testing.T) {
ObjectStream: objStream,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
metabasetest.CommitInlineSegment{
@ -1333,6 +1333,7 @@ func TestGetLatestObjectLastSegment(t *testing.T) {
copyObjStream := metabasetest.RandObjectStream()
data := testrand.Bytes(1024)
copyObjStream.ProjectID = objStream.ProjectID
copyObjStream.Version = 1 // auto assigned the first available version
objLocation := objStream.Location()
copyLocation := copyObjStream.Location()
@ -1341,7 +1342,6 @@ func TestGetLatestObjectLastSegment(t *testing.T) {
ObjectStream: objStream,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
metabasetest.CommitInlineSegment{
@ -1554,7 +1554,6 @@ func TestBucketEmpty(t *testing.T) {
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.BucketEmpty{

View File

@ -108,7 +108,6 @@ func TestIterateObjectsWithStatus(t *testing.T) {
ObjectStream: pending,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
encryptedMetadata := testrand.Bytes(1024)
@ -120,7 +119,6 @@ func TestIterateObjectsWithStatus(t *testing.T) {
ObjectStream: committed,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.CommitObject{
Opts: metabase.CommitObject{
@ -328,7 +326,7 @@ func TestIterateObjectsWithStatus(t *testing.T) {
IncludeCustomMetadata: true,
IncludeSystemMetadata: true,
Cursor: metabase.IterateCursor{Key: "a", Version: 10},
Cursor: metabase.IterateCursor{Key: "a", Version: objects["a"].Version + 1},
},
Result: []metabase.ObjectEntry{
objects["b/1"],
@ -477,7 +475,7 @@ func TestIterateObjectsWithStatus(t *testing.T) {
IncludeCustomMetadata: true,
IncludeSystemMetadata: true,
Cursor: metabase.IterateCursor{Key: "a", Version: 10},
Cursor: metabase.IterateCursor{Key: "a", Version: objects["a"].Version + 1},
},
Result: []metabase.ObjectEntry{
prefixEntry("b/", metabase.Committed),
@ -1164,7 +1162,7 @@ func TestIterateObjectsSkipCursor(t *testing.T) {
Prefix: metabase.ObjectKey("2017/05/"),
Cursor: metabase.IterateCursor{
Key: metabase.ObjectKey("2017/05/08"),
Version: 1,
Version: objects["2017/05/08"].Version,
},
Status: metabase.Committed,
IncludeCustomMetadata: true,

View File

@ -263,7 +263,7 @@ func TestListObjects(t *testing.T) {
IncludeCustomMetadata: true,
IncludeSystemMetadata: true,
Cursor: metabase.ListObjectsCursor{Key: "a", Version: 10},
Cursor: metabase.ListObjectsCursor{Key: "a", Version: objects["a"].Version + 1},
},
Result: metabase.ListObjectsResult{
Objects: []metabase.ObjectEntry{
@ -418,7 +418,7 @@ func TestListObjects(t *testing.T) {
IncludeCustomMetadata: true,
IncludeSystemMetadata: true,
Cursor: metabase.ListObjectsCursor{Key: "a", Version: 10},
Cursor: metabase.ListObjectsCursor{Key: "a", Version: objects["a"].Version + 1},
},
Result: metabase.ListObjectsResult{
Objects: []metabase.ObjectEntry{
@ -736,7 +736,7 @@ func TestListObjectsSkipCursor(t *testing.T) {
Prefix: metabase.ObjectKey("2017/05/"),
Cursor: metabase.ListObjectsCursor{
Key: metabase.ObjectKey("2017/05/08"),
Version: 1,
Version: objects["2017/05/08"].Version,
},
Status: metabase.Committed,
IncludeCustomMetadata: true,

View File

@ -207,7 +207,6 @@ func TestListSegments(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
for i, segmentPosition := range tc.segments {
@ -538,7 +537,6 @@ func TestListStreamPositions(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
for i, segmentPosition := range tc.segments {
@ -633,7 +631,6 @@ func TestListStreamPositions(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
for i := 0; i < segmentCount; i++ {

View File

@ -74,7 +74,6 @@ func TestIterateLoopObjects(t *testing.T) {
ObjectStream: pending,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
encryptedMetadata := testrand.Bytes(1024)
@ -86,7 +85,6 @@ func TestIterateLoopObjects(t *testing.T) {
ObjectStream: committed,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.CommitObject{
@ -861,7 +859,6 @@ func TestCollectBucketTallies(t *testing.T) {
EncryptedMetadataNonce: encryptedMetadataNonce[:],
EncryptedMetadataEncryptedKey: encryptedMetadataKey,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.CreateObject(ctx, t, db, committed, 1)

View File

@ -22,7 +22,7 @@ func RandObjectStream() metabase.ObjectStream {
ProjectID: testrand.UUID(),
BucketName: testrand.BucketName(),
ObjectKey: RandObjectKey(),
Version: 1,
Version: 12345,
StreamID: testrand.UUID(),
}
}
@ -48,7 +48,6 @@ func CreatePendingObject(ctx *testcontext.Context, t *testing.T, db *metabase.DB
ObjectStream: obj,
Encryption: DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
for i := byte(0); i < numberOfSegments; i++ {
@ -139,7 +138,6 @@ func CreateObject(ctx *testcontext.Context, t require.TestingT, db *metabase.DB,
ObjectStream: obj,
Encryption: DefaultEncryption,
},
Version: obj.Version,
}.Check(ctx, t, db)
for i := byte(0); i < numberOfSegments; i++ {
@ -189,7 +187,6 @@ func CreateExpiredObject(ctx *testcontext.Context, t *testing.T, db *metabase.DB
Encryption: DefaultEncryption,
ExpiresAt: &expiresAt,
},
Version: obj.Version,
}.Check(ctx, t, db)
for i := byte(0); i < numberOfSegments; i++ {

View File

@ -59,7 +59,6 @@ func (step BeginObjectNextVersion) Check(ctx *testcontext.Context, t testing.TB,
// BeginObjectExactVersion is for testing metabase.BeginObjectExactVersion.
type BeginObjectExactVersion struct {
Opts metabase.BeginObjectExactVersion
Version metabase.Version
ErrClass *errs.Class
ErrText string
}
@ -69,7 +68,7 @@ func (step BeginObjectExactVersion) Check(ctx *testcontext.Context, t require.Te
got, err := db.BeginObjectExactVersion(ctx, step.Opts)
checkError(t, err, step.ErrClass, step.ErrText)
if step.ErrClass == nil {
require.Equal(t, step.Version, got.Version)
require.Equal(t, step.Opts.Version, got.Version)
require.WithinDuration(t, time.Now(), got.CreatedAt, 5*time.Second)
require.Equal(t, step.Opts.ObjectStream, got.ObjectStream)
require.Equal(t, step.Opts.ExpiresAt, got.ExpiresAt)

View File

@ -123,7 +123,7 @@ func TestUpdateObjectMetadata(t *testing.T) {
metabasetest.CreatePendingObject(ctx, t, db, newObj, 0)
newObjDiffVersion := newObj
newObjDiffVersion.Version = 4
newObjDiffVersion.Version = newObj.Version + 10000
metabasetest.CreateTestObject{}.Run(ctx, t, db, newObjDiffVersion, 0)
encryptedMetadata := testrand.Bytes(1024)

View File

@ -138,7 +138,6 @@ func createSegment(ctx *testcontext.Context, t testing.TB, db *metabase.DB, stre
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
metabasetest.CommitInlineSegment{

View File

@ -50,7 +50,6 @@ func TestGetStreamPieceCountByNodeID(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
encryptedKey := testrand.Bytes(32)
@ -86,7 +85,6 @@ func TestGetStreamPieceCountByNodeID(t *testing.T) {
ObjectStream: obj,
Encryption: metabasetest.DefaultEncryption,
},
Version: 1,
}.Check(ctx, t, db)
encryptedKey := testrand.Bytes(32)