From 332e6afed889ac09575716db9bd5278b5b10ed80 Mon Sep 17 00:00:00 2001 From: Fadila Khadar Date: Fri, 18 Feb 2022 01:14:50 +0100 Subject: [PATCH] satellite/metabasetest: order RawSegments by streamID and position Change-Id: I669c0c2361c2c7989c8e946eb1fbf2f52074ce0e --- satellite/metabase/copy_object_test.go | 5 ----- satellite/metabase/metabasetest/common.go | 11 +++++++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/satellite/metabase/copy_object_test.go b/satellite/metabase/copy_object_test.go index f57e1fca3..719d99608 100644 --- a/satellite/metabase/copy_object_test.go +++ b/satellite/metabase/copy_object_test.go @@ -352,11 +352,6 @@ func TestFinishCopyObject(t *testing.T) { numberOfSegments := 10 copyStream := metabasetest.RandObjectStream() - // make sure segments are ordered as expected when checking database - if copyStream.StreamID.Less(obj.StreamID) { - obj, copyStream = copyStream, obj - } - originalObj := metabasetest.CreateTestObject{ CommitObject: &metabase.CommitObject{ ObjectStream: obj, diff --git a/satellite/metabase/metabasetest/common.go b/satellite/metabase/metabasetest/common.go index ec100b5e2..e6637ebf3 100644 --- a/satellite/metabase/metabasetest/common.go +++ b/satellite/metabase/metabasetest/common.go @@ -49,25 +49,28 @@ func (step Verify) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB func sortObjects(objects []metabase.Object) { sort.Slice(objects, func(i, j int) bool { - return bytes.Compare(objects[i].StreamID[:], objects[j].StreamID[:]) < 0 + return objects[i].StreamID.Less(objects[j].StreamID) }) } func sortRawObjects(objects []metabase.RawObject) { sort.Slice(objects, func(i, j int) bool { - return bytes.Compare(objects[i].StreamID[:], objects[j].StreamID[:]) < 0 + return objects[i].StreamID.Less(objects[j].StreamID) }) } func sortRawSegments(segments []metabase.RawSegment) { sort.Slice(segments, func(i, j int) bool { - return bytes.Compare(segments[i].StreamID[:], segments[j].StreamID[:]) < 0 + if segments[i].StreamID == segments[j].StreamID { + return segments[i].Position.Less(segments[j].Position) + } + return segments[i].StreamID.Less(segments[j].StreamID) }) } func sortRawCopies(copies []metabase.RawCopy) { sort.Slice(copies, func(i, j int) bool { - return bytes.Compare(copies[i].StreamID[:], copies[j].StreamID[:]) < 0 + return copies[i].StreamID.Less(copies[j].StreamID) }) }