@@ -59,13 +59,7 @@ func TestShardBatcher_NoSplit_MinThresholdZero_TimeoutDisabled(t *testing.T) {
59
59
}
60
60
61
61
sink := requesttest .NewSink ()
62
- ba := newMultiBatcher (cfg , batcherSettings [request.Request ]{
63
- sizerType : tt .sizerType ,
64
- sizer : tt .sizer ,
65
- partitioner : nil ,
66
- next : sink .Export ,
67
- maxWorkers : tt .maxWorkers ,
68
- })
62
+ ba := newShard (cfg , tt .sizerType , tt .sizer , newWorkerPool (tt .maxWorkers ), sink .Export )
69
63
require .NoError (t , ba .Start (context .Background (), componenttest .NewNopHost ()))
70
64
t .Cleanup (func () {
71
65
require .NoError (t , ba .Shutdown (context .Background ()))
@@ -83,7 +77,7 @@ func TestShardBatcher_NoSplit_MinThresholdZero_TimeoutDisabled(t *testing.T) {
83
77
assert .Eventually (t , func () bool {
84
78
return sink .RequestsCount () == 5 && (sink .ItemsCount () == 75 || sink .BytesCount () == 75 )
85
79
}, 1 * time .Second , 10 * time .Millisecond )
86
- // Check that done callback is called for the right amount of times.
80
+ // Check that done callback is called for the right number of times.
87
81
assert .EqualValues (t , 1 , done .errors .Load ())
88
82
assert .EqualValues (t , 5 , done .success .Load ())
89
83
})
@@ -130,13 +124,7 @@ func TestShardBatcher_NoSplit_TimeoutDisabled(t *testing.T) {
130
124
}
131
125
132
126
sink := requesttest .NewSink ()
133
- ba := newMultiBatcher (cfg , batcherSettings [request.Request ]{
134
- sizerType : tt .sizerType ,
135
- sizer : tt .sizer ,
136
- partitioner : nil ,
137
- next : sink .Export ,
138
- maxWorkers : tt .maxWorkers ,
139
- })
127
+ ba := newShard (cfg , tt .sizerType , tt .sizer , newWorkerPool (tt .maxWorkers ), sink .Export )
140
128
require .NoError (t , ba .Start (context .Background (), componenttest .NewNopHost ()))
141
129
142
130
done := newFakeDone ()
@@ -165,7 +153,7 @@ func TestShardBatcher_NoSplit_TimeoutDisabled(t *testing.T) {
165
153
assert .Equal (t , 3 , sink .RequestsCount ())
166
154
assert .True (t , sink .ItemsCount () == 57 || sink .BytesCount () == 57 )
167
155
168
- // Check that done callback is called for the right amount of times.
156
+ // Check that done callback is called for the right number of times.
169
157
assert .EqualValues (t , 3 , done .errors .Load ())
170
158
assert .EqualValues (t , 4 , done .success .Load ())
171
159
})
@@ -216,13 +204,7 @@ func TestShardBatcher_NoSplit_WithTimeout(t *testing.T) {
216
204
}
217
205
218
206
sink := requesttest .NewSink ()
219
- ba := newMultiBatcher (cfg , batcherSettings [request.Request ]{
220
- sizerType : tt .sizerType ,
221
- sizer : tt .sizer ,
222
- partitioner : nil ,
223
- next : sink .Export ,
224
- maxWorkers : tt .maxWorkers ,
225
- })
207
+ ba := newShard (cfg , tt .sizerType , tt .sizer , newWorkerPool (tt .maxWorkers ), sink .Export )
226
208
require .NoError (t , ba .Start (context .Background (), componenttest .NewNopHost ()))
227
209
t .Cleanup (func () {
228
210
require .NoError (t , ba .Shutdown (context .Background ()))
@@ -241,7 +223,7 @@ func TestShardBatcher_NoSplit_WithTimeout(t *testing.T) {
241
223
return sink .RequestsCount () == 1 && (sink .ItemsCount () == 75 || sink .BytesCount () == 75 )
242
224
}, 1 * time .Second , 10 * time .Millisecond )
243
225
244
- // Check that done callback is called for the right amount of times.
226
+ // Check that done callback is called for the right number of times.
245
227
assert .EqualValues (t , 1 , done .errors .Load ())
246
228
assert .EqualValues (t , 5 , done .success .Load ())
247
229
})
@@ -293,13 +275,7 @@ func TestShardBatcher_Split_TimeoutDisabled(t *testing.T) {
293
275
}
294
276
295
277
sink := requesttest .NewSink ()
296
- ba := newMultiBatcher (cfg , batcherSettings [request.Request ]{
297
- sizerType : tt .sizerType ,
298
- sizer : tt .sizer ,
299
- partitioner : nil ,
300
- next : sink .Export ,
301
- maxWorkers : tt .maxWorkers ,
302
- })
278
+ ba := newShard (cfg , tt .sizerType , tt .sizer , newWorkerPool (tt .maxWorkers ), sink .Export )
303
279
require .NoError (t , ba .Start (context .Background (), componenttest .NewNopHost ()))
304
280
305
281
done := newFakeDone ()
@@ -332,7 +308,7 @@ func TestShardBatcher_Split_TimeoutDisabled(t *testing.T) {
332
308
assert .Equal (t , 11 , sink .RequestsCount ())
333
309
assert .True (t , sink .ItemsCount () == 1005 || sink .BytesCount () == 1005 )
334
310
335
- // Check that done callback is called for the right amount of times.
311
+ // Check that done callback is called for the right number of times.
336
312
assert .EqualValues (t , 2 , done .errors .Load ())
337
313
assert .EqualValues (t , 7 , done .success .Load ())
338
314
})
@@ -346,13 +322,7 @@ func TestShardBatcher_Shutdown(t *testing.T) {
346
322
}
347
323
348
324
sink := requesttest .NewSink ()
349
- ba := newMultiBatcher (cfg , batcherSettings [request.Request ]{
350
- sizerType : request .SizerTypeItems ,
351
- sizer : request .NewItemsSizer (),
352
- partitioner : nil ,
353
- next : sink .Export ,
354
- maxWorkers : 2 ,
355
- })
325
+ ba := newShard (cfg , request .SizerTypeItems , request .NewItemsSizer (), newWorkerPool (2 ), sink .Export )
356
326
require .NoError (t , ba .Start (context .Background (), componenttest .NewNopHost ()))
357
327
358
328
done := newFakeDone ()
@@ -367,7 +337,7 @@ func TestShardBatcher_Shutdown(t *testing.T) {
367
337
assert .Equal (t , 1 , sink .RequestsCount ())
368
338
assert .Equal (t , 3 , sink .ItemsCount ())
369
339
370
- // Check that done callback is called for the right amount of times.
340
+ // Check that done callback is called for the right number of times.
371
341
assert .EqualValues (t , 0 , done .errors .Load ())
372
342
assert .EqualValues (t , 2 , done .success .Load ())
373
343
}
@@ -380,14 +350,7 @@ func TestShardBatcher_MergeError(t *testing.T) {
380
350
}
381
351
382
352
sink := requesttest .NewSink ()
383
- ba := newMultiBatcher (cfg , batcherSettings [request.Request ]{
384
- sizerType : request .SizerTypeItems ,
385
- sizer : request .NewItemsSizer (),
386
- partitioner : nil ,
387
- next : sink .Export ,
388
- maxWorkers : 2 ,
389
- })
390
-
353
+ ba := newShard (cfg , request .SizerTypeItems , request .NewItemsSizer (), newWorkerPool (2 ), sink .Export )
391
354
require .NoError (t , ba .Start (context .Background (), componenttest .NewNopHost ()))
392
355
t .Cleanup (func () {
393
356
require .NoError (t , ba .Shutdown (context .Background ()))
@@ -405,7 +368,7 @@ func TestShardBatcher_MergeError(t *testing.T) {
405
368
return done .errors .Load () == 2
406
369
}, 1 * time .Second , 10 * time .Millisecond )
407
370
408
- // Check that done callback is called for the right amount of times.
371
+ // Check that done callback is called for the right number of times.
409
372
assert .EqualValues (t , 2 , done .errors .Load ())
410
373
assert .EqualValues (t , 0 , done .success .Load ())
411
374
}
0 commit comments