1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-12 10:04:29 +02:00

Fix data race in periodic reader tests (#4731)

This commit is contained in:
David Ashpole 2023-11-28 05:12:11 -05:00 committed by GitHub
parent 47ba653e69
commit 204be6157f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -202,8 +202,6 @@ type periodicReaderTestSuite struct {
} }
func (ts *periodicReaderTestSuite) SetupTest() { func (ts *periodicReaderTestSuite) SetupTest() {
ts.Reader = ts.Factory()
e := &fnExporter{ e := &fnExporter{
exportFunc: func(context.Context, *metricdata.ResourceMetrics) error { return assert.AnError }, exportFunc: func(context.Context, *metricdata.ResourceMetrics) error { return assert.AnError },
flushFunc: func(context.Context) error { return assert.AnError }, flushFunc: func(context.Context) error { return assert.AnError },
@ -429,12 +427,13 @@ func TestPeriodicReaderMultipleForceFlush(t *testing.T) {
r.register(testSDKProducer{}) r.register(testSDKProducer{})
require.NoError(t, r.ForceFlush(ctx)) require.NoError(t, r.ForceFlush(ctx))
require.NoError(t, r.ForceFlush(ctx)) require.NoError(t, r.ForceFlush(ctx))
require.NoError(t, r.Shutdown(ctx))
} }
func BenchmarkPeriodicReader(b *testing.B) { func BenchmarkPeriodicReader(b *testing.B) {
b.Run("Collect", benchReaderCollectFunc( r := NewPeriodicReader(new(fnExporter))
NewPeriodicReader(new(fnExporter)), b.Run("Collect", benchReaderCollectFunc(r))
)) require.NoError(b, r.Shutdown(context.Background()))
} }
func TestPeriodiclReaderTemporality(t *testing.T) { func TestPeriodiclReaderTemporality(t *testing.T) {