c.suite.T().Helper()
c.suite.log(containerExecCommand)
byteOutput, err := exechelper.CombinedOutput(containerExecCommand)
- c.suite.assertNil(err)
+ c.suite.assertNil(err, err)
return string(byteOutput)
}
f.Close()
}
-func (c *Container) log() string {
- cmd := "docker logs " + c.name
+// Outputs logs from docker containers. Set 'maxLines' to 0 to output the full log.
+func (c *Container) log(maxLines int) (string, error) {
+ var cmd string
+ if maxLines == 0 {
+ cmd = "docker logs " + c.name
+ } else {
+ cmd = fmt.Sprintf("docker logs --tail %d %s", maxLines, c.name)
+ }
+
c.suite.log(cmd)
o, err := exechelper.CombinedOutput(cmd)
- c.suite.assertNil(err)
- return string(o)
+ return string(o), err
}
func (c *Container) stop() error {
template := template.Must(template.ParseFiles(templateName))
f, err := os.CreateTemp(logDir, "hst-config")
- c.suite.assertNil(err)
+ c.suite.assertNil(err, err)
defer os.Remove(f.Name())
err = template.Execute(f, values)
- c.suite.assertNil(err)
+ c.suite.assertNil(err, err)
err = f.Close()
- c.suite.assertNil(err)
+ c.suite.assertNil(err, err)
c.copy(f.Name(), targetConfigName)
}