Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor change to doCompare #3130

Merged
merged 1 commit into from
May 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 37 additions & 7 deletions receiver/prometheusreceiver/metrics_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func verifyNumScrapeResults(t *testing.T, td *testData, mds []internaldata.Metri
}
}

func doCompare(name string, t *testing.T, want, got interface{}) {
func doCompare(name string, t *testing.T, want, got *internaldata.MetricsData) {
t.Run(name, func(t *testing.T) {
assert.EqualValues(t, want, got)
})
Expand Down Expand Up @@ -279,8 +279,18 @@ func verifyTarget1(t *testing.T, td *testData, mds []internaldata.MetricsData) {
ts1 := gotG1.Timeseries[0].Points[0].Timestamp
// set this timestamp to wantG1
wantG1.Timeseries[0].Points[0].Timestamp = ts1
doCompare("scrape1", t, wantG1, gotG1)

doCompare("scrape1", t,
&internaldata.MetricsData{
Node: td.node,
Resource: td.resource,
Metrics: []*metricspb.Metric{wantG1},
},
&internaldata.MetricsData{
Node: td.node,
Resource: td.resource,
Metrics: []*metricspb.Metric{gotG1},
},
)
// verify the 2nd metricData
m2 := mds[1]
ts2 := m2.Metrics[0].Timeseries[0].Points[0].Timestamp
Expand Down Expand Up @@ -505,8 +515,18 @@ func verifyTarget2(t *testing.T, td *testData, mds []internaldata.MetricsData) {
ts1 := gotG1.Timeseries[0].Points[0].Timestamp
// set this timestamp to wantG1
wantG1.Timeseries[0].Points[0].Timestamp = ts1
doCompare("scrape1", t, wantG1, gotG1)

doCompare("scrape1", t,
&internaldata.MetricsData{
Node: td.node,
Resource: td.resource,
Metrics: []*metricspb.Metric{wantG1},
},
&internaldata.MetricsData{
Node: td.node,
Resource: td.resource,
Metrics: []*metricspb.Metric{gotG1},
},
)
// verify the 2nd metricData
m2 := mds[1]
ts2 := m2.Metrics[0].Timeseries[0].Points[0].Timestamp
Expand Down Expand Up @@ -822,8 +842,18 @@ func verifyTarget3(t *testing.T, td *testData, mds []internaldata.MetricsData) {
ts1 := gotG1.Timeseries[0].Points[0].Timestamp
// set this timestamp to wantG1
wantG1.Timeseries[0].Points[0].Timestamp = ts1
doCompare("scrape1", t, wantG1, gotG1)

doCompare("scrape1", t,
&internaldata.MetricsData{
Node: td.node,
Resource: td.resource,
Metrics: []*metricspb.Metric{wantG1},
},
&internaldata.MetricsData{
Node: td.node,
Resource: td.resource,
Metrics: []*metricspb.Metric{gotG1},
},
)
// verify the 2nd metricData
m2 := mds[1]
ts2 := m2.Metrics[0].Timeseries[0].Points[0].Timestamp
Expand Down