Skip to content

Commit

Permalink
[chore][processor/websocket] try sending data a few times to fix flak…
Browse files Browse the repository at this point in the history
…iness (#23410)

Try sending data a few times to fix flakiness of test.

**Link to tracking Issue:**
Fixes #23381
  • Loading branch information
atoulme authored Jun 15, 2023
1 parent 9f0032e commit 65a1dea
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions processor/websocketprocessor/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ func TestSocketConnectionLogs(t *testing.T) {
log.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords().AppendEmpty().Body().SetStr("foo")
err = processor.ConsumeLogs(context.Background(), log)
require.NoError(t, err)
require.Len(t, logSink.AllLogs(), 1)
buf := make([]byte, 1024)
require.Eventuallyf(t, func() bool {
err = processor.ConsumeLogs(context.Background(), log)
require.NoError(t, err)
n, _ := wsConn.Read(buf)
return n == 132
}, 1*time.Second, 100*time.Millisecond, "received message")
Expand Down Expand Up @@ -76,11 +77,10 @@ func TestSocketConnectionMetrics(t *testing.T) {
require.NoError(t, err)
metric := pmetric.NewMetrics()
metric.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics().AppendEmpty().SetName("foo")
err = processor.ConsumeMetrics(context.Background(), metric)
require.NoError(t, err)
require.Len(t, metricsSink.AllMetrics(), 1)
buf := make([]byte, 1024)
require.Eventuallyf(t, func() bool {
err = processor.ConsumeMetrics(context.Background(), metric)
require.NoError(t, err)
n, _ := wsConn.Read(buf)
return n == 94
}, 1*time.Second, 100*time.Millisecond, "received message")
Expand Down Expand Up @@ -112,11 +112,10 @@ func TestSocketConnectionTraces(t *testing.T) {
require.NoError(t, err)
trace := ptrace.NewTraces()
trace.ResourceSpans().AppendEmpty().ScopeSpans().AppendEmpty().Spans().AppendEmpty().SetName("foo")
err = processor.ConsumeTraces(context.Background(), trace)
require.NoError(t, err)
require.Len(t, tracesSink.AllTraces(), 1)
buf := make([]byte, 1024)
require.Eventuallyf(t, func() bool {
err = processor.ConsumeTraces(context.Background(), trace)
require.NoError(t, err)
n, _ := wsConn.Read(buf)
return n == 143
}, 1*time.Second, 100*time.Millisecond, "received message")
Expand Down

0 comments on commit 65a1dea

Please sign in to comment.