Skip to content

Commit

Permalink
fixed ssh handshake in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Code-Hex committed Oct 29, 2024
1 parent 39818f1 commit 924ca70
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions virtualization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,35 @@ RETRY:
t.Fatalf("failed to connect vsock: %v", err)
}

t.Log("setup ssh client in container")

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

sshClient, err := testhelper.NewSshClient(conn, ":22", sshConfig)
if err != nil {
select {
case <-retry:
t.Log("retry because ssh handshake has been failed")
continue RETRY
default:
}
conn.Close()
t.Fatalf("failed to create a new ssh client: %v", err)
}

close(initialized)

t.Logf("container setup done")

return &Container{
VirtualMachine: vm,
Client: sshClient,
Expand Down

0 comments on commit 924ca70

Please sign in to comment.