Skip to content

Commit

Permalink
Rename aggregator/test to aggregatortest
Browse files Browse the repository at this point in the history
  • Loading branch information
eundoosong committed Jul 28, 2020
1 parent 2833212 commit cde5573
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 110 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Changed

- Rename `sdk/metric/aggregator/test` to `sdk/metric/aggregator/aggregatortest`. (#980)
- Rename `kv.Infer` to `kv.Any`. (#969)
- Jaeger exporter helpers: added InstallNewPipeline and removed RegisterGlobal option instead. (#944)
- Zipkin exporter helpers: pipeline methods introduced, new exporter method adjusted. (#944)
Expand Down
16 changes: 8 additions & 8 deletions exporters/stdout/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ import (
export "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
"go.opentelemetry.io/otel/sdk/export/metric/metrictest"
"go.opentelemetry.io/otel/sdk/metric/aggregator/aggregatortest"
"go.opentelemetry.io/otel/sdk/metric/aggregator/array"
"go.opentelemetry.io/otel/sdk/metric/aggregator/ddsketch"
"go.opentelemetry.io/otel/sdk/metric/aggregator/lastvalue"
"go.opentelemetry.io/otel/sdk/metric/aggregator/minmaxsumcount"
"go.opentelemetry.io/otel/sdk/metric/aggregator/sum"
aggtest "go.opentelemetry.io/otel/sdk/metric/aggregator/test"
"go.opentelemetry.io/otel/sdk/resource"
)

Expand Down Expand Up @@ -103,7 +103,7 @@ func TestStdoutTimestamp(t *testing.T) {

lvagg, ckpt := metrictest.Unslice2(lastvalue.New(2))

aggtest.CheckedUpdate(t, lvagg, metric.NewInt64Number(321), &desc)
aggregatortest.CheckedUpdate(t, lvagg, metric.NewInt64Number(321), &desc)
require.NoError(t, lvagg.SynchronizedMove(ckpt, &desc))

checkpointSet.Add(&desc, ckpt)
Expand Down Expand Up @@ -142,7 +142,7 @@ func TestStdoutCounterFormat(t *testing.T) {

cagg, ckpt := metrictest.Unslice2(sum.New(2))

aggtest.CheckedUpdate(fix.t, cagg, metric.NewInt64Number(123), &desc)
aggregatortest.CheckedUpdate(fix.t, cagg, metric.NewInt64Number(123), &desc)
require.NoError(t, cagg.SynchronizedMove(ckpt, &desc))

checkpointSet.Add(&desc, ckpt, kv.String("A", "B"), kv.String("C", "D"))
Expand All @@ -160,7 +160,7 @@ func TestStdoutLastValueFormat(t *testing.T) {
desc := metric.NewDescriptor("test.name", metric.ValueObserverKind, metric.Float64NumberKind)
lvagg, ckpt := metrictest.Unslice2(lastvalue.New(2))

aggtest.CheckedUpdate(fix.t, lvagg, metric.NewFloat64Number(123.456), &desc)
aggregatortest.CheckedUpdate(fix.t, lvagg, metric.NewFloat64Number(123.456), &desc)
require.NoError(t, lvagg.SynchronizedMove(ckpt, &desc))

checkpointSet.Add(&desc, ckpt, kv.String("A", "B"), kv.String("C", "D"))
Expand All @@ -179,8 +179,8 @@ func TestStdoutMinMaxSumCount(t *testing.T) {

magg, ckpt := metrictest.Unslice2(minmaxsumcount.New(2, &desc))

aggtest.CheckedUpdate(fix.t, magg, metric.NewFloat64Number(123.456), &desc)
aggtest.CheckedUpdate(fix.t, magg, metric.NewFloat64Number(876.543), &desc)
aggregatortest.CheckedUpdate(fix.t, magg, metric.NewFloat64Number(123.456), &desc)
aggregatortest.CheckedUpdate(fix.t, magg, metric.NewFloat64Number(876.543), &desc)
require.NoError(t, magg.SynchronizedMove(ckpt, &desc))

checkpointSet.Add(&desc, ckpt, kv.String("A", "B"), kv.String("C", "D"))
Expand All @@ -199,7 +199,7 @@ func TestStdoutValueRecorderFormat(t *testing.T) {
aagg, ckpt := metrictest.Unslice2(array.New(2))

for i := 0; i < 1000; i++ {
aggtest.CheckedUpdate(fix.t, aagg, metric.NewFloat64Number(float64(i)+0.5), &desc)
aggregatortest.CheckedUpdate(fix.t, aagg, metric.NewFloat64Number(float64(i)+0.5), &desc)
}

require.NoError(t, aagg.SynchronizedMove(ckpt, &desc))
Expand Down Expand Up @@ -317,7 +317,7 @@ func TestStdoutResource(t *testing.T) {
desc := metric.NewDescriptor("test.name", metric.ValueObserverKind, metric.Float64NumberKind)
lvagg, ckpt := metrictest.Unslice2(lastvalue.New(2))

aggtest.CheckedUpdate(fix.t, lvagg, metric.NewFloat64Number(123.456), &desc)
aggregatortest.CheckedUpdate(fix.t, lvagg, metric.NewFloat64Number(123.456), &desc)
require.NoError(t, lvagg.SynchronizedMove(ckpt, &desc))

checkpointSet.Add(&desc, ckpt, tc.attrs...)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package test
package aggregatortest

import (
"context"
Expand Down
48 changes: 24 additions & 24 deletions sdk/metric/aggregator/array/array_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"go.opentelemetry.io/otel/api/metric"
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
"go.opentelemetry.io/otel/sdk/metric/aggregator/test"
"go.opentelemetry.io/otel/sdk/metric/aggregator/aggregatortest"
)

type updateTest struct {
Expand Down Expand Up @@ -61,20 +61,20 @@ func new4() (_, _, _, _ *Aggregator) {
return &alloc[0], &alloc[1], &alloc[2], &alloc[3]
}

func (ut *updateTest) run(t *testing.T, profile test.Profile) {
descriptor := test.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
func (ut *updateTest) run(t *testing.T, profile aggregatortest.Profile) {
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
agg, ckpt := new2()

all := test.NewNumbers(profile.NumberKind)
all := aggregatortest.NewNumbers(profile.NumberKind)

for i := 0; i < ut.count; i++ {
x := profile.Random(+1)
all.Append(x)
test.CheckedUpdate(t, agg, x, descriptor)
aggregatortest.CheckedUpdate(t, agg, x, descriptor)

y := profile.Random(-1)
all.Append(y)
test.CheckedUpdate(t, agg, y, descriptor)
aggregatortest.CheckedUpdate(t, agg, y, descriptor)
}

err := agg.SynchronizedMove(ckpt, descriptor)
Expand Down Expand Up @@ -118,7 +118,7 @@ func TestArrayUpdate(t *testing.T) {
}

// Test integer and floating point
test.RunProfiles(t, ut.run)
aggregatortest.RunProfiles(t, ut.run)
})
}
}
Expand All @@ -128,29 +128,29 @@ type mergeTest struct {
absolute bool
}

func (mt *mergeTest) run(t *testing.T, profile test.Profile) {
descriptor := test.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
func (mt *mergeTest) run(t *testing.T, profile aggregatortest.Profile) {
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
agg1, agg2, ckpt1, ckpt2 := new4()

all := test.NewNumbers(profile.NumberKind)
all := aggregatortest.NewNumbers(profile.NumberKind)

for i := 0; i < mt.count; i++ {
x1 := profile.Random(+1)
all.Append(x1)
test.CheckedUpdate(t, agg1, x1, descriptor)
aggregatortest.CheckedUpdate(t, agg1, x1, descriptor)

x2 := profile.Random(+1)
all.Append(x2)
test.CheckedUpdate(t, agg2, x2, descriptor)
aggregatortest.CheckedUpdate(t, agg2, x2, descriptor)

if !mt.absolute {
y1 := profile.Random(-1)
all.Append(y1)
test.CheckedUpdate(t, agg1, y1, descriptor)
aggregatortest.CheckedUpdate(t, agg1, y1, descriptor)

y2 := profile.Random(-1)
all.Append(y2)
test.CheckedUpdate(t, agg2, y2, descriptor)
aggregatortest.CheckedUpdate(t, agg2, y2, descriptor)
}
}

Expand All @@ -160,7 +160,7 @@ func (mt *mergeTest) run(t *testing.T, profile test.Profile) {
checkZero(t, agg1, descriptor)
checkZero(t, agg2, descriptor)

test.CheckedMerge(t, ckpt1, ckpt2, descriptor)
aggregatortest.CheckedMerge(t, ckpt1, ckpt2, descriptor)

all.Sort()

Expand Down Expand Up @@ -202,15 +202,15 @@ func TestArrayMerge(t *testing.T) {
}

// Test integer and floating point
test.RunProfiles(t, mt.run)
aggregatortest.RunProfiles(t, mt.run)
})
}
})
}
}

func TestArrayErrors(t *testing.T) {
test.RunProfiles(t, func(t *testing.T, profile test.Profile) {
aggregatortest.RunProfiles(t, func(t *testing.T, profile aggregatortest.Profile) {
agg, ckpt := new2()

_, err := ckpt.Max()
Expand All @@ -225,12 +225,12 @@ func TestArrayErrors(t *testing.T) {
require.Error(t, err)
require.Equal(t, err, aggregation.ErrNoData)

descriptor := test.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)

test.CheckedUpdate(t, agg, metric.Number(0), descriptor)
aggregatortest.CheckedUpdate(t, agg, metric.Number(0), descriptor)

if profile.NumberKind == metric.Float64NumberKind {
test.CheckedUpdate(t, agg, metric.NewFloat64Number(math.NaN()), descriptor)
aggregatortest.CheckedUpdate(t, agg, metric.NewFloat64Number(math.NaN()), descriptor)
}
require.NoError(t, agg.SynchronizedMove(ckpt, descriptor))

Expand All @@ -253,7 +253,7 @@ func TestArrayErrors(t *testing.T) {
}

func TestArrayFloat64(t *testing.T) {
descriptor := test.NewAggregatorTest(metric.ValueRecorderKind, metric.Float64NumberKind)
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, metric.Float64NumberKind)

fpsf := func(sign int) []float64 {
// Check behavior of a bunch of odd floating
Expand Down Expand Up @@ -282,18 +282,18 @@ func TestArrayFloat64(t *testing.T) {
}
}

all := test.NewNumbers(metric.Float64NumberKind)
all := aggregatortest.NewNumbers(metric.Float64NumberKind)

agg, ckpt := new2()

for _, f := range fpsf(1) {
all.Append(metric.NewFloat64Number(f))
test.CheckedUpdate(t, agg, metric.NewFloat64Number(f), descriptor)
aggregatortest.CheckedUpdate(t, agg, metric.NewFloat64Number(f), descriptor)
}

for _, f := range fpsf(-1) {
all.Append(metric.NewFloat64Number(f))
test.CheckedUpdate(t, agg, metric.NewFloat64Number(f), descriptor)
aggregatortest.CheckedUpdate(t, agg, metric.NewFloat64Number(f), descriptor)
}

require.NoError(t, agg.SynchronizedMove(ckpt, descriptor))
Expand Down
32 changes: 16 additions & 16 deletions sdk/metric/aggregator/ddsketch/ddsketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"go.opentelemetry.io/otel/api/metric"
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
"go.opentelemetry.io/otel/sdk/metric/aggregator/test"
"go.opentelemetry.io/otel/sdk/metric/aggregator/aggregatortest"
)

const count = 1000
Expand Down Expand Up @@ -65,19 +65,19 @@ func checkZero(t *testing.T, agg *Aggregator, desc *metric.Descriptor) {
require.Equal(t, kind.Zero(), min)
}

func (ut *updateTest) run(t *testing.T, profile test.Profile) {
descriptor := test.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
func (ut *updateTest) run(t *testing.T, profile aggregatortest.Profile) {
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
agg, ckpt := new2(descriptor)

all := test.NewNumbers(profile.NumberKind)
all := aggregatortest.NewNumbers(profile.NumberKind)
for i := 0; i < count; i++ {
x := profile.Random(+1)
all.Append(x)
test.CheckedUpdate(t, agg, x, descriptor)
aggregatortest.CheckedUpdate(t, agg, x, descriptor)

y := profile.Random(-1)
all.Append(y)
test.CheckedUpdate(t, agg, y, descriptor)
aggregatortest.CheckedUpdate(t, agg, y, descriptor)
}

err := agg.SynchronizedMove(ckpt, descriptor)
Expand Down Expand Up @@ -119,40 +119,40 @@ func (ut *updateTest) run(t *testing.T, profile test.Profile) {

func TestDDSketchUpdate(t *testing.T) {
ut := updateTest{}
test.RunProfiles(t, ut.run)
aggregatortest.RunProfiles(t, ut.run)
}

type mergeTest struct {
absolute bool
}

func (mt *mergeTest) run(t *testing.T, profile test.Profile) {
descriptor := test.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
func (mt *mergeTest) run(t *testing.T, profile aggregatortest.Profile) {
descriptor := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)

agg1, agg2, ckpt1, ckpt2 := new4(descriptor)

all := test.NewNumbers(profile.NumberKind)
all := aggregatortest.NewNumbers(profile.NumberKind)
for i := 0; i < count; i++ {
x := profile.Random(+1)
all.Append(x)
test.CheckedUpdate(t, agg1, x, descriptor)
aggregatortest.CheckedUpdate(t, agg1, x, descriptor)

if !mt.absolute {
y := profile.Random(-1)
all.Append(y)
test.CheckedUpdate(t, agg1, y, descriptor)
aggregatortest.CheckedUpdate(t, agg1, y, descriptor)
}
}

for i := 0; i < count; i++ {
x := profile.Random(+1)
all.Append(x)
test.CheckedUpdate(t, agg2, x, descriptor)
aggregatortest.CheckedUpdate(t, agg2, x, descriptor)

if !mt.absolute {
y := profile.Random(-1)
all.Append(y)
test.CheckedUpdate(t, agg2, y, descriptor)
aggregatortest.CheckedUpdate(t, agg2, y, descriptor)
}
}

Expand All @@ -162,7 +162,7 @@ func (mt *mergeTest) run(t *testing.T, profile test.Profile) {
checkZero(t, agg1, descriptor)
checkZero(t, agg1, descriptor)

test.CheckedMerge(t, ckpt1, ckpt2, descriptor)
aggregatortest.CheckedMerge(t, ckpt1, ckpt2, descriptor)

all.Sort()

Expand Down Expand Up @@ -204,7 +204,7 @@ func TestDDSketchMerge(t *testing.T) {
absolute: absolute,
}
// Test integer and floating point
test.RunProfiles(t, mt.run)
aggregatortest.RunProfiles(t, mt.run)
})
}
}
6 changes: 3 additions & 3 deletions sdk/metric/aggregator/histogram/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"testing"

"go.opentelemetry.io/otel/api/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregator/aggregatortest"
"go.opentelemetry.io/otel/sdk/metric/aggregator/histogram"
"go.opentelemetry.io/otel/sdk/metric/aggregator/test"
)

const inputRange = 1e6
Expand All @@ -37,7 +37,7 @@ func benchmarkHistogramSearchFloat64(b *testing.B, size int) {
for i := range values {
values[i] = rand.Float64() * inputRange
}
desc := test.NewAggregatorTest(metric.ValueRecorderKind, metric.Float64NumberKind)
desc := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, metric.Float64NumberKind)
agg := &histogram.New(1, desc, boundaries)[0]
ctx := context.Background()

Expand Down Expand Up @@ -88,7 +88,7 @@ func benchmarkHistogramSearchInt64(b *testing.B, size int) {
for i := range values {
values[i] = int64(rand.Float64() * inputRange)
}
desc := test.NewAggregatorTest(metric.ValueRecorderKind, metric.Int64NumberKind)
desc := aggregatortest.NewAggregatorTest(metric.ValueRecorderKind, metric.Int64NumberKind)
agg := &histogram.New(1, desc, boundaries)[0]
ctx := context.Background()

Expand Down
Loading

0 comments on commit cde5573

Please sign in to comment.