summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api4/system_test.go22
-rw-r--r--app/web_hub.go1
2 files changed, 23 insertions, 0 deletions
diff --git a/api4/system_test.go b/api4/system_test.go
index f74d91563..b12421e62 100644
--- a/api4/system_test.go
+++ b/api4/system_test.go
@@ -534,6 +534,28 @@ func TestGetAnalyticsOld(t *testing.T) {
_, resp = th.SystemAdminClient.GetAnalyticsOld("", th.BasicTeam.Id)
CheckNoError(t, resp)
+ rows2, resp2 := th.SystemAdminClient.GetAnalyticsOld("standard", "")
+ CheckNoError(t, resp2)
+ assert.Equal(t, "total_websocket_connections", rows2[5].Name)
+ assert.Equal(t, float64(0), rows2[5].Value)
+
+ WebSocketClient, err := th.CreateWebSocketClient()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ rows2, resp2 = th.SystemAdminClient.GetAnalyticsOld("standard", "")
+ CheckNoError(t, resp2)
+ assert.Equal(t, "total_websocket_connections", rows2[5].Name)
+ assert.Equal(t, float64(1), rows2[5].Value)
+
+ WebSocketClient.Close()
+
+ rows2, resp2 = th.SystemAdminClient.GetAnalyticsOld("standard", "")
+ CheckNoError(t, resp2)
+ assert.Equal(t, "total_websocket_connections", rows2[5].Name)
+ assert.Equal(t, float64(0), rows2[5].Value)
+
Client.Logout()
_, resp = Client.GetAnalyticsOld("", th.BasicTeam.Id)
CheckUnauthorizedStatus(t, resp)
diff --git a/app/web_hub.go b/app/web_hub.go
index c1c8cb7bb..971b03481 100644
--- a/app/web_hub.go
+++ b/app/web_hub.go
@@ -378,6 +378,7 @@ func (h *Hub) Start() {
atomic.StoreInt64(&h.connectionCount, int64(len(connections.All())))
case webCon := <-h.unregister:
connections.Remove(webCon)
+ atomic.StoreInt64(&h.connectionCount, int64(len(connections.All())))
if len(webCon.UserId) == 0 {
continue