Update start time for readloop started, check RTT on flapper test

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2020-05-22 13:35:29 -07:00
parent a695d7aeb7
commit 413884d87f
2 changed files with 14 additions and 1 deletions

View File

@@ -894,7 +894,10 @@ func (c *client) readLoop() {
// Check the per-account-cache for closed subscriptions
cpacc := c.kind == ROUTER || c.kind == GATEWAY
// Last per-account-cache check for closed subscriptions
lpacc := time.Now()
now := time.Now()
lpacc := now
// Update our notion of when we started. Useful for better initial RTT estimation.
c.start = now
c.mu.Unlock()
defer func() {

View File

@@ -705,6 +705,9 @@ func TestServiceLatencyWithQueueSubscribersAndNames(t *testing.T) {
nc.Flush()
}
// Wait for them all to propagate.
time.Sleep(100 * time.Millisecond)
doRequest := func() {
nc := clientConnect(t, selectServer(), "bar")
defer nc.Close()
@@ -731,6 +734,13 @@ func TestServiceLatencyWithQueueSubscribersAndNames(t *testing.T) {
json.Unmarshal(msg.Data, &sl)
rlock.Lock()
results[sl.Responder.Name] += sl.ServiceLatency
// This test is measuring for sampling and service latency.
// In a loaded test, like on Travis, our RTT estimation for
// the responder may be off slightly. So we check and compensate
// for that here.
if sl.Responder.RTT > 25*time.Millisecond {
results[sl.Responder.Name] += sl.Responder.RTT
}
serviced[sl.Responder.Name]++
rlock.Unlock()
if r := atomic.AddInt32(&received, 1); r >= toSend {