Skip to content

Commit ab4293e

Browse files
committed
Add more test cases
For negative buckets, and for a second datapoint with fewer instead of more bucket count array items than the first.
1 parent 8e64654 commit ab4293e

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

internal/coreinternal/aggregateutil/aggregate_test.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,10 @@ func Test_GroupDataPoints(t *testing.T) {
365365
d := s.DataPoints().AppendEmpty()
366366
d.SetTimestamp(pcommon.NewTimestampFromTime(time.Time{}))
367367
d.Attributes().PutStr("attr1", "val1")
368-
d.SetCount(8)
368+
d.SetCount(9)
369369
d.SetZeroCount(2)
370370
d.Positive().BucketCounts().Append(0, 1, 2, 3)
371+
d.Negative().BucketCounts().Append(0, 1)
371372
return m
372373
},
373374
want: AggGroups{
@@ -485,10 +486,11 @@ func Test_MergeDataPoints(t *testing.T) {
485486
s := m.SetEmptyExponentialHistogram()
486487
d := s.DataPoints().AppendEmpty()
487488
d.Attributes().PutStr("attr1", "val1")
488-
d.SetCount(12)
489+
d.SetCount(16)
489490
d.SetSum(0)
490491
d.SetZeroCount(3)
491492
d.Positive().BucketCounts().Append(0, 2, 4, 3)
493+
d.Negative().BucketCounts().Append(0, 2, 2)
492494
return m
493495
},
494496
in: func() pmetric.Metric {
@@ -551,9 +553,10 @@ func testDataExpHistogram() pmetric.ExponentialHistogramDataPointSlice {
551553
data := pmetric.NewExponentialHistogramDataPointSlice()
552554
d := data.AppendEmpty()
553555
d.Attributes().PutStr("attr1", "val1")
554-
d.SetCount(4)
556+
d.SetCount(7)
555557
d.SetZeroCount(1)
556558
d.Positive().BucketCounts().Append(0, 1, 2)
559+
d.Negative().BucketCounts().Append(0, 1, 2)
557560
return data
558561
}
559562

@@ -562,18 +565,22 @@ func testDataExpHistogramDouble() pmetric.ExponentialHistogramDataPointSlice {
562565

563566
dWant := dataWant.AppendEmpty()
564567
dWant.Attributes().PutStr("attr1", "val1")
565-
dWant.SetCount(4)
568+
dWant.SetCount(7)
566569
dWant.SetZeroCount(1)
567570
dWant.Positive().BucketCounts().Append(0, 1, 2)
571+
dWant.Negative().BucketCounts().Append(0, 1, 2)
568572

569573
dWant2 := dataWant.AppendEmpty()
570574
dWant2.SetTimestamp(pcommon.NewTimestampFromTime(time.Time{}))
571575
dWant2.Attributes().PutStr("attr1", "val1")
572-
dWant2.SetCount(8)
576+
dWant2.SetCount(9)
573577
dWant2.SetZeroCount(2)
574578
// Use a larger number of buckets than above to check that we expand the
575579
// destination array as needed while merging.
576580
dWant2.Positive().BucketCounts().Append(0, 1, 2, 3)
581+
// Use a smaller number of buckets than above to check that we merge values
582+
// into the correct, existing buckets.
583+
dWant2.Negative().BucketCounts().Append(0, 1)
577584

578585
return dataWant
579586
}

0 commit comments

Comments
 (0)