Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit73f5af8

Browse files
authored
test: fix TestAgent_Lifecycle/ShutdownScriptOnce to wait for stats (#17387)
fixes:coder/internal#576TestAgent_Lifecycle/ShutdownScriptOnce hits error logs which cause testfailures. These logs are legit errors and have to do with shutting downthe agent before it has fully come up.This PR changes the test to wait for the agent to send stats (a goodindicator that it's fully up, and beyond the errors that have triggeredtest failures in past) before closing it.
1 parentd8fcb06 commit73f5af8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

‎agent/agent_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1650,8 +1650,10 @@ func TestAgent_Lifecycle(t *testing.T) {
16501650
t.Run("ShutdownScriptOnce",func(t*testing.T) {
16511651
t.Parallel()
16521652
logger:=testutil.Logger(t)
1653+
ctx:=testutil.Context(t,testutil.WaitMedium)
16531654
expected:="this-is-shutdown"
16541655
derpMap,_:=tailnettest.RunDERPAndSTUN(t)
1656+
statsCh:=make(chan*proto.Stats,50)
16551657

16561658
client:=agenttest.NewClient(t,
16571659
logger,
@@ -1670,7 +1672,7 @@ func TestAgent_Lifecycle(t *testing.T) {
16701672
RunOnStop:true,
16711673
}},
16721674
},
1673-
make(chan*proto.Stats,50),
1675+
statsCh,
16741676
tailnet.NewCoordinator(logger),
16751677
)
16761678
deferclient.Close()
@@ -1695,6 +1697,11 @@ func TestAgent_Lifecycle(t *testing.T) {
16951697
returnlen(content)>0// something is in the startup log file
16961698
},testutil.WaitShort,testutil.IntervalMedium)
16971699

1700+
// In order to avoid shutting down the agent before it is fully started and triggering
1701+
// errors, we'll wait until the agent is fully up. It's a bit hokey, but among the last things the agent starts
1702+
// is the stats reporting, so getting a stats report is a good indication the agent is fully up.
1703+
_=testutil.RequireRecvCtx(ctx,t,statsCh)
1704+
16981705
err:=agent.Close()
16991706
require.NoError(t,err,"agent should be closed successfully")
17001707

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp