diff --git a/testhelper/docker/resource/sshserver/sshserver.go b/testhelper/docker/resource/sshserver/sshserver.go index 60e1d914..c198e40a 100644 --- a/testhelper/docker/resource/sshserver/sshserver.go +++ b/testhelper/docker/resource/sshserver/sshserver.go @@ -119,7 +119,6 @@ func Setup(pool *dockertest.Pool, cln resource.Cleaner, opts ...Option) (*Resour } var ( - buf *bytes.Buffer timeout = time.After(30 * time.Second) ticker = time.NewTicker(200 * time.Millisecond) ) @@ -127,23 +126,26 @@ loop: for { select { case <-ticker.C: - buf = bytes.NewBuffer(nil) + stdOut := bytes.NewBuffer(nil) + stdErr := bytes.NewBuffer(nil) + exitCode, err := container.Exec([]string{"cat", "/config/logs/openssh/current"}, dockertest.ExecOptions{ - StdOut: buf, + StdOut: stdOut, + StdErr: stdErr, }) if err != nil { - cln.Log("could not exec into SSH server:", err) + cln.Logf("could not exec into SSH server: %s. \nstdout: \n%s, \nstderr: \n%s", err, stdOut.String(), stdErr.String()) continue } if exitCode != 0 { - cln.Log("invalid exit code while exec-ing into SSH server:", exitCode) + cln.Logf("invalid exit code while exec-ing into SSH server: %d. \nstdout: \n%s, \nstderr: \n%s", exitCode, stdOut.String(), stdErr.String()) continue } - if buf.String() == "" { + if stdOut.String() == "" { cln.Log("SSH server not ready yet") continue } - if !strings.Contains(buf.String(), "Server listening on :: port "+exposedPort) { + if !strings.Contains(stdOut.String(), "Server listening on :: port "+exposedPort) { cln.Log("SSH server not listening on port yet") continue }