parallel test causes deadlock

This commit is contained in:
Asim Aslam 2018-03-13 18:50:58 +00:00
parent dca078f30b
commit a941a4772b

View File

@ -30,38 +30,30 @@ func TestService(t *testing.T) {
// we can't test service.Init as it parses the command line // we can't test service.Init as it parses the command line
// service.Init() // service.Init()
t.Run("Run", func(t *testing.T) { // run service
t.Parallel() go service.Run()
// run service // wait for start
service.Run() wg.Wait()
})
t.Run("Debug.Health", func(t *testing.T) { // test call debug
t.Parallel() req := service.Client().NewRequest(
"test.service",
"Debug.Health",
new(proto.HealthRequest),
)
// wait for start rsp := new(proto.HealthResponse)
wg.Wait()
// test call debug err := service.Client().Call(context.TODO(), req, rsp)
req := service.Client().NewRequest( if err != nil {
"test.service", t.Fatal(err)
"Debug.Health", }
new(proto.HealthRequest),
)
rsp := new(proto.HealthResponse) if rsp.Status != "ok" {
t.Fatalf("service response: %s", rsp.Status)
}
err := service.Client().Call(context.TODO(), req, rsp) // shutdown the service
if err != nil { cancel()
t.Fatal(err)
}
if rsp.Status != "ok" {
t.Fatalf("service response: %s", rsp.Status)
}
// shutdown the service
cancel()
})
} }