Skip to content

Commit

Permalink
Add TestPipelinesAggregatorForEachReader
Browse files Browse the repository at this point in the history
Test each pipeline is updated with the aggregators it syncs.
  • Loading branch information
MrAlias committed Feb 14, 2023
1 parent 71a7bfb commit 367fae6
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions sdk/metric/pipeline_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ func testCreateAggregators[N int64 | float64](t *testing.T) {
}
}

func TestCreateAggregators(t *testing.T) {
t.Run("Int64", testCreateAggregators[int64])
t.Run("Float64", testCreateAggregators[float64])
}

func testInvalidInstrumentShouldPanic[N int64 | float64]() {
c := newInstrumentCache[N](nil, nil)
i := newInserter(newPipeline(nil, NewManualReader(), []View{defaultView}), c)
Expand All @@ -242,9 +247,25 @@ func TestInvalidInstrumentShouldPanic(t *testing.T) {
assert.Panics(t, testInvalidInstrumentShouldPanic[float64])
}

func TestCreateAggregators(t *testing.T) {
t.Run("Int64", testCreateAggregators[int64])
t.Run("Float64", testCreateAggregators[float64])
func TestPipelinesAggregatorForEachReader(t *testing.T) {
r0, r1 := NewManualReader(), NewManualReader()
pipes := newPipelines(resource.Empty(), []Reader{r0, r1}, nil)
require.Len(t, pipes, 2, "created pipelines")

inst := Instrument{Name: "foo", Kind: InstrumentKindCounter}
c := newInstrumentCache[int64](nil, nil)
r := newResolver(pipes, c)
aggs, err := r.Aggregators(inst)
require.NoError(t, err, "resolved Aggregators error")
require.Len(t, aggs, 2, "instrument aggregators")

for i, p := range pipes {
var aggN int
for _, is := range p.aggregations {
aggN += len(is)
}
assert.Equalf(t, 1, aggN, "pipeline %d: number of instrumentSync", i)
}
}

func TestPipelineRegistryCreateAggregators(t *testing.T) {
Expand Down

0 comments on commit 367fae6

Please sign in to comment.