fix(telemetry)_: fix flaky cache test
This commit is contained in:
parent
7a23ac59c4
commit
327be21de0
|
@ -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))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue