Skip to content

Commit fc217ae

Browse files
committed
do full test
1 parent ab2264b commit fc217ae

File tree

2 files changed

+25
-40
lines changed

2 files changed

+25
-40
lines changed

instrumentation/google.golang.org/grpc/otelgrpc/stats_handler_test.go

-40
This file was deleted.

instrumentation/google.golang.org/grpc/otelgrpc/test/grpc_stats_handler_test.go

+25
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package test
1717
import (
1818
"context"
1919
"net"
20+
"sync"
2021
"testing"
2122

2223
"github.com/stretchr/testify/assert"
@@ -1316,3 +1317,27 @@ func checkServerMetrics(t *testing.T, reader metric.Reader) {
13161317

13171318
metricdatatest.AssertEqual(t, expectedScopeMetric, rm.ScopeMetrics[0], metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue())
13181319
}
1320+
1321+
func TestStatsHandlerConcurrentSafe(t *testing.T) {
1322+
listener, err := net.Listen("tcp", "127.0.0.1:0")
1323+
require.NoError(t, err, "failed to open port")
1324+
client := newGrpcTest(t, listener,
1325+
[]grpc.DialOption{
1326+
grpc.WithStatsHandler(otelgrpc.NewClientHandler()),
1327+
},
1328+
[]grpc.ServerOption{
1329+
grpc.StatsHandler(otelgrpc.NewServerHandler()),
1330+
},
1331+
)
1332+
1333+
wg := &sync.WaitGroup{}
1334+
const n = 100
1335+
for i := 0; i < n; i++ {
1336+
wg.Add(1)
1337+
go func() {
1338+
defer wg.Done()
1339+
doCalls(client)
1340+
}()
1341+
}
1342+
wg.Wait()
1343+
}

0 commit comments

Comments
 (0)