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

Commit2c2bbcc

Browse files
authored
chore: update tests to support fish (#6023)
* fix: update tests to add fish support* Track connections for SSH sessions to prevent leaks* Revert SSH conn handling
1 parentcf9abe3 commit2c2bbcc

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

‎agent/agent.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,13 @@ func (a *agent) run(ctx context.Context) error {
268268

269269
scriptDone:=make(chanerror,1)
270270
scriptStart:=time.Now()
271-
gofunc() {
271+
err:=a.trackConnGoroutine(func() {
272272
deferclose(scriptDone)
273273
scriptDone<-a.runStartupScript(ctx,metadata.StartupScript)
274-
}()
274+
})
275+
iferr!=nil {
276+
returnxerrors.Errorf("track startup script: %w",err)
277+
}
275278
gofunc() {
276279
vartimeout<-chan time.Time
277280
// If timeout is zero, an older version of the coder

‎agent/agent_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ func TestAgent_TCPLocalForwarding(t *testing.T) {
305305
}
306306
}()
307307

308-
cmd:=setupSSHCommand(t, []string{"-L",fmt.Sprintf("%d:127.0.0.1:%d",randomPort,remotePort)}, []string{"sleep","10"})
308+
cmd:=setupSSHCommand(t, []string{"-L",fmt.Sprintf("%d:127.0.0.1:%d",randomPort,remotePort)}, []string{"sleep","5"})
309309
err=cmd.Start()
310310
require.NoError(t,err)
311311

@@ -372,7 +372,7 @@ func TestAgent_TCPRemoteForwarding(t *testing.T) {
372372
}
373373
}()
374374

375-
cmd:=setupSSHCommand(t, []string{"-R",fmt.Sprintf("127.0.0.1:%d:127.0.0.1:%d",randomPort,localPort)}, []string{"sleep","10"})
375+
cmd:=setupSSHCommand(t, []string{"-R",fmt.Sprintf("127.0.0.1:%d:127.0.0.1:%d",randomPort,localPort)}, []string{"sleep","5"})
376376
err=cmd.Start()
377377
require.NoError(t,err)
378378

@@ -437,7 +437,7 @@ func TestAgent_UnixLocalForwarding(t *testing.T) {
437437
}
438438
}()
439439

440-
cmd:=setupSSHCommand(t, []string{"-L",fmt.Sprintf("%s:%s",localSocketPath,remoteSocketPath)}, []string{"sleep","10"})
440+
cmd:=setupSSHCommand(t, []string{"-L",fmt.Sprintf("%s:%s",localSocketPath,remoteSocketPath)}, []string{"sleep","5"})
441441
err=cmd.Start()
442442
require.NoError(t,err)
443443

@@ -495,7 +495,7 @@ func TestAgent_UnixRemoteForwarding(t *testing.T) {
495495
}
496496
}()
497497

498-
cmd:=setupSSHCommand(t, []string{"-R",fmt.Sprintf("%s:%s",remoteSocketPath,localSocketPath)}, []string{"sleep","10"})
498+
cmd:=setupSSHCommand(t, []string{"-R",fmt.Sprintf("%s:%s",remoteSocketPath,localSocketPath)}, []string{"sleep","5"})
499499
err=cmd.Start()
500500
require.NoError(t,err)
501501

@@ -703,7 +703,7 @@ func TestAgent_Lifecycle(t *testing.T) {
703703
t.Parallel()
704704

705705
_,client,_,_:=setupAgent(t, agentsdk.Metadata{
706-
StartupScript:"sleep10",
706+
StartupScript:"sleep5",
707707
StartupScriptTimeout:time.Nanosecond,
708708
},0)
709709

‎cli/ssh.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ func uploadGPGKeys(ctx context.Context, sshClient *gossh.Client) error {
458458
//
459459
// Note: we sleep after killing the agent because it doesn't always die
460460
// immediately.
461-
agentSocketBytes,err:=runRemoteSSH(sshClient,nil,`
461+
agentSocketBytes,err:=runRemoteSSH(sshClient,nil,`sh -c '
462462
set -eux
463463
agent_socket=$(gpgconf --list-dir agent-socket)
464464
echo "$agent_socket"
@@ -470,7 +470,7 @@ if [ -S "$agent_socket" ]; then
470470
fi
471471
472472
test ! -S "$agent_socket"
473-
`)
473+
'`)
474474
agentSocket:=strings.TrimSpace(string(agentSocketBytes))
475475
iferr!=nil {
476476
returnxerrors.Errorf("check if agent socket is running (check if %q exists): %w",agentSocket,err)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp