@@ -42,20 +42,25 @@ func TestSDAMProse(t *testing.T) {
42
42
// For number of nodes N, interval I, and duration D, a Client should process at most X
43
43
// operations:
44
44
//
45
- // X = (N * (1 handshake + D/I heartbeats + D/I RTTs))
45
+ // X = (N * (2 handshakes + D/I heartbeats + D/I RTTs))
46
46
//
47
47
// Assert that a Client processes the expected number of operations for heartbeats sent at
48
48
// an interval between I and 2*I to account for different actual heartbeat intervals under
49
49
// different runtime conditions.
50
50
51
- duration := 2 * time .Second
51
+ // Measure the actual amount of time between the start of the test and when we inspect the
52
+ // sent messages. The sleep duration will be at least the specified duration but
53
+ // possibly longer, which could lead to extra heartbeat messages, so account for that in
54
+ // the assertions.
55
+ start := time .Now ()
56
+ time .Sleep (2 * time .Second )
57
+ messages := mt .GetProxiedMessages ()
58
+ duration := time .Since (start )
52
59
53
60
numNodes := len (options .Client ().ApplyURI (mtest .ClusterURI ()).Hosts )
54
- maxExpected := numNodes * (1 + 2 * int (duration / heartbeatInterval ))
55
- minExpected := numNodes * (1 + 2 * int (duration / (heartbeatInterval * 2 )))
61
+ maxExpected := numNodes * (2 + 2 * int (duration / heartbeatInterval ))
62
+ minExpected := numNodes * (2 + 2 * int (duration / (heartbeatInterval * 2 )))
56
63
57
- time .Sleep (duration )
58
- messages := mt .GetProxiedMessages ()
59
64
assert .True (
60
65
mt ,
61
66
len (messages ) >= minExpected && len (messages ) <= maxExpected ,
0 commit comments