Skip to content

Commit

Permalink
tmp 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Code-Hex committed Feb 25, 2024
1 parent 05b2ab2 commit f64c5cf
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions virtualization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,32 @@ RETRY:
}

t.Log("setup ssh client in container")
now := time.Now()
t.Log(conn.SetReadDeadline(now.Add(5 * time.Second)))
t.Log(conn.SetWriteDeadline(now.Add(5 * time.Second)))

initialized := make(chan struct{})
retry := make(chan struct{})
go func() {
select {
case <-initialized:
case <-time.After(5 * time.Second):
close(retry)
conn.Close()
}
}()

sshClient, err := testhelper.NewSshClient(conn, ":22", sshConfig)
if err != nil {
conn.Close()
t.Fatalf("failed to create a new ssh client: %v", err)
}
conn.SetReadDeadline(time.Time{})
conn.SetWriteDeadline(time.Time{})

select {
case <-retry:
t.Log("retry because ssh handshake has been failed")
continue RETRY
default:
close(initialized)
}

t.Logf("container setup done")

return &Container{
Expand Down

0 comments on commit f64c5cf

Please sign in to comment.