mirror of
https://github.com/status-im/consul.git
synced 2025-02-08 11:54:12 +00:00
FIX flaky test: TestAPI_AgentMonitorJSON
This commit is contained in:
parent
31b9b90bc3
commit
f1f778ffcc
@ -1209,16 +1209,27 @@ func TestAPI_AgentMonitorJSON(t *testing.T) {
|
|||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for the first log message and validate it is valid JSON
|
retry.Run(t, func(r *retry.R) {
|
||||||
select {
|
{
|
||||||
case log := <-logCh:
|
// Register a service to be sure something happens in secs
|
||||||
var output map[string]interface{}
|
serviceReg := &AgentServiceRegistration{
|
||||||
if err := json.Unmarshal([]byte(log), &output); err != nil {
|
Name: "redis",
|
||||||
t.Fatalf("log output was not JSON: %q", log)
|
}
|
||||||
|
if err := agent.ServiceRegister(serviceReg); err != nil {
|
||||||
|
r.Fatalf("err: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case <-time.After(10 * time.Second):
|
// Wait for the first log message and validate it is valid JSON
|
||||||
t.Fatalf("failed to get a log message")
|
select {
|
||||||
}
|
case log := <-logCh:
|
||||||
|
var output map[string]interface{}
|
||||||
|
if err := json.Unmarshal([]byte(log), &output); err != nil {
|
||||||
|
r.Fatalf("log output was not JSON: %q", log)
|
||||||
|
}
|
||||||
|
case <-time.After(10 * time.Second):
|
||||||
|
r.Fatalf("failed to get a log message")
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAPI_ServiceMaintenance(t *testing.T) {
|
func TestAPI_ServiceMaintenance(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user