mirror of
https://github.com/redis/go-redis.git
synced 2025-12-02 06:22:31 +03:00
flaky test
This commit is contained in:
@@ -902,8 +902,9 @@ func (cn *Conn) MaybeHasData() bool {
|
||||
// Uses cached time to avoid expensive syscall (max 50ms staleness is acceptable for deadline calculation).
|
||||
func (cn *Conn) deadline(ctx context.Context, timeout time.Duration) time.Time {
|
||||
// Use cached time for deadline calculation (called 2x per command: read + write)
|
||||
tm := time.Unix(0, getCachedTimeNs())
|
||||
cn.SetUsedAt(tm)
|
||||
nowNs := getCachedTimeNs()
|
||||
cn.SetUsedAtNs(nowNs)
|
||||
tm := time.Unix(0, nowNs)
|
||||
|
||||
if timeout > 0 {
|
||||
tm = tm.Add(timeout)
|
||||
|
||||
@@ -91,8 +91,9 @@ func TestConn_UsedAtUpdatedOnWrite(t *testing.T) {
|
||||
// Verify the difference is reasonable (should be around 100ms, accounting for ~50ms cache precision)
|
||||
diff := updatedUsedAt.Sub(initialUsedAt)
|
||||
|
||||
if diff > 100*time.Millisecond {
|
||||
t.Errorf("Expected usedAt difference to be no more than 100ms (±50ms for cache), got %v", diff)
|
||||
// 50 ms is the cache precision, so we allow up to 110ms difference
|
||||
if diff < 45*time.Millisecond || diff > 155*time.Millisecond {
|
||||
t.Errorf("Expected usedAt difference to be around 100 (±50ms for cache) (+-5ms for sleep precision), got %v", diff)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -391,11 +391,11 @@ func TestPushNotifications(t *testing.T) {
|
||||
go commandsRunner.FireCommandsUntilStop(ctx)
|
||||
go commandsRunner2.FireCommandsUntilStop(ctx)
|
||||
go commandsRunner3.FireCommandsUntilStop(ctx)
|
||||
time.Sleep(30 * time.Second)
|
||||
time.Sleep(2 * time.Minute)
|
||||
commandsRunner.Stop()
|
||||
commandsRunner2.Stop()
|
||||
commandsRunner3.Stop()
|
||||
time.Sleep(5 * time.Minute)
|
||||
time.Sleep(1 * time.Minute)
|
||||
allLogsAnalysis := logCollector.GetAnalysis()
|
||||
trackerAnalysis := tracker.GetAnalysis()
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ func TestConnectionHook(t *testing.T) {
|
||||
select {
|
||||
case <-initConnCalled:
|
||||
// Good, initialization was called
|
||||
case <-time.After(1 * time.Second):
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("Timeout waiting for initialization function to be called")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user