Skip to content

Commit

Permalink
pkg/query: Sort list in aggregateTopByFunction
Browse files Browse the repository at this point in the history
This sorts the list by the meta location address, so the flaky
TestAggregateTopByFunction passes every time. (#770)
  • Loading branch information
importhuman committed Apr 3, 2022
1 parent e0c7d0c commit 272ece5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/query/top.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package query
import (
"context"
"fmt"
"sort"

metastorev1alpha1 "github.com/parca-dev/parca/gen/proto/go/parca/metastore/v1alpha1"
pb "github.com/parca-dev/parca/gen/proto/go/parca/query/v1alpha1"
Expand Down Expand Up @@ -176,6 +177,11 @@ func aggregateTopByFunction(top *pb.Top) *pb.Top {
}
}

// Sort the list by meta location address, ascending
sort.Slice(list, func(i, j int) bool {
return list[i].Meta.Location.Address < list[j].Meta.Location.Address
})

return &pb.Top{
List: list,
Reported: int32(len(list)),
Expand Down

0 comments on commit 272ece5

Please sign in to comment.