Skip to content

Commit aaef131

Browse files
committed
fixup! chore: refactor agent stats streaming
1 parent a983aa2 commit aaef131

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

codersdk/workspaceagents_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/http/httptest"
77
"net/url"
88
"strconv"
9+
"sync/atomic"
910
"testing"
1011
"time"
1112

@@ -54,9 +55,9 @@ func TestWorkspaceAgentMetadata(t *testing.T) {
5455
func TestAgentReportStats(t *testing.T) {
5556
t.Parallel()
5657

57-
var numReports int
58+
var numReports atomic.Int64
5859
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
59-
numReports++
60+
numReports.Add(1)
6061
httpapi.Write(context.Background(), w, http.StatusOK, codersdk.AgentStatsResponse{
6162
ReportInterval: 5 * time.Millisecond,
6263
})
@@ -73,7 +74,7 @@ func TestAgentReportStats(t *testing.T) {
7374
defer closeStream.Close()
7475

7576
require.Eventually(t,
76-
func() bool { return numReports >= 3 },
77+
func() bool { return numReports.Load() >= 3 },
7778
testutil.WaitMedium, testutil.IntervalFast,
7879
)
7980
}

0 commit comments

Comments
 (0)