From 3e1b108b84dd4fbb2c9393867a1a2f87445facda Mon Sep 17 00:00:00 2001 From: Michal Niewrzal Date: Mon, 6 Nov 2023 14:51:24 +0100 Subject: [PATCH] satellite/metainfo: return correct version with ListObjects ListObjects method will now return correct object version. Change-Id: I663c506079b21f238026bd6ffac2384eae521635 --- satellite/metainfo/endpoint_object.go | 1 + satellite/metainfo/endpoint_object_test.go | 24 ++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/satellite/metainfo/endpoint_object.go b/satellite/metainfo/endpoint_object.go index 9a858ce37..bd24c7588 100644 --- a/satellite/metainfo/endpoint_object.go +++ b/satellite/metainfo/endpoint_object.go @@ -1624,6 +1624,7 @@ func (endpoint *Endpoint) objectEntryToProtoListItem(ctx context.Context, bucket EncryptedObjectKey: []byte(entry.ObjectKey), Version: int32(entry.Version), // TODO incompatible types Status: pb.Object_Status(entry.Status), + ObjectVersion: entry.Version.Encode(), } expiresAt := time.Time{} diff --git a/satellite/metainfo/endpoint_object_test.go b/satellite/metainfo/endpoint_object_test.go index f737fee08..bd0d51c84 100644 --- a/satellite/metainfo/endpoint_object_test.go +++ b/satellite/metainfo/endpoint_object_test.go @@ -1518,19 +1518,26 @@ func TestEndpoint_Object_With_StorageNodes(t *testing.T) { // TODO(ver): add tests more detailed tests for returning object on commit, including returned version - objects, _, err := metainfoClient.ListObjects(ctx, metaclient.ListObjectsParams{ - Bucket: []byte(bucket.Name), - IncludeSystemMetadata: true, + listResponse, err := endpoint.ListObjects(ctx, &pb.ListObjectsRequest{ + Header: &pb.RequestHeader{ + ApiKey: apiKey.SerializeRaw(), + }, + Bucket: []byte(bucket.Name), + ObjectIncludes: &pb.ObjectListItemIncludes{ + ExcludeSystemMetadata: false, + Metadata: false, + }, }) + require.NoError(t, err) - require.Len(t, objects, 1) - require.Equal(t, params.EncryptedObjectKey, objects[0].EncryptedObjectKey) - // TODO find better way to compare (one ExpiresAt contains time zone informations) - require.Equal(t, params.ExpiresAt.Unix(), objects[0].ExpiresAt.Unix()) + require.Len(t, listResponse.Items, 1) + require.Equal(t, params.EncryptedObjectKey, listResponse.Items[0].EncryptedObjectKey) + require.Equal(t, params.ExpiresAt.Truncate(time.Millisecond), params.ExpiresAt.Truncate(time.Millisecond)) + require.Equal(t, coResponse.Object.ObjectVersion, listResponse.Items[0].ObjectVersion) object, err := metainfoClient.GetObject(ctx, metaclient.GetObjectParams{ Bucket: []byte(bucket.Name), - EncryptedObjectKey: objects[0].EncryptedObjectKey, + EncryptedObjectKey: listResponse.Items[0].EncryptedObjectKey, }) require.NoError(t, err) @@ -1538,6 +1545,7 @@ func TestEndpoint_Object_With_StorageNodes(t *testing.T) { allObjects, err := planet.Satellites[0].Metabase.DB.TestingAllCommittedObjects(ctx, project.ID, object.Bucket) require.NoError(t, err) require.Len(t, allObjects, 1) + require.Equal(t, listResponse.Items[0].ObjectVersion, allObjects[0].Version.Encode()) }) t.Run("get object IP", func(t *testing.T) {