satellite/metabasetest: order RawSegments by streamID and position
Change-Id: I669c0c2361c2c7989c8e946eb1fbf2f52074ce0e
This commit is contained in:
parent
2d4760fd09
commit
332e6afed8
@ -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,
|
||||
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user