fix: handle new agent stat format correctly (#14576)

---------

Co-authored-by: Ethan Dickson <ethan@coder.com>
This commit is contained in:
Garrett Delfosse
2024-09-19 11:52:14 -04:00
committed by GitHub
parent 37885e2e82
commit 922f4c545f
28 changed files with 1495 additions and 70 deletions

View File

@ -32,7 +32,7 @@ func TestCache_TemplateWorkspaceOwners(t *testing.T) {
db = dbmem.New()
cache = metricscache.New(db, slogtest.Make(t, nil), metricscache.Intervals{
TemplateBuildTimes: testutil.IntervalFast,
})
}, false)
)
defer cache.Close()
@ -150,7 +150,7 @@ func TestCache_BuildTime(t *testing.T) {
},
},
transition: database.WorkspaceTransitionStop,
}, want{50 * 1000, true},
}, want{30 * 1000, true},
},
{
"three/delete", args{
@ -183,7 +183,7 @@ func TestCache_BuildTime(t *testing.T) {
db = dbmem.New()
cache = metricscache.New(db, slogtest.Make(t, nil), metricscache.Intervals{
TemplateBuildTimes: testutil.IntervalFast,
})
}, false)
)
defer cache.Close()
@ -278,7 +278,7 @@ func TestCache_DeploymentStats(t *testing.T) {
db := dbmem.New()
cache := metricscache.New(db, slogtest.Make(t, nil), metricscache.Intervals{
DeploymentStats: testutil.IntervalFast,
})
}, false)
defer cache.Close()
err := db.InsertWorkspaceAgentStats(context.Background(), database.InsertWorkspaceAgentStatsParams{
@ -300,6 +300,7 @@ func TestCache_DeploymentStats(t *testing.T) {
SessionCountReconnectingPTY: []int64{0},
SessionCountSSH: []int64{0},
ConnectionMedianLatencyMS: []float64{10},
Usage: []bool{false},
})
require.NoError(t, err)