Skip to content

Commit

Permalink
Fix last activity monitoring test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kozlovic committed Mar 23, 2018
1 parent c587035 commit 705d8f5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion server/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
7 changes: 1 addition & 6 deletions server/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 705d8f5

Please sign in to comment.