diff options
author | Alexander Polcyn <apolcyn@google.com> | 2017-03-14 12:26:17 -0700 |
---|---|---|
committer | Alexander Polcyn <apolcyn@google.com> | 2017-03-14 12:26:17 -0700 |
commit | fcad5799b4c785d428ed30340d79581a5d97026c (patch) | |
tree | 78654e566d8cf58bf23aecc3331cbf38423a309c /src/ruby/spec | |
parent | 427ec5e433e006b7095e68029f5e99a6b11ce962 (diff) |
in the middle of fixing watch and get connectivity state to work with new changes
Diffstat (limited to 'src/ruby/spec')
-rw-r--r-- | src/ruby/spec/channel_connection_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/ruby/spec/channel_connection_spec.rb b/src/ruby/spec/channel_connection_spec.rb index 58ab37d7bc..d8e10f7b76 100644 --- a/src/ruby/spec/channel_connection_spec.rb +++ b/src/ruby/spec/channel_connection_spec.rb @@ -90,4 +90,53 @@ describe 'channel connection behavior' do expect(stub.an_rpc(req)).to be_a(EchoMsg) stop_server end + + it 'observably connects and reconnects to transient server when using the channel state API', trial: true do + port = start_server + ch = GRPC::Core::Channel.new("localhost:#{port}", {}, :this_channel_is_insecure) + + expect(ch.connectivity_state).to be(GRPC::Core::ConnectivityStates::IDLE) + + state = ch.connectivity_state(true) + + count = 0 + while count < 20 and state != GRPC::Core::ConnectivityStates::READY do + STDERR.puts "first round of waiting for state to become READY" + ch.watch_connectivity_state(state, Time.now + 60) + state = ch.connectivity_state(true) + count += 1 + end + + expect(state).to be(GRPC::Core::ConnectivityStates::READY) + + stop_server + + state = ch.connectivity_state + + count = 0 + while count < 20 and state == GRPC::Core::ConnectivityStates::READY do + STDERR.puts "server shut down. waiting for state to not be READY" + ch.watch_connectivity_state(state, Time.now + 60) + state = ch.connectivity_state + count += 1 + end + + expect(state).to_not be(GRPC::Core::ConnectivityStates::READY) + + start_server(port) + + state = ch.connectivity_state(true) + + count = 0 + while count < 20 and state != GRPC::Core::ConnectivityStates::READY do + STDERR.puts "second round of waiting for state to become READY" + ch.watch_connectivity_state(state, Time.now + 60) + state = ch.connectivity_state(true) + count += 1 + end + + expect(state).to be(GRPC::Core::ConnectivityStates::READY) + + stop_server + end end |