diff --git a/integration/control.go b/integration/control.go index f390d080..d9273ae6 100644 --- a/integration/control.go +++ b/integration/control.go @@ -16,6 +16,7 @@ import ( type ControlServer interface { Shutdown() (string, string, error) SaveLog(path string) (string, string, error) + ReadLog() (string, string, error) SaveProfile(path string) error Execute(command []string) (string, error) WriteFile(path string, content []byte) error diff --git a/integration/hsic/hsic.go b/integration/hsic/hsic.go index 3ef4d5d4..cd60c20d 100644 --- a/integration/hsic/hsic.go +++ b/integration/hsic/hsic.go @@ -699,6 +699,18 @@ func (t *HeadscaleInContainer) WriteLogs(stdout, stderr io.Writer) error { return dockertestutil.WriteLog(t.pool, t.container, stdout, stderr) } +// ReadLog returns the current stdout and stderr logs from the headscale container. +func (t *HeadscaleInContainer) ReadLog() (string, string, error) { + var stdout, stderr bytes.Buffer + + err := dockertestutil.WriteLog(t.pool, t.container, &stdout, &stderr) + if err != nil { + return "", "", fmt.Errorf("reading container logs: %w", err) + } + + return stdout.String(), stderr.String(), nil +} + // SaveLog saves the current stdout log of the container to a path // on the host system. func (t *HeadscaleInContainer) SaveLog(path string) (string, string, error) {