diff --git a/agent/agent_test.go b/agent/agent_test.go index 9c634fb37..822eb9c89 100644 --- a/agent/agent_test.go +++ b/agent/agent_test.go @@ -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 { diff --git a/agent/testagent.go b/agent/testagent.go index 487119593..576fa77d8 100644 --- a/agent/testagent.go +++ b/agent/testagent.go @@ -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)