@@ -11,7 +11,6 @@ import (
1111 "github.com/stretchr/testify/require"
1212
1313 ingestv1 "github.com/grafana/pyroscope/api/gen/proto/go/ingester/v1"
14- typesv1 "github.com/grafana/pyroscope/api/gen/proto/go/types/v1"
1514 "github.com/grafana/pyroscope/pkg/iter"
1615 phlaremodel "github.com/grafana/pyroscope/pkg/model"
1716 schemav1 "github.com/grafana/pyroscope/pkg/phlaredb/schemas/v1"
@@ -39,34 +38,36 @@ func TestFilterProfiles(t *testing.T) {
3938 require .NoError (t , err )
4039 require .Equal (t , 2 , len (filtered [0 ]))
4140 require .Equal (t , 3 , len (bidi .profilesSent ))
42- testhelper .EqualProto (t , []* ingestv1.ProfileSets {
41+
42+ expectedSent := []* ingestv1.ProfileSets {
4343 {
44- LabelsSets : lo .Times (5 , func (i int ) * typesv1. Labels {
45- return & typesv1. Labels { Labels : phlaremodel .LabelsFromStrings ("foo" , "bar" , "i" , fmt .Sprintf ("%d" , i ))}
44+ Fingerprints : lo .Times (5 , func (i int ) uint64 {
45+ return phlaremodel .LabelsFromStrings ("foo" , "bar" , "i" , fmt .Sprintf ("%d" , i )). Hash ()
4646 }),
4747 Profiles : lo .Times (5 , func (i int ) * ingestv1.SeriesProfile {
4848 return & ingestv1.SeriesProfile {Timestamp : int64 (model .TimeFromUnixNano (int64 (i * int (time .Minute )))), LabelIndex : int32 (i )}
4949 }),
5050 },
5151 {
52- LabelsSets : lo .Times (5 , func (i int ) * typesv1. Labels {
53- return & typesv1. Labels { Labels : phlaremodel .LabelsFromStrings ("foo" , "bar" , "i" , fmt .Sprintf ("%d" , i + 5 ))}
52+ Fingerprints : lo .Times (5 , func (i int ) uint64 {
53+ return phlaremodel .LabelsFromStrings ("foo" , "bar" , "i" , fmt .Sprintf ("%d" , i + 5 )). Hash ()
5454 }),
5555 Profiles : lo .Times (5 , func (i int ) * ingestv1.SeriesProfile {
5656 return & ingestv1.SeriesProfile {Timestamp : int64 (model .TimeFromUnixNano (int64 ((i + 5 ) * int (time .Minute )))), LabelIndex : int32 (i )}
5757 }),
5858 },
5959 {
60- LabelsSets : lo .Times (1 , func (i int ) * typesv1. Labels {
61- return & typesv1. Labels { Labels : phlaremodel .LabelsFromStrings ("foo" , "bar" , "i" , fmt .Sprintf ("%d" , i + 10 ))}
60+ Fingerprints : lo .Times (1 , func (i int ) uint64 {
61+ return phlaremodel .LabelsFromStrings ("foo" , "bar" , "i" , fmt .Sprintf ("%d" , i + 10 )). Hash ()
6262 }),
6363 Profiles : lo .Times (1 , func (i int ) * ingestv1.SeriesProfile {
6464 return & ingestv1.SeriesProfile {Timestamp : int64 (model .TimeFromUnixNano (int64 ((i + 10 ) * int (time .Minute )))), LabelIndex : int32 (i )}
6565 }),
6666 },
67- }, bidi .profilesSent )
67+ }
68+ testhelper .EqualProto (t , expectedSent , bidi .profilesSent )
6869
69- require . Equal ( t , []Profile {
70+ expectedFiltered := []Profile {
7071 ProfileWithLabels {
7172 profile : & schemav1.InMemoryProfile {TimeNanos : int64 (5 * int (time .Minute ))},
7273 lbs : phlaremodel .LabelsFromStrings ("foo" , "bar" , "i" , fmt .Sprintf ("%d" , 5 )),
@@ -77,5 +78,6 @@ func TestFilterProfiles(t *testing.T) {
7778 lbs : phlaremodel .LabelsFromStrings ("foo" , "bar" , "i" , fmt .Sprintf ("%d" , 10 )),
7879 fp : model .Fingerprint (phlaremodel .LabelsFromStrings ("foo" , "bar" , "i" , fmt .Sprintf ("%d" , 10 )).Hash ()),
7980 },
80- }, filtered [0 ])
81+ }
82+ require .Equal (t , expectedFiltered , filtered [0 ])
8183}
0 commit comments