- Notifications
You must be signed in to change notification settings - Fork928
feat: change agent to use v2 API for reporting stats#12024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -52,6 +52,7 @@ import ( | ||
"github.com/coder/coder/v2/agent/agentproc/agentproctest" | ||
"github.com/coder/coder/v2/agent/agentssh" | ||
"github.com/coder/coder/v2/agent/agenttest" | ||
"github.com/coder/coder/v2/agent/proto" | ||
"github.com/coder/coder/v2/codersdk" | ||
"github.com/coder/coder/v2/codersdk/agentsdk" | ||
"github.com/coder/coder/v2/pty/ptytest" | ||
@@ -85,11 +86,11 @@ func TestAgent_Stats_SSH(t *testing.T) { | ||
err=session.Shell() | ||
require.NoError(t,err) | ||
vars*proto.Stats | ||
require.Eventuallyf(t,func()bool { | ||
varokbool | ||
s,ok=<-stats | ||
returnok&&s.ConnectionCount>0&&s.RxBytes>0&&s.TxBytes>0&&s.SessionCountSsh==1 | ||
},testutil.WaitLong,testutil.IntervalFast, | ||
"never saw stats: %+v",s, | ||
) | ||
@@ -118,11 +119,11 @@ func TestAgent_Stats_ReconnectingPTY(t *testing.T) { | ||
_,err=ptyConn.Write(data) | ||
require.NoError(t,err) | ||
vars*proto.Stats | ||
require.Eventuallyf(t,func()bool { | ||
varokbool | ||
s,ok=<-stats | ||
returnok&&s.ConnectionCount>0&&s.RxBytes>0&&s.TxBytes>0&&s.SessionCountReconnectingPty==1 | ||
},testutil.WaitLong,testutil.IntervalFast, | ||
"never saw stats: %+v",s, | ||
) | ||
@@ -177,14 +178,14 @@ func TestAgent_Stats_Magic(t *testing.T) { | ||
require.Eventuallyf(t,func()bool { | ||
s,ok:=<-stats | ||
t.Logf("got stats: ok=%t, ConnectionCount=%d, RxBytes=%d, TxBytes=%d, SessionCountVSCode=%d, ConnectionMedianLatencyMS=%f", | ||
ok,s.ConnectionCount,s.RxBytes,s.TxBytes,s.SessionCountVscode,s.ConnectionMedianLatencyMs) | ||
Comment on lines -180 to +181 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. VSCode vs Vscode are these renamed on purpose? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. The SDK type fields were written by humans, the proto type fields are machine translated from lowercase_with_underscores so it doesn't get capitalization correct in all cases. Unfortunate from a style perspective, but I haven't chased down how to fix it yet. | ||
returnok&&s.ConnectionCount>0&&s.RxBytes>0&&s.TxBytes>0&& | ||
// Ensure that the connection didn't count as a "normal" SSH session. | ||
// This was a special one, so it should be labeled specially in the stats! | ||
s.SessionCountVscode==1&& | ||
// Ensure that connection latency is being counted! | ||
// If it isn't, it's set to -1. | ||
s.ConnectionMedianLatencyMs>=0 | ||
},testutil.WaitLong,testutil.IntervalFast, | ||
"never saw stats", | ||
) | ||
@@ -243,9 +244,9 @@ func TestAgent_Stats_Magic(t *testing.T) { | ||
require.Eventuallyf(t,func()bool { | ||
s,ok:=<-stats | ||
t.Logf("got stats with conn open: ok=%t, ConnectionCount=%d, SessionCountJetBrains=%d", | ||
ok,s.ConnectionCount,s.SessionCountJetbrains) | ||
returnok&&s.ConnectionCount>0&& | ||
s.SessionCountJetbrains==1 | ||
},testutil.WaitLong,testutil.IntervalFast, | ||
"never saw stats with conn open", | ||
) | ||
@@ -258,9 +259,9 @@ func TestAgent_Stats_Magic(t *testing.T) { | ||
require.Eventuallyf(t,func()bool { | ||
s,ok:=<-stats | ||
t.Logf("got stats after disconnect %t, %d", | ||
ok,s.SessionCountJetbrains) | ||
returnok&& | ||
s.SessionCountJetbrains==0 | ||
},testutil.WaitLong,testutil.IntervalFast, | ||
"never saw stats after conn closes", | ||
) | ||
@@ -1346,7 +1347,7 @@ func TestAgent_Lifecycle(t *testing.T) { | ||
RunOnStop:true, | ||
}}, | ||
}, | ||
make(chan*proto.Stats,50), | ||
tailnet.NewCoordinator(logger), | ||
) | ||
deferclient.Close() | ||
@@ -1667,7 +1668,7 @@ func TestAgent_UpdatedDERP(t *testing.T) { | ||
_=coordinator.Close() | ||
}) | ||
agentID:=uuid.New() | ||
statsCh:=make(chan*proto.Stats,50) | ||
fs:=afero.NewMemMapFs() | ||
client:=agenttest.NewClient(t, | ||
logger.Named("agent"), | ||
@@ -1816,7 +1817,7 @@ func TestAgent_Reconnect(t *testing.T) { | ||
defercoordinator.Close() | ||
agentID:=uuid.New() | ||
statsCh:=make(chan*proto.Stats,50) | ||
derpMap,_:=tailnettest.RunDERPAndSTUN(t) | ||
client:=agenttest.NewClient(t, | ||
logger, | ||
@@ -1861,7 +1862,7 @@ func TestAgent_WriteVSCodeConfigs(t *testing.T) { | ||
GitAuthConfigs:1, | ||
DERPMap:&tailcfg.DERPMap{}, | ||
}, | ||
make(chan*proto.Stats,50), | ||
coordinator, | ||
) | ||
deferclient.Close() | ||
@@ -2018,7 +2019,7 @@ func setupSSHSession( | ||
funcsetupAgent(t*testing.T,metadata agentsdk.Manifest,ptyTimeout time.Duration,opts...func(*agenttest.Client,*agent.Options)) ( | ||
*codersdk.WorkspaceAgentConn, | ||
*agenttest.Client, | ||
<-chan*proto.Stats, | ||
afero.Fs, | ||
agent.Agent, | ||
) { | ||
@@ -2046,7 +2047,7 @@ func setupAgent(t *testing.T, metadata agentsdk.Manifest, ptyTimeout time.Durati | ||
t.Cleanup(func() { | ||
_=coordinator.Close() | ||
}) | ||
statsCh:=make(chan*proto.Stats,50) | ||
fs:=afero.NewMemMapFs() | ||
c:=agenttest.NewClient(t,logger.Named("agent"),metadata.AgentID,metadata,statsCh,coordinator) | ||
t.Cleanup(c.Close) | ||
Uh oh!
There was an error while loading.Please reload this page.