Skip to content

Commit

Permalink
Add WaitForServer in grpc_transport_test. (#37)
Browse files Browse the repository at this point in the history
* Add WaitForServer in grpc_transport_test.

* Use WaitForConnected.
  • Loading branch information
qiwzhang authored Mar 9, 2017
1 parent 14c2911 commit 0019653
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mixerclient/src/grpc_transport_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ class MockMixerServerImpl final : public ::istio::mixer::v1::Mixer::Service {
}
};

// Wait for up to 10 seconds for channel to be connected.
void WaitForServer(const std::string& server) {
auto channel = CreateChannel(server, ::grpc::InsecureChannelCredentials());
channel->WaitForConnected(gpr_time_add(
gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(10, GPR_TIMESPAN)));
}

template <class T>
class MockReader : public ReadInterface<T> {
public:
Expand All @@ -102,6 +109,8 @@ class GrpcTransportTest : public ::testing::Test {
builder.RegisterService(&service_);
server_ = builder.BuildAndStart();

WaitForServer(server_address);

grpc_transport_.reset(new GrpcTransport(server_address));
}

Expand Down

0 comments on commit 0019653

Please sign in to comment.