Skip to content

Instantly share code, notes, and snippets.

@clsung
Created October 13, 2016 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clsung/181f09063776407c5a45e3f6d32590d1 to your computer and use it in GitHub Desktop.
Save clsung/181f09063776407c5a45e3f6d32590d1 to your computer and use it in GitHub Desktop.
Test GRPC
// TestRMsvrSuccess test success case, this can't fail
func (s *FailTestSuite) TestRMsvrSuccess() {
err := StartResourceMgr(s.chErr, config.Config.QueueSize, config.Config.RMServerAddr, config.Config.QueuedTaskTTL)
assert.NoError(s.T(), err)
var conn *grpc.ClientConn
for ts := 250; ts <= 1000; ts += 250 {
time.Sleep(time.Duration(ts) * time.Millisecond)
conn, err = grpc.Dial(config.Config.RMServerAddr, grpc.WithInsecure(), grpc.WithTimeout(5*time.Second))
if err == nil {
break
}
}
assert.NoError(s.T(), err, "should have no error")
cli := rmpb.NewServiceClient(conn)
assert.NoError(s.T(), err, "should have no error")
stopreq := &rmpb.Empty{}
_, err = cli.StopService(context.Background(), stopreq)
assert.NoError(s.T(), err, "should have no error")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment