Skip to content

Commit 271d99a

Browse files
committed
chore(tests): add flag to print ionscale logs
1 parent cf8b2be commit 271d99a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/sc/scenario.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package sc
22

33
import (
4+
"bytes"
45
"context"
56
"fmt"
67
"github.com/bufbuild/connect-go"
@@ -96,6 +97,31 @@ func (s *Scenario) PushOIDCUser(sub, email, preferredUsername string) {
9697
require.NoError(s.t, err)
9798
}
9899

100+
func (s *Scenario) printIonscaleLogs() error {
101+
var stdout bytes.Buffer
102+
103+
err := s.pool.Client.Logs(docker.LogsOptions{
104+
Context: context.TODO(),
105+
Container: s.ionscale.Container.ID,
106+
OutputStream: &stdout,
107+
ErrorStream: io.Discard,
108+
Tail: "all",
109+
RawTerminal: false,
110+
Stdout: true,
111+
Stderr: true,
112+
Follow: false,
113+
Timestamps: false,
114+
})
115+
116+
if err != nil {
117+
return err
118+
}
119+
120+
_, err = os.Stdout.Write(stdout.Bytes())
121+
122+
return err
123+
}
124+
99125
type TailscaleNodeConfig struct {
100126
Hostname string
101127
}
@@ -157,6 +183,10 @@ func Run(t *testing.T, f func(s *Scenario)) {
157183
_ = pool.Purge(r)
158184
}
159185

186+
if verbose() {
187+
_ = s.printIonscaleLogs()
188+
}
189+
160190
if s.ionscale != nil {
161191
_ = pool.Purge(s.ionscale)
162192
}
@@ -313,3 +343,7 @@ func prepareDockerPoolAndImages() {
313343
log.Fatal(err)
314344
}
315345
}
346+
347+
func verbose() bool {
348+
return os.Getenv("IONSCALE_TESTS_VERBOSE") == "true"
349+
}

0 commit comments

Comments
 (0)