(t *testing.T)
| 117 | } |
| 118 | |
| 119 | func TestHeadTailBuffer_MultiMBStaysBounded(t *testing.T) { |
| 120 | t.Parallel() |
| 121 | |
| 122 | buf := agentproc.NewHeadTailBuffer() |
| 123 | |
| 124 | // Write 5MB of data in chunks. |
| 125 | chunk := []byte(strings.Repeat("x", 4096) + "\n") |
| 126 | totalWritten := 0 |
| 127 | for totalWritten < 5*1024*1024 { |
| 128 | n, err := buf.Write(chunk) |
| 129 | require.NoError(t, err) |
| 130 | require.Equal(t, len(chunk), n) |
| 131 | totalWritten += n |
| 132 | } |
| 133 | |
| 134 | // Memory should be bounded to head+tail. |
| 135 | require.LessOrEqual(t, buf.Len(), |
| 136 | agentproc.MaxHeadBytes+agentproc.MaxTailBytes) |
| 137 | require.Equal(t, totalWritten, buf.TotalWritten()) |
| 138 | |
| 139 | out, info := buf.Output() |
| 140 | require.NotNil(t, info) |
| 141 | require.Equal(t, totalWritten, info.OriginalBytes) |
| 142 | require.Greater(t, info.OmittedBytes, 0) |
| 143 | require.NotEmpty(t, out) |
| 144 | } |
| 145 | |
| 146 | func TestHeadTailBuffer_LongLineTruncation(t *testing.T) { |
| 147 | t.Parallel() |
nothing calls this directly
no test coverage detected