@@ -47,18 +47,16 @@ var logEntries = []loki.Entry{
4747
4848func TestClient_Handle (t * testing.T ) {
4949 tests := map [string ]struct {
50- clientBatchSize int
51- clientBatchWait time.Duration
52- clientMaxRetries int
53- clientMaxLineSize int
54- clientMaxLineSizeTruncate bool
55- clientTenantID string
56- clientDropRateLimited bool
57- serverResponseStatus int
58- inputEntries []loki.Entry
59- inputDelay time.Duration
60- expectedReqs []utils.RemoteWriteRequest
61- expectedMetrics string
50+ clientBatchSize int
51+ clientBatchWait time.Duration
52+ clientMaxRetries int
53+ clientTenantID string
54+ clientDropRateLimited bool
55+ serverResponseStatus int
56+ inputEntries []loki.Entry
57+ inputDelay time.Duration
58+ expectedReqs []utils.RemoteWriteRequest
59+ expectedMetrics string
6260 }{
6361 "batch log entries together until the batch size is reached" : {
6462 clientBatchSize : 10 ,
@@ -100,90 +98,6 @@ func TestClient_Handle(t *testing.T) {
10098 loki_write_mutated_bytes_total{host="__HOST__",reason="stream_limited",tenant=""} 0
10199 ` ,
102100 },
103- "dropping log entries that have max_line_size exceeded" : {
104- clientBatchSize : 10 ,
105- clientBatchWait : 100 * time .Millisecond ,
106- clientMaxRetries : 3 ,
107- clientMaxLineSize : 10 , // any log line more than this length should be discarded
108- clientMaxLineSizeTruncate : false ,
109- serverResponseStatus : 200 ,
110- inputEntries : []loki.Entry {logEntries [0 ], logEntries [1 ], logEntries [6 ]}, // this logEntries[6] entries has line more than size 10
111- expectedReqs : []utils.RemoteWriteRequest {
112- {
113- TenantID : "" ,
114- Request : logproto.PushRequest {Streams : []logproto.Stream {{Labels : "{}" , Entries : []logproto.Entry {logEntries [0 ].Entry , logEntries [1 ].Entry }}}},
115- },
116- },
117- expectedMetrics : `
118- # HELP loki_write_sent_entries_total Number of log entries sent to the ingester.
119- # TYPE loki_write_sent_entries_total counter
120- loki_write_sent_entries_total{host="__HOST__",tenant=""} 2.0
121- # HELP loki_write_dropped_entries_total Number of log entries dropped because failed to be sent to the ingester after all retries.
122- # TYPE loki_write_dropped_entries_total counter
123- loki_write_dropped_entries_total{host="__HOST__",reason="ingester_error",tenant=""} 0
124- loki_write_dropped_entries_total{host="__HOST__",reason="line_too_long",tenant=""} 1
125- loki_write_dropped_entries_total{host="__HOST__",reason="rate_limited",tenant=""} 0
126- loki_write_dropped_entries_total{host="__HOST__",reason="stream_limited",tenant=""} 0
127- # HELP loki_write_mutated_entries_total The total number of log entries that have been mutated.
128- # TYPE loki_write_mutated_entries_total counter
129- loki_write_mutated_entries_total{host="__HOST__",reason="ingester_error",tenant=""} 0
130- loki_write_mutated_entries_total{host="__HOST__",reason="line_too_long",tenant=""} 0
131- loki_write_mutated_entries_total{host="__HOST__",reason="rate_limited",tenant=""} 0
132- loki_write_mutated_entries_total{host="__HOST__",reason="stream_limited",tenant=""} 0
133- # HELP loki_write_mutated_bytes_total The total number of bytes that have been mutated.
134- # TYPE loki_write_mutated_bytes_total counter
135- loki_write_mutated_bytes_total{host="__HOST__",reason="ingester_error",tenant=""} 0
136- loki_write_mutated_bytes_total{host="__HOST__",reason="line_too_long",tenant=""} 0
137- loki_write_mutated_bytes_total{host="__HOST__",reason="rate_limited",tenant=""} 0
138- loki_write_mutated_bytes_total{host="__HOST__",reason="stream_limited",tenant=""} 0
139- ` ,
140- },
141- "truncating log entries that have max_line_size exceeded" : {
142- clientBatchSize : 10 ,
143- clientBatchWait : 100 * time .Millisecond ,
144- clientMaxRetries : 3 ,
145- clientMaxLineSize : 10 ,
146- clientMaxLineSizeTruncate : true ,
147- serverResponseStatus : 200 ,
148- inputEntries : []loki.Entry {logEntries [0 ], logEntries [1 ], logEntries [6 ]}, // logEntries[6]'s line is greater than 10 bytes
149- expectedReqs : []utils.RemoteWriteRequest {
150- {
151- TenantID : "" ,
152- Request : logproto.PushRequest {Streams : []logproto.Stream {{Labels : "{}" , Entries : []logproto.Entry {
153- logEntries [0 ].Entry ,
154- logEntries [1 ].Entry ,
155- {
156- Timestamp : logEntries [6 ].Entry .Timestamp ,
157- Line : logEntries [6 ].Line [:10 ],
158- },
159- }}}},
160- },
161- },
162- expectedMetrics : `
163- # HELP loki_write_sent_entries_total Number of log entries sent to the ingester.
164- # TYPE loki_write_sent_entries_total counter
165- loki_write_sent_entries_total{host="__HOST__",tenant=""} 3.0
166- # HELP loki_write_dropped_entries_total Number of log entries dropped because failed to be sent to the ingester after all retries.
167- # TYPE loki_write_dropped_entries_total counter
168- loki_write_dropped_entries_total{host="__HOST__",reason="ingester_error",tenant=""} 0
169- loki_write_dropped_entries_total{host="__HOST__",reason="line_too_long",tenant=""} 0
170- loki_write_dropped_entries_total{host="__HOST__",reason="rate_limited",tenant=""} 0
171- loki_write_dropped_entries_total{host="__HOST__",reason="stream_limited",tenant=""} 0
172- # HELP loki_write_mutated_entries_total The total number of log entries that have been mutated.
173- # TYPE loki_write_mutated_entries_total counter
174- loki_write_mutated_entries_total{host="__HOST__",reason="ingester_error",tenant=""} 0
175- loki_write_mutated_entries_total{host="__HOST__",reason="line_too_long",tenant=""} 1
176- loki_write_mutated_entries_total{host="__HOST__",reason="rate_limited",tenant=""} 0
177- loki_write_mutated_entries_total{host="__HOST__",reason="stream_limited",tenant=""} 0
178- # HELP loki_write_mutated_bytes_total The total number of bytes that have been mutated.
179- # TYPE loki_write_mutated_bytes_total counter
180- loki_write_mutated_bytes_total{host="__HOST__",reason="ingester_error",tenant=""} 0
181- loki_write_mutated_bytes_total{host="__HOST__",reason="line_too_long",tenant=""} 4
182- loki_write_mutated_bytes_total{host="__HOST__",reason="rate_limited",tenant=""} 0
183- loki_write_mutated_bytes_total{host="__HOST__",reason="stream_limited",tenant=""} 0
184- ` ,
185- },
186-
187101 "batch log entries together until the batch wait time is reached" : {
188102 clientBatchSize : 10 ,
189103 clientBatchWait : 100 * time .Millisecond ,
@@ -526,7 +440,7 @@ func TestClient_Handle(t *testing.T) {
526440 }
527441
528442 m := NewMetrics (reg )
529- c , err := New (m , cfg , 0 , testData . clientMaxLineSize , testData . clientMaxLineSizeTruncate , log .NewNopLogger ())
443+ c , err := New (m , cfg , 0 , log .NewNopLogger ())
530444 require .NoError (t , err )
531445
532446 // Send all the input log entries
@@ -666,7 +580,7 @@ func TestClient_StopNow(t *testing.T) {
666580 }
667581
668582 m := NewMetrics (reg )
669- cl , err := New (m , cfg , 0 , 0 , false , log .NewNopLogger ())
583+ cl , err := New (m , cfg , 0 , log .NewNopLogger ())
670584 require .NoError (t , err )
671585
672586 // Send all the input log entries
0 commit comments