From 705d8f5fe85618abc37bbcdad184994404dab68a Mon Sep 17 00:00:00 2001 From: Ivan Kozlovic Date: Fri, 23 Mar 2018 14:20:16 -0600 Subject: [PATCH] Fix last activity monitoring test This test originally used only 1 connection. It was then modified to use another connection to check the publishing effect into the last activity. However, when polling for connz we were using [0], but that may not necessarily match the connection we were checking. I don't think that there was a need for a new connection in this test, so use a single connection. --- server/client.go | 2 +- server/monitor_test.go | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/server/client.go b/server/client.go index d7588d06760..d6f8c0a6788 100644 --- a/server/client.go +++ b/server/client.go @@ -769,7 +769,7 @@ func (c *client) processSub(argo []byte) (err error) { c.traceInOp("SUB", argo) // Indicate activity. - c.cache.subs += 1 + c.cache.subs++ // Copy so we do not reference a potentially large buffer arg := make([]byte, len(argo)) diff --git a/server/monitor_test.go b/server/monitor_test.go index 7ca750151bb..75292dbee45 100644 --- a/server/monitor_test.go +++ b/server/monitor_test.go @@ -371,10 +371,6 @@ func TestConnzLastActivity(t *testing.T) { defer nc.Close() nc.Flush() - nc2 := createClientConnSubscribeAndPublish(t, s) - defer nc2.Close() - nc2.Flush() - // Test inside details of each connection ci := pollConz(t, s, mode, url, opts).Conns[0] if len(ci.Subs) != 1 { @@ -429,8 +425,7 @@ func TestConnzLastActivity(t *testing.T) { time.Sleep(100 * time.Millisecond) // Message delivery should trigger as well - nc2.Publish("foo", []byte("Hello")) - nc2.Flush() + nc.Publish("foo", []byte("Hello")) nc.Flush() ci = pollConz(t, s, mode, url, opts).Conns[0] msgLast := ci.LastActivity