mirror of
https://github.com/jsiebens/ionscale.git
synced 2026-03-31 15:07:49 +01:00
chore(tests): add flag to print ionscale logs
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package sc
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/bufbuild/connect-go"
|
||||
@@ -96,6 +97,31 @@ func (s *Scenario) PushOIDCUser(sub, email, preferredUsername string) {
|
||||
require.NoError(s.t, err)
|
||||
}
|
||||
|
||||
func (s *Scenario) printIonscaleLogs() error {
|
||||
var stdout bytes.Buffer
|
||||
|
||||
err := s.pool.Client.Logs(docker.LogsOptions{
|
||||
Context: context.TODO(),
|
||||
Container: s.ionscale.Container.ID,
|
||||
OutputStream: &stdout,
|
||||
ErrorStream: io.Discard,
|
||||
Tail: "all",
|
||||
RawTerminal: false,
|
||||
Stdout: true,
|
||||
Stderr: true,
|
||||
Follow: false,
|
||||
Timestamps: false,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = os.Stdout.Write(stdout.Bytes())
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
type TailscaleNodeConfig struct {
|
||||
Hostname string
|
||||
}
|
||||
@@ -157,6 +183,10 @@ func Run(t *testing.T, f func(s *Scenario)) {
|
||||
_ = pool.Purge(r)
|
||||
}
|
||||
|
||||
if verbose() {
|
||||
_ = s.printIonscaleLogs()
|
||||
}
|
||||
|
||||
if s.ionscale != nil {
|
||||
_ = pool.Purge(s.ionscale)
|
||||
}
|
||||
@@ -313,3 +343,7 @@ func prepareDockerPoolAndImages() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func verbose() bool {
|
||||
return os.Getenv("IONSCALE_TESTS_VERBOSE") == "true"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user