Skip to content

Commit caa2578

Browse files
committed
Add logging for SSH tests
Signed-off-by: Spike Curtis <spike@coder.com>
1 parent af83870 commit caa2578

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

cli/ssh_test.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"net"
1313
"os"
1414
"os/exec"
15+
"path"
1516
"path/filepath"
1617
"runtime"
1718
"strings"
@@ -412,6 +413,28 @@ func TestSSH(t *testing.T) {
412413
t.Parallel()
413414

414415
logDir := t.TempDir()
416+
defer func() {
417+
// Copy any log files into test logs for debugging
418+
ents, err := os.ReadDir(logDir)
419+
if err != nil {
420+
t.Log("failed to read logDir")
421+
}
422+
for _, ent := range ents {
423+
fn := path.Join(logDir, ent.Name())
424+
f, err := os.Open(fn)
425+
if err != nil {
426+
t.Logf("failed to open logfile %s", fn)
427+
}
428+
logs, err := io.ReadAll(f)
429+
f.Close()
430+
if err != nil {
431+
t.Logf("failed to read logfile %s", fn)
432+
continue
433+
}
434+
t.Logf("logfile %s:", fn)
435+
t.Log(logs)
436+
}
437+
}()
415438

416439
client, workspace, agentToken := setupWorkspaceForAgent(t, nil)
417440
inv, root := clitest.New(t, "ssh", "-l", logDir, workspace.Name)
@@ -425,7 +448,7 @@ func TestSSH(t *testing.T) {
425448
agentClient.SetSessionToken(agentToken)
426449
agentCloser := agent.New(agent.Options{
427450
Client: agentClient,
428-
Logger: slogtest.Make(t, nil).Named("agent"),
451+
Logger: slogtest.Make(t, nil).Named("agent").Leveled(slog.LevelDebug),
429452
})
430453
defer func() {
431454
_ = agentCloser.Close()

tailnet/conn.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ var unixEpoch = time.Unix(0, 0)
589589
// forever.
590590
func (c *Conn) AwaitReachable(ctx context.Context, ip netip.Addr) bool {
591591
logger := c.logger.With(slog.F("ip", ip))
592+
logger.Debug(ctx, "checking reachability")
592593
rightAway := make(chan struct{}, 1)
593594
rightAway <- struct{}{}
594595
tkr := time.NewTicker(50 * time.Millisecond)

0 commit comments

Comments
 (0)