diff --git a/telemetry/client_test.go b/telemetry/client_test.go index a19a9569c..ee7a84617 100644 --- a/telemetry/client_test.go +++ b/telemetry/client_test.go @@ -288,19 +288,27 @@ func TestRetryCacheCleanup(t *testing.T) { ctx := context.Background() client := createClient(t, "") - client.Start(ctx) for i := 0; i < 6000; i++ { - sendEnvelope(ctx, client) + go sendEnvelope(ctx, client) + telemetryRequest := <-client.telemetryCh + client.telemetryCache = append(client.telemetryCache, telemetryRequest) } - time.Sleep(110 * time.Millisecond) - + client.pushTelemetryRequest(client.telemetryCache) + client.telemetryCache = nil require.Equal(t, 6000, len(client.telemetryRetryCache)) - sendEnvelope(ctx, client) + go sendEnvelope(ctx, client) + telemetryRequest := <-client.telemetryCh + client.telemetryCache = append(client.telemetryCache, telemetryRequest) - time.Sleep(210 * time.Millisecond) + client.pushTelemetryRequest(client.telemetryCache) + telemetryRequests := make([]TelemetryRequest, len(client.telemetryCache)) + copy(telemetryRequests, client.telemetryCache) + client.telemetryCache = nil + + client.pushTelemetryRequest(telemetryRequests) require.Equal(t, 5001, len(client.telemetryRetryCache)) }