Skip to content

Commit

Permalink
fix: broken unit test after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
alxbl committed May 2, 2024
1 parent 428840d commit 0b14085
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -455,18 +455,28 @@ func TestScrape(t *testing.T) {
metrics.Sort(func(a, b pmetric.Metric) bool {
return a.Name() < b.Name()
})

assert.Equal(t, len(test.mockPerfCounters)-len(expectedErrors), metrics.Len())

curMetricsNum := 0
for _, pc := range test.cfg.PerfCounters {

for counterIdx, counterCfg := range pc.Counters {
counterValues := test.mockPerfCounters[counterIdx].counterValues
scrapeErr := test.mockPerfCounters[counterIdx].scrapeErr

if scrapeErr != nil {
require.Empty(t, counterValues, "Invalid test case. Scrape error and counter values simultaneously.")
continue // no data for this counter.
}

metric := metrics.At(curMetricsNum)
assert.Equal(t, counterCfg.MetricRep.Name, metric.Name())
metricData := test.cfg.MetricMetaData[counterCfg.MetricRep.Name]
assert.Equal(t, metricData.Description, metric.Description())
assert.Equal(t, metricData.Unit, metric.Unit())
dps := metric.Gauge().DataPoints()

counterValues := test.mockPerfCounters[counterIdx].counterValues
assert.Equal(t, len(counterValues), dps.Len())
for dpIdx, val := range counterValues {
assert.Equal(t, val.Value, dps.At(dpIdx).DoubleValue())
Expand Down

0 comments on commit 0b14085

Please sign in to comment.