@@ -62,8 +62,6 @@ func TestQueueConfig_Validate(t *testing.T) {
6262 assert .NoError (t , noCfg .Validate ())
6363}
6464
65- // --- New Tests for Request Middleware ---
66-
6765// nopComponent satisfies component.Component but does not implement RequestMiddleware.
6866type nopComponent struct {}
6967
@@ -299,100 +297,3 @@ func TestQueueSender_Start_Errors_And_Cleanup(t *testing.T) {
299297 })
300298 }
301299}
302-
303- func TestNewQueueSender_RequestMiddleware_LogsWarningOnDefaultConsumers (t * testing.T ) {
304- mwID := component .MustNewID ("request_middleware" )
305-
306- tests := []struct {
307- name string
308- inputConfig queuebatch.Config
309- wantConsumers int
310- wantLog bool
311- }{
312- {
313- name : "warn_on_default_consumer_count" ,
314- inputConfig : func () queuebatch.Config {
315- cfg := NewDefaultQueueConfig ()
316- cfg .RequestMiddlewares = []component.ID {mwID }
317- cfg .NumConsumers = 10
318- return cfg
319- }(),
320- wantConsumers : 10 , // Should NOT change
321- wantLog : true ,
322- },
323- {
324- name : "respect_high_consumer_count" ,
325- inputConfig : func () queuebatch.Config {
326- cfg := NewDefaultQueueConfig ()
327- cfg .RequestMiddlewares = []component.ID {mwID }
328- cfg .NumConsumers = 500
329- return cfg
330- }(),
331- wantConsumers : 500 ,
332- wantLog : false ,
333- },
334- {
335- name : "ignore_if_middleware_disabled" ,
336- inputConfig : func () queuebatch.Config {
337- cfg := NewDefaultQueueConfig ()
338- cfg .RequestMiddlewares = nil
339- cfg .NumConsumers = 10
340- return cfg
341- }(),
342- wantConsumers : 10 ,
343- wantLog : false ,
344- },
345- }
346-
347- for _ , tt := range tests {
348- t .Run (tt .name , func (t * testing.T ) {
349- logger , observed := observer .New (zap .WarnLevel )
350- cfg := tt .inputConfig
351-
352- warnIfNumConsumersMayCapMiddleware (& cfg , zap .New (logger ))
353-
354- assert .Equal (t , tt .wantConsumers , cfg .NumConsumers )
355- if tt .wantLog {
356- require .Len (t , observed .All (), 1 , "Expected a warning log" )
357- assert .Contains (t , observed .All ()[0 ].Message , "sending_queue.num_consumers is at the default" )
358- } else {
359- assert .Len (t , observed .All (), 0 , "Expected no warning logs" )
360- }
361- })
362- }
363- }
364-
365- func TestQueueSender_RequestMiddleware_Disabled_NoInteraction (t * testing.T ) {
366- // 1. Setup a host with the extension available, but do NOT use it.
367- mwID := component .MustNewID ("request_middleware" )
368- mockMw := & mockRequestMiddleware {}
369- host := & mockHost {
370- ext : map [component.ID ]component.Component {
371- mwID : mockMw ,
372- },
373- }
374-
375- // 2. do NOT configure the RequestMiddlewares in the queue settings.
376- qSet := queuebatch.AllSettings [request.Request ]{
377- ID : component .MustNewID ("otlp" ),
378- Signal : pipeline .SignalTraces ,
379- Telemetry : componenttest .NewNopTelemetrySettings (),
380- }
381- qCfg := NewDefaultQueueConfig ()
382- qCfg .RequestMiddlewares = nil
383-
384- nextSender := sender .NewSender (func (ctx context.Context , req request.Request ) error {
385- return nil
386- })
387-
388- qs , err := NewQueueSender (qSet , qCfg , "" , nextSender )
389- require .NoError (t , err )
390-
391- // 3. Start and Send data
392- require .NoError (t , qs .Start (context .Background (), host ))
393- require .NoError (t , qs .Send (context .Background (), & requesttest.FakeRequest {Items : 10 }))
394- require .NoError (t , qs .Shutdown (context .Background ()))
395-
396- // 4. Verification: Assert ABSOLUTELY NO interaction with the mock middleware
397- assert .Nil (t , mockMw .wrapper , "WrapSender should not be called when middleware is disabled" )
398- }
0 commit comments