| 715 | } |
| 716 | |
| 717 | void TestSuccessSelective(bool single_server, bool async, bool short_connection) { |
| 718 | std::cout << " *** single=" << single_server |
| 719 | << " async=" << async |
| 720 | << " short=" << short_connection << std::endl; |
| 721 | |
| 722 | const size_t NCHANS = 8; |
| 723 | ASSERT_EQ(0, StartAccept(_ep)); |
| 724 | brpc::SelectiveChannel channel; |
| 725 | brpc::ChannelOptions options; |
| 726 | options.max_retry = 0; |
| 727 | ASSERT_EQ(0, channel.Init("rr", &options)); |
| 728 | for (size_t i = 0; i < NCHANS; ++i) { |
| 729 | brpc::Channel* subchan = new brpc::Channel; |
| 730 | SetUpChannel(subchan, single_server, short_connection); |
| 731 | ASSERT_EQ(0, channel.AddChannel(subchan, NULL)) << "i=" << i; |
| 732 | } |
| 733 | brpc::Controller cntl; |
| 734 | test::EchoRequest req; |
| 735 | test::EchoResponse res; |
| 736 | req.set_message(__FUNCTION__); |
| 737 | req.set_code(23); |
| 738 | CallMethod(&channel, &cntl, &req, &res, async); |
| 739 | |
| 740 | EXPECT_EQ(0, cntl.ErrorCode()) << cntl.ErrorText(); |
| 741 | EXPECT_EQ(1, cntl.sub_count()); |
| 742 | ASSERT_EQ(0, cntl.sub(0)->ErrorCode()); |
| 743 | EXPECT_EQ("received " + std::string(__FUNCTION__), res.message()); |
| 744 | ASSERT_EQ(1, res.code_list_size()); |
| 745 | ASSERT_EQ(req.code(), res.code_list(0)); |
| 746 | ASSERT_EQ(_ep, cntl.remote_side()); |
| 747 | |
| 748 | if (short_connection) { |
| 749 | // Sleep to let `_messenger' detect `Socket' being `SetFailed' |
| 750 | const int64_t start_time = butil::cpuwide_time_us(); |
| 751 | while (_messenger.ConnectionCount() != 0) { |
| 752 | EXPECT_LT(butil::cpuwide_time_us(), start_time + 100000L/*100ms*/); |
| 753 | bthread_usleep(1000); |
| 754 | } |
| 755 | } else { |
| 756 | EXPECT_GE(1ul, _messenger.ConnectionCount()); |
| 757 | } |
| 758 | StopAndJoin(); |
| 759 | } |
| 760 | |
| 761 | void TestSkipParallel(bool single_server, bool async, bool short_connection) { |
| 762 | std::cout << " *** single=" << single_server |
nothing calls this directly
no test coverage detected