From 9f1cb6fdc5784f55dcbab734d90c2d21cb90bbf1 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Wed, 18 Feb 2026 15:47:21 +0100 Subject: [PATCH] hsic: add ReadLog method for container log inspection Add ReadLog() to HeadscaleInContainer and the ControlServer interface so integration tests can inspect container logs at runtime. This is needed by the SSH check mode tests to extract the auth-id from headscale log output. Updates #1850 --- integration/control.go | 1 + integration/hsic/hsic.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) 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) {