fix(telemetry)_: fix flaky cache test

This commit is contained in:
Arseniy Klempner 2024-09-27 07:59:14 -07:00
parent 7a23ac59c4
commit 327be21de0
No known key found for this signature in database
GPG Key ID: 51653F18863BD24B
1 changed files with 14 additions and 6 deletions

View File

@ -288,19 +288,27 @@ func TestRetryCacheCleanup(t *testing.T) {
ctx := context.Background() ctx := context.Background()
client := createClient(t, "") client := createClient(t, "")
client.Start(ctx)
for i := 0; i < 6000; i++ { 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)) 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)) require.Equal(t, 5001, len(client.telemetryRetryCache))
} }