diff options
author | yang-g <yangg@google.com> | 2015-09-18 01:24:14 -0700 |
---|---|---|
committer | yang-g <yangg@google.com> | 2015-09-18 01:24:14 -0700 |
commit | d886f339399e0936e26a55fd71519b2db588d2fc (patch) | |
tree | f72655d675888e292780182deb70cee71a393bbc /test/cpp | |
parent | a63fe4e259d572b591ec8b4ea21101d242be4f62 (diff) |
add a test
Diffstat (limited to 'test/cpp')
-rw-r--r-- | test/cpp/end2end/end2end_test.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index bd829d96e1..c294d59454 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -1076,6 +1076,24 @@ TEST_F(End2endTest, ChannelState) { EXPECT_EQ(GRPC_CHANNEL_CONNECTING, channel_->GetState(false)); } +// Takes 10s. +TEST_F(End2endTest, ChannelStateTimeout) { + int port = grpc_pick_unused_port_or_die(); + std::ostringstream server_address; + server_address << "127.0.0.1:" << port; + // Channel to non-existing server + auto channel = CreateChannel(server_address.str(), InsecureCredentials()); + // Start IDLE + EXPECT_EQ(GRPC_CHANNEL_IDLE, channel->GetState(true)); + + auto state = GRPC_CHANNEL_IDLE; + for (int i = 0; i < 10; i++) { + channel->WaitForStateChange(state, std::chrono::system_clock::now() + + std::chrono::milliseconds(1000)); + state = channel->GetState(false); + } +} + // Talking to a non-existing service. TEST_F(End2endTest, NonExistingService) { ResetChannel(); |