mirror of https://github.com/status-im/consul.git
testing: reduce verbosity of output log
Previously the log output included the test name twice and a long date format. The test output is already grouped by test, so adding the test name did not add any new information. The date and time are only useful to understand elapsed time, so using a short format should provide succident detail. Also fixed a bug in NewTestAgentWithFields where nil was returned instead of the test agent.
This commit is contained in:
parent
31b9b90bc3
commit
dd40a1535e
|
@ -138,11 +138,7 @@ func TestAgent_ConnectClusterIDConfig(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// This is a rare case where using a constructor for TestAgent
|
||||
// (NewTestAgent and the likes) won't work, since we expect an error
|
||||
// in one test case, and the constructors have built-in retry logic
|
||||
// that runs automatically upon error.
|
||||
a := &TestAgent{Name: tt.name, HCL: tt.hcl, LogOutput: testutil.TestWriter(t)}
|
||||
a := NewTestAgentWithFields(t, false, TestAgent{HCL: tt.hcl})
|
||||
err := a.Start()
|
||||
if tt.wantErr {
|
||||
if err == nil {
|
||||
|
|
|
@ -25,7 +25,6 @@ import (
|
|||
"github.com/hashicorp/consul/agent/structs"
|
||||
"github.com/hashicorp/consul/api"
|
||||
"github.com/hashicorp/consul/sdk/freeport"
|
||||
"github.com/hashicorp/consul/sdk/testutil"
|
||||
"github.com/hashicorp/consul/sdk/testutil/retry"
|
||||
)
|
||||
|
||||
|
@ -104,11 +103,8 @@ func NewTestAgentWithFields(t *testing.T, start bool, ta TestAgent) *TestAgent {
|
|||
if a.Name == "" {
|
||||
a.Name = t.Name()
|
||||
}
|
||||
if a.LogOutput == nil {
|
||||
a.LogOutput = testutil.TestWriter(t)
|
||||
}
|
||||
if !start {
|
||||
return nil
|
||||
return &a
|
||||
}
|
||||
|
||||
retry.RunWith(retry.ThreeTimes(), t, func(r *retry.R) {
|
||||
|
@ -162,9 +158,9 @@ func (a *TestAgent) Start() (err error) {
|
|||
}
|
||||
|
||||
logger := hclog.NewInterceptLogger(&hclog.LoggerOptions{
|
||||
Name: a.Name,
|
||||
Level: hclog.Debug,
|
||||
Output: logOutput,
|
||||
Level: hclog.Debug,
|
||||
Output: logOutput,
|
||||
TimeFormat: "04:05.000",
|
||||
})
|
||||
|
||||
portsConfig, returnPortsFn := randomPortsSource(a.UseTLS)
|
||||
|
|
Loading…
Reference in New Issue