mirror of https://github.com/status-im/consul.git
api/watch: reduce timing dependence on tests of watch behavior
Also for debugging purposes send the stdout/stderr streams from consul processes spawned for API tests to testing.T.Logf
This commit is contained in:
parent
91e6c634ca
commit
f74244dde8
File diff suppressed because it is too large
Load Diff
|
@ -17,7 +17,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -249,6 +248,9 @@ func newTestServerConfigT(t *testing.T, cb ServerConfigCallback) (*TestServer, e
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := defaultServerConfig()
|
cfg := defaultServerConfig()
|
||||||
|
testWriter := TestWriter(t)
|
||||||
|
cfg.Stdout = testWriter
|
||||||
|
cfg.Stderr = testWriter
|
||||||
|
|
||||||
cfg.DataDir = filepath.Join(tmpdir, "data")
|
cfg.DataDir = filepath.Join(tmpdir, "data")
|
||||||
if cb != nil {
|
if cb != nil {
|
||||||
|
@ -262,7 +264,7 @@ func newTestServerConfigT(t *testing.T, cb ServerConfigCallback) (*TestServer, e
|
||||||
return nil, errors.Wrap(err, "failed marshaling json")
|
return nil, errors.Wrap(err, "failed marshaling json")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("CONFIG JSON: %s", string(b))
|
t.Logf("CONFIG JSON: %s", string(b))
|
||||||
configFile := filepath.Join(tmpdir, "config.json")
|
configFile := filepath.Join(tmpdir, "config.json")
|
||||||
if err := ioutil.WriteFile(configFile, b, 0644); err != nil {
|
if err := ioutil.WriteFile(configFile, b, 0644); err != nil {
|
||||||
cfg.ReturnPorts()
|
cfg.ReturnPorts()
|
||||||
|
@ -270,11 +272,11 @@ func newTestServerConfigT(t *testing.T, cb ServerConfigCallback) (*TestServer, e
|
||||||
return nil, errors.Wrap(err, "failed writing config content")
|
return nil, errors.Wrap(err, "failed writing config content")
|
||||||
}
|
}
|
||||||
|
|
||||||
stdout := io.Writer(os.Stdout)
|
stdout := testWriter
|
||||||
if cfg.Stdout != nil {
|
if cfg.Stdout != nil {
|
||||||
stdout = cfg.Stdout
|
stdout = cfg.Stdout
|
||||||
}
|
}
|
||||||
stderr := io.Writer(os.Stderr)
|
stderr := testWriter
|
||||||
if cfg.Stderr != nil {
|
if cfg.Stderr != nil {
|
||||||
stderr = cfg.Stderr
|
stderr = cfg.Stderr
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue