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