From 72d469b3b7d401c1def4f2a0955e499b2a6cc2d5 Mon Sep 17 00:00:00 2001 From: Dmitrii Anoshin Date: Thu, 5 Oct 2023 08:26:11 -0700 Subject: [PATCH] [chore] [exporterhelper] Remove redundant test helper (#8625) Cut from https://github.com/open-telemetry/opentelemetry-collector/pull/8275 --- exporter/exporterhelper/queue_sender_test.go | 9 +-------- exporter/exporterhelper/retry_sender_test.go | 9 --------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/exporter/exporterhelper/queue_sender_test.go b/exporter/exporterhelper/queue_sender_test.go index 84cccb6635e..322282a6972 100644 --- a/exporter/exporterhelper/queue_sender_test.go +++ b/exporter/exporterhelper/queue_sender_test.go @@ -306,8 +306,6 @@ func TestQueuedRetryPersistentEnabled_shutdown_dataIsRequeued(t *testing.T) { rCfg.InitialInterval = time.Millisecond rCfg.MaxElapsedTime = 0 // retry infinitely so shutdown can be triggered - req := newMockRequest(context.Background(), 3, errors.New("some error")) - be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newNoopObsrepSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -320,13 +318,8 @@ func TestQueuedRetryPersistentEnabled_shutdown_dataIsRequeued(t *testing.T) { } be.queueSender.(*queueSender).requeuingEnabled = true - // replace nextSender inside retrySender to always return error so it doesn't exit send loop - be.retrySender.setNextSender(&errorRequestSender{ - errToReturn: errors.New("some error"), - }) - // Invoke queuedRetrySender so the producer will put the item for consumer to poll - require.NoError(t, be.send(req)) + require.NoError(t, be.send(newErrorRequest(context.Background()))) // first wait for the item to be produced to the queue initially assert.Eventually(t, func() bool { diff --git a/exporter/exporterhelper/retry_sender_test.go b/exporter/exporterhelper/retry_sender_test.go index 1da5fb29ebd..0062fcb0d3b 100644 --- a/exporter/exporterhelper/retry_sender_test.go +++ b/exporter/exporterhelper/retry_sender_test.go @@ -404,12 +404,3 @@ func (pcq *producerConsumerQueueWithCounter) Produce(item internal.Request) bool pcq.produceCounter.Add(1) return pcq.ProducerConsumerQueue.Produce(item) } - -type errorRequestSender struct { - baseRequestSender - errToReturn error -} - -func (rs *errorRequestSender) send(_ internal.Request) error { - return rs.errToReturn -}