| 437 | } |
| 438 | |
| 439 | void TestConnectionFailedSelective(bool single_server, bool async, |
| 440 | bool short_connection) { |
| 441 | std::cout << " *** single=" << single_server |
| 442 | << " async=" << async |
| 443 | << " short=" << short_connection << std::endl; |
| 444 | |
| 445 | const size_t NCHANS = 8; |
| 446 | brpc::SelectiveChannel channel; |
| 447 | brpc::ChannelOptions options; |
| 448 | options.max_retry = 0; |
| 449 | ASSERT_EQ(0, channel.Init("rr", &options)); |
| 450 | for (size_t i = 0; i < NCHANS; ++i) { |
| 451 | brpc::Channel* subchan = new brpc::Channel; |
| 452 | SetUpChannel(subchan, single_server, short_connection); |
| 453 | ASSERT_EQ(0, channel.AddChannel(subchan, NULL)) << "i=" << i; |
| 454 | } |
| 455 | |
| 456 | brpc::Controller cntl; |
| 457 | test::EchoRequest req; |
| 458 | test::EchoResponse res; |
| 459 | req.set_message(__FUNCTION__); |
| 460 | CallMethod(&channel, &cntl, &req, &res, async); |
| 461 | |
| 462 | EXPECT_EQ(ECONNREFUSED, cntl.ErrorCode()) << cntl.ErrorText(); |
| 463 | ASSERT_EQ(1, cntl.sub_count()); |
| 464 | EXPECT_EQ(ECONNREFUSED, cntl.sub(0)->ErrorCode()) |
| 465 | << cntl.sub(0)->ErrorText(); |
| 466 | LOG(INFO) << cntl.ErrorText(); |
| 467 | } |
| 468 | |
| 469 | void TestSuccess(bool single_server, bool async, bool short_connection) { |
| 470 | std::cout << " *** single=" << single_server |