From 66cc79ca80df13e49d3e8a71f1950ec02aa21fad Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Tue, 31 Oct 2023 09:45:03 -0700 Subject: [PATCH] [chore][exporter/signalfx] Attempt to resolve failing test (#27608) **Description:** The APM correlation test is failing with too many retry updates. The solution is to increase the `CleanupInterval` to allow the test time to make multiple correlation calls within the same dedup cleanup interval. I posted the full description in [this issue comment.](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/27059#issuecomment-1772792142) Before this fix this test would fail _almost_ every time since it was introduced into this repo, I haven't seen any failure since this update (9 successful runs). **Link to tracking Issue:** Resolves #27059 --- .../signalfxexporter/internal/apm/correlations/client.go | 2 +- .../internal/apm/correlations/client_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/exporter/signalfxexporter/internal/apm/correlations/client.go b/exporter/signalfxexporter/internal/apm/correlations/client.go index bb48cb4f98b3..427c0abb685f 100644 --- a/exporter/signalfxexporter/internal/apm/correlations/client.go +++ b/exporter/signalfxexporter/internal/apm/correlations/client.go @@ -146,7 +146,7 @@ func (cc *Client) putRequestOnChan(r *request) error { func (cc *Client) putRequestOnRetryChan(r *request) error { // handle request counter - if requestcounter.GetRequestCount(r.ctx) == cc.maxAttempts { + if requestcounter.GetRequestCount(r.ctx) >= cc.maxAttempts { return errMaxAttempts } requestcounter.IncrementRequestCount(r.ctx) diff --git a/exporter/signalfxexporter/internal/apm/correlations/client_test.go b/exporter/signalfxexporter/internal/apm/correlations/client_test.go index ecffd83add46..48cb24b996de 100644 --- a/exporter/signalfxexporter/internal/apm/correlations/client_test.go +++ b/exporter/signalfxexporter/internal/apm/correlations/client_test.go @@ -148,8 +148,8 @@ func setup(t *testing.T) (CorrelationClient, chan *request, *atomic.Value, *atom MaxBuffered: 10, MaxRetries: 4, LogUpdates: true, - RetryDelay: 0, - CleanupInterval: 0, + RetryDelay: 0 * time.Second, + CleanupInterval: 1 * time.Minute, }, AccessToken: "", URL: serverURL, @@ -180,7 +180,6 @@ func setup(t *testing.T) (CorrelationClient, chan *request, *atomic.Value, *atom } func TestCorrelationClient(t *testing.T) { - t.Skip("See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/27059") client, serverCh, forcedRespCode, forcedRespPayload, cancel := setup(t) defer close(serverCh) defer cancel() @@ -248,6 +247,7 @@ func TestCorrelationClient(t *testing.T) { cors := waitForCors(serverCh, 1, 4) require.Len(t, cors, 0) + require.Equal(t, uint32(5), client.(*Client).maxAttempts) require.Equal(t, int64(5), atomic.LoadInt64(&client.(*Client).TotalRetriedUpdates)) forcedRespCode.Store(200)