| 759 | } |
| 760 | |
| 761 | void TestSkipParallel(bool single_server, bool async, bool short_connection) { |
| 762 | std::cout << " *** single=" << single_server |
| 763 | << " async=" << async |
| 764 | << " short=" << short_connection << std::endl; |
| 765 | |
| 766 | ASSERT_EQ(0, StartAccept(_ep)); |
| 767 | const size_t NCHANS = 8; |
| 768 | brpc::Channel subchans[NCHANS]; |
| 769 | brpc::ParallelChannel channel; |
| 770 | for (size_t i = 0; i < NCHANS; ++i) { |
| 771 | SetUpChannel(&subchans[i], single_server, short_connection); |
| 772 | ASSERT_EQ(0, channel.AddChannel( |
| 773 | &subchans[i], brpc::DOESNT_OWN_CHANNEL, |
| 774 | new SetCodeOnEven, NULL)); |
| 775 | } |
| 776 | brpc::Controller cntl; |
| 777 | test::EchoRequest req; |
| 778 | test::EchoResponse res; |
| 779 | req.set_message(__FUNCTION__); |
| 780 | req.set_code(23); |
| 781 | CallMethod(&channel, &cntl, &req, &res, async); |
| 782 | |
| 783 | EXPECT_EQ(0, cntl.ErrorCode()) << cntl.ErrorText(); |
| 784 | EXPECT_EQ("received " + std::string(__FUNCTION__), res.message()); |
| 785 | EXPECT_EQ(NCHANS, (size_t)cntl.sub_count()); |
| 786 | for (int i = 0; i < cntl.sub_count(); ++i) { |
| 787 | if (i % 2) { |
| 788 | EXPECT_TRUE(NULL == cntl.sub(i)) << "i=" << i; |
| 789 | } else { |
| 790 | EXPECT_TRUE(cntl.sub(i) && !cntl.sub(i)->Failed()) << "i=" << i; |
| 791 | } |
| 792 | } |
| 793 | ASSERT_EQ(NCHANS / 2, (size_t)res.code_list_size()); |
| 794 | for (int i = 0; i < res.code_list_size(); ++i) { |
| 795 | ASSERT_EQ(i*2 + 1, res.code_list(i)); |
| 796 | } |
| 797 | if (short_connection) { |
| 798 | // Sleep to let `_messenger' detect `Socket' being `SetFailed' |
| 799 | const int64_t start_time = butil::cpuwide_time_us(); |
| 800 | while (_messenger.ConnectionCount() != 0) { |
| 801 | EXPECT_LT(butil::cpuwide_time_us(), start_time + 100000L/*100ms*/); |
| 802 | bthread_usleep(1000); |
| 803 | } |
| 804 | } else { |
| 805 | EXPECT_GE(1ul, _messenger.ConnectionCount()); |
| 806 | } |
| 807 | StopAndJoin(); |
| 808 | } |
| 809 | |
| 810 | void TestSuccessParallel2(bool single_server, bool async, bool short_connection) { |
| 811 | std::cout << " *** single=" << single_server |
nothing calls this directly
no test coverage detected