chore: move stat reporting into workspacestats package (#13386)

This commit is contained in:
Garrett Delfosse
2024-05-29 11:49:08 -04:00
committed by GitHub
parent afd9d3b35f
commit 5789ea5397
19 changed files with 314 additions and 346 deletions
+1 -27
View File
@@ -939,32 +939,6 @@ func TestWorkspaceAgentReportStats(t *testing.T) {
agentClient.SetSessionToken(r.AgentToken)
_, err := agentClient.PostStats(context.Background(), &agentsdk.Stats{
ConnectionsByProto: map[string]int64{"TCP": 1},
// Set connection count to 1 but all session counts to zero to
// assert we aren't updating last_used_at for a connections that may
// be spawned passively by the dashboard.
ConnectionCount: 1,
RxPackets: 1,
RxBytes: 1,
TxPackets: 1,
TxBytes: 1,
SessionCountVSCode: 0,
SessionCountJetBrains: 0,
SessionCountReconnectingPTY: 0,
SessionCountSSH: 0,
ConnectionMedianLatencyMS: 10,
})
require.NoError(t, err)
newWorkspace, err := client.Workspace(context.Background(), r.Workspace.ID)
require.NoError(t, err)
assert.True(t,
newWorkspace.LastUsedAt.Equal(r.Workspace.LastUsedAt),
"%s and %s should not differ", newWorkspace.LastUsedAt, r.Workspace.LastUsedAt,
)
_, err = agentClient.PostStats(context.Background(), &agentsdk.Stats{
ConnectionsByProto: map[string]int64{"TCP": 1},
ConnectionCount: 1,
RxPackets: 1,
@@ -979,7 +953,7 @@ func TestWorkspaceAgentReportStats(t *testing.T) {
})
require.NoError(t, err)
newWorkspace, err = client.Workspace(context.Background(), r.Workspace.ID)
newWorkspace, err := client.Workspace(context.Background(), r.Workspace.ID)
require.NoError(t, err)
assert.True(t,