diff --git a/libbeat/reader/multiline/message_buffer_test.go b/libbeat/reader/multiline/message_buffer_test.go index 2f3d883e8414..fff9c61b6d81 100644 --- a/libbeat/reader/multiline/message_buffer_test.go +++ b/libbeat/reader/multiline/message_buffer_test.go @@ -21,11 +21,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "go.uber.org/zap/zaptest/observer" "github.com/elastic/beats/v7/libbeat/reader" - "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/mapstr" ) @@ -138,74 +135,6 @@ func TestFinalizeMessage(t *testing.T) { } -func TestLogTruncatedMessage(t *testing.T) { - tests := []struct { - name string - msgFunc func() - assertFunc func(t *testing.T, logs []observer.LoggedEntry) - }{ - { - name: "truncated", - msgFunc: func() { - msgs := []reader.Message{ - {Content: []byte("line1\nline2\nline3"), Bytes: 15}, - } - - getTestMessageBuffer(10, false, msgs).finalize() - }, - assertFunc: func(t *testing.T, logs []observer.LoggedEntry) { - require.Len(t, logs, 1) - assert.Contains(t, logs[0].Message, "The multiline message is too large and has been truncated to the limit of 5 lines or 10 bytes.") - assert.Equal(t, "warn", logs[0].Level.String()) - }, - }, - { - name: "not truncated", - msgFunc: func() { - msgs := []reader.Message{ - {Content: []byte("line1\nline2"), Bytes: 15}, - } - - getTestMessageBuffer(15, false, msgs).finalize() - }, - assertFunc: func(t *testing.T, logs []observer.LoggedEntry) { - require.Empty(t, logs) - }, - }, - { - name: "log messages are rate limited", - msgFunc: func() { - msgs := []reader.Message{ - {Content: []byte("line1\nline2\nline3"), Bytes: 10}, - } - for i := 0; i < 2000; i++ { - getTestMessageBuffer(10, false, msgs).finalize() - } - }, - assertFunc: func(t *testing.T, logs []observer.LoggedEntry) { - // Log happens once every 1000 messages. - require.Len(t, logs, 2) - for _, l := range logs { - assert.Contains(t, l.Message, "The multiline message is too large and has been truncated to the limit of 5 lines or 10 bytes.") - assert.Equal(t, "reader_multiline", l.LoggerName) - assert.Equal(t, "warn", l.Level.String()) - } - }, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - logp.DevelopmentSetup(logp.ToObserverOutput()) - - tt.msgFunc() - - logs := logp.ObserverLogs().TakeAll() - tt.assertFunc(t, logs) - }) - } -} - func getTestMessageBuffer(maxBytes int, skipNewline bool, messages []reader.Message) *messageBuffer { buf := newMessageBuffer(maxBytes, 5, []byte("\n"), skipNewline) buf.clear()