You've already forked ionscale
mirror of
https://github.com/jsiebens/ionscale.git
synced 2026-04-05 12:32:58 +01:00
chore(tests): add flag to print ionscale logs
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package sc
|
package sc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/bufbuild/connect-go"
|
"github.com/bufbuild/connect-go"
|
||||||
@@ -96,6 +97,31 @@ func (s *Scenario) PushOIDCUser(sub, email, preferredUsername string) {
|
|||||||
require.NoError(s.t, err)
|
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 {
|
type TailscaleNodeConfig struct {
|
||||||
Hostname string
|
Hostname string
|
||||||
}
|
}
|
||||||
@@ -157,6 +183,10 @@ func Run(t *testing.T, f func(s *Scenario)) {
|
|||||||
_ = pool.Purge(r)
|
_ = pool.Purge(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if verbose() {
|
||||||
|
_ = s.printIonscaleLogs()
|
||||||
|
}
|
||||||
|
|
||||||
if s.ionscale != nil {
|
if s.ionscale != nil {
|
||||||
_ = pool.Purge(s.ionscale)
|
_ = pool.Purge(s.ionscale)
|
||||||
}
|
}
|
||||||
@@ -313,3 +343,7 @@ func prepareDockerPoolAndImages() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func verbose() bool {
|
||||||
|
return os.Getenv("IONSCALE_TESTS_VERBOSE") == "true"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user