Browse Source

tests: fixed unstable test TestAPI_AgentMonitor (#7561)

Similar fix as https://github.com/hashicorp/consul/pull/7541
pull/7565/head
Pierre Souchay 5 years ago committed by GitHub
parent
commit
4d35816bee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      api/agent_test.go

15
api/agent_test.go

@ -1186,15 +1186,26 @@ func TestAPI_AgentMonitor(t *testing.T) {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)
} }
retry.Run(t, func(r *retry.R) {
{
// Register a service to be sure something happens in secs
serviceReg := &AgentServiceRegistration{
Name: "redis",
}
if err := agent.ServiceRegister(serviceReg); err != nil {
r.Fatalf("err: %v", err)
}
}
// Wait for the first log message and validate it // Wait for the first log message and validate it
select { select {
case log := <-logCh: case log := <-logCh:
if !(strings.Contains(log, "[INFO]") || strings.Contains(log, "[DEBUG]")) { if !(strings.Contains(log, "[INFO]") || strings.Contains(log, "[DEBUG]")) {
t.Fatalf("bad: %q", log) r.Fatalf("bad: %q", log)
} }
case <-time.After(10 * time.Second): case <-time.After(10 * time.Second):
t.Fatalf("failed to get a log message") r.Fatalf("failed to get a log message")
} }
})
} }
func TestAPI_AgentMonitorJSON(t *testing.T) { func TestAPI_AgentMonitorJSON(t *testing.T) {

Loading…
Cancel
Save