|
@@ -28,19 +28,6 @@ func (l *TestLoggerJSON) Close() error { return nil }
|
|
|
|
|
|
func (l *TestLoggerJSON) Name() string { return "json" }
|
|
func (l *TestLoggerJSON) Name() string { return "json" }
|
|
|
|
|
|
-type TestLoggerText struct {
|
|
|
|
- *bytes.Buffer
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func (l *TestLoggerText) Log(m *Message) error {
|
|
|
|
- _, err := l.WriteString(m.ContainerID + " " + m.Source + " " + string(m.Line) + "\n")
|
|
|
|
- return err
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func (l *TestLoggerText) Close() error { return nil }
|
|
|
|
-
|
|
|
|
-func (l *TestLoggerText) Name() string { return "text" }
|
|
|
|
-
|
|
|
|
func TestCopier(t *testing.T) {
|
|
func TestCopier(t *testing.T) {
|
|
stdoutLine := "Line that thinks that it is log line from docker stdout"
|
|
stdoutLine := "Line that thinks that it is log line from docker stdout"
|
|
stderrLine := "Line that thinks that it is log line from docker stderr"
|
|
stderrLine := "Line that thinks that it is log line from docker stderr"
|
|
@@ -59,8 +46,7 @@ func TestCopier(t *testing.T) {
|
|
|
|
|
|
jsonLog := &TestLoggerJSON{Encoder: json.NewEncoder(&jsonBuf)}
|
|
jsonLog := &TestLoggerJSON{Encoder: json.NewEncoder(&jsonBuf)}
|
|
|
|
|
|
- cid := "a7317399f3f857173c6179d44823594f8294678dea9999662e5c625b5a1c7657"
|
|
|
|
- c := NewCopier(cid,
|
|
|
|
|
|
+ c := NewCopier(
|
|
map[string]io.Reader{
|
|
map[string]io.Reader{
|
|
"stdout": &stdout,
|
|
"stdout": &stdout,
|
|
"stderr": &stderr,
|
|
"stderr": &stderr,
|
|
@@ -89,9 +75,6 @@ func TestCopier(t *testing.T) {
|
|
if msg.Source != "stdout" && msg.Source != "stderr" {
|
|
if msg.Source != "stdout" && msg.Source != "stderr" {
|
|
t.Fatalf("Wrong Source: %q, should be %q or %q", msg.Source, "stdout", "stderr")
|
|
t.Fatalf("Wrong Source: %q, should be %q or %q", msg.Source, "stdout", "stderr")
|
|
}
|
|
}
|
|
- if msg.ContainerID != cid {
|
|
|
|
- t.Fatalf("Wrong ContainerID: %q, expected %q", msg.ContainerID, cid)
|
|
|
|
- }
|
|
|
|
if msg.Source == "stdout" {
|
|
if msg.Source == "stdout" {
|
|
if string(msg.Line) != stdoutLine {
|
|
if string(msg.Line) != stdoutLine {
|
|
t.Fatalf("Wrong Line: %q, expected %q", msg.Line, stdoutLine)
|
|
t.Fatalf("Wrong Line: %q, expected %q", msg.Line, stdoutLine)
|
|
@@ -118,8 +101,7 @@ func TestCopierSlow(t *testing.T) {
|
|
//encoder := &encodeCloser{Encoder: json.NewEncoder(&jsonBuf)}
|
|
//encoder := &encodeCloser{Encoder: json.NewEncoder(&jsonBuf)}
|
|
jsonLog := &TestLoggerJSON{Encoder: json.NewEncoder(&jsonBuf), delay: 100 * time.Millisecond}
|
|
jsonLog := &TestLoggerJSON{Encoder: json.NewEncoder(&jsonBuf), delay: 100 * time.Millisecond}
|
|
|
|
|
|
- cid := "a7317399f3f857173c6179d44823594f8294678dea9999662e5c625b5a1c7657"
|
|
|
|
- c := NewCopier(cid, map[string]io.Reader{"stdout": &stdout}, jsonLog)
|
|
|
|
|
|
+ c := NewCopier(map[string]io.Reader{"stdout": &stdout}, jsonLog)
|
|
c.Run()
|
|
c.Run()
|
|
wait := make(chan struct{})
|
|
wait := make(chan struct{})
|
|
go func() {
|
|
go func() {
|