Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b1f59aa

Browse files
authored
fix: stop checking gauges unrelated to TestAgent_Stats_Magic (#17290)
Fixes coder/internal#564 The test is asserting too much, including stats guages that are not directly related to the thing we are trying to test: ConnectionCount, RxBytes, and TxBytes. I think the author assumed that these are counts that only go up, but they are guages and eventually zero back out, so there are race condtions where not all of them are non-zero at the same time.
1 parent 88b7c9e commit b1f59aa

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

agent/agent_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func TestAgent_Stats_Magic(t *testing.T) {
190190
s, ok := <-stats
191191
t.Logf("got stats: ok=%t, ConnectionCount=%d, RxBytes=%d, TxBytes=%d, SessionCountVSCode=%d, ConnectionMedianLatencyMS=%f",
192192
ok, s.ConnectionCount, s.RxBytes, s.TxBytes, s.SessionCountVscode, s.ConnectionMedianLatencyMs)
193-
return ok && s.ConnectionCount > 0 && s.RxBytes > 0 && s.TxBytes > 0 &&
193+
return ok &&
194194
// Ensure that the connection didn't count as a "normal" SSH session.
195195
// This was a special one, so it should be labeled specially in the stats!
196196
s.SessionCountVscode == 1 &&
@@ -258,8 +258,7 @@ func TestAgent_Stats_Magic(t *testing.T) {
258258
s, ok := <-stats
259259
t.Logf("got stats with conn open: ok=%t, ConnectionCount=%d, SessionCountJetBrains=%d",
260260
ok, s.ConnectionCount, s.SessionCountJetbrains)
261-
return ok && s.ConnectionCount > 0 &&
262-
s.SessionCountJetbrains == 1
261+
return ok && s.SessionCountJetbrains == 1
263262
}, testutil.WaitLong, testutil.IntervalFast,
264263
"never saw stats with conn open",
265264
)

0 commit comments

Comments
 (0)