Merge pull request #18141 from markdroth/resolver_connectivity_state

Transition into state CONNECTING when we start name resolution
pull/18143/head
Mark D. Roth 6 years ago committed by GitHub
commit d7fe3b023e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/core/ext/filters/client_channel/resolving_lb_policy.cc
  2. 21
      test/cpp/end2end/client_lb_end2end_test.cc

@ -218,6 +218,9 @@ void ResolvingLoadBalancingPolicy::StartResolvingLocked() {
}
GPR_ASSERT(!started_resolving_);
started_resolving_ = true;
channel_control_helper()->UpdateState(
GRPC_CHANNEL_CONNECTING, GRPC_ERROR_NONE,
UniquePtr<SubchannelPicker>(New<QueuePicker>(Ref())));
Ref().release();
resolver_->NextLocked(&resolver_result_, &on_resolver_result_changed_);
}

@ -402,6 +402,27 @@ class ClientLbEnd2endTest : public ::testing::Test {
std::shared_ptr<ChannelCredentials> creds_;
};
TEST_F(ClientLbEnd2endTest, ChannelStateConnectingWhenResolving) {
const int kNumServers = 3;
StartServers(kNumServers);
auto channel = BuildChannel("");
auto stub = BuildStub(channel);
// Initial state should be IDLE.
EXPECT_EQ(channel->GetState(false /* try_to_connect */), GRPC_CHANNEL_IDLE);
// Tell the channel to try to connect.
// Note that this call also returns IDLE, since the state change has
// not yet occurred; it just gets triggered by this call.
EXPECT_EQ(channel->GetState(true /* try_to_connect */), GRPC_CHANNEL_IDLE);
// Now that the channel is trying to connect, we should be in state
// CONNECTING.
EXPECT_EQ(channel->GetState(false /* try_to_connect */),
GRPC_CHANNEL_CONNECTING);
// Return a resolver result, which allows the connection attempt to proceed.
SetNextResolution(GetServersPorts());
// We should eventually transition into state READY.
EXPECT_TRUE(WaitForChannelReady(channel.get()));
}
TEST_F(ClientLbEnd2endTest, PickFirst) {
// Start servers and send one RPC per server.
const int kNumServers = 3;

Loading…
Cancel
Save