MCPcopy Create free account
hub / github.com/apache/brpc / TestSuccessParallel

Method TestSuccessParallel

test/brpc_channel_unittest.cpp:620–663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

618 };
619
620 void TestSuccessParallel(bool single_server, bool async, bool short_connection) {
621 std::cout << " *** single=" << single_server
622 << " async=" << async
623 << " short=" << short_connection << std::endl;
624
625 ASSERT_EQ(0, StartAccept(_ep));
626 const size_t NCHANS = 8;
627 brpc::Channel subchans[NCHANS];
628 brpc::ParallelChannel channel;
629 for (size_t i = 0; i < NCHANS; ++i) {
630 SetUpChannel(&subchans[i], single_server, short_connection);
631 ASSERT_EQ(0, channel.AddChannel(
632 &subchans[i], brpc::DOESNT_OWN_CHANNEL,
633 new SetCode, NULL));
634 }
635 brpc::Controller cntl;
636 test::EchoRequest req;
637 test::EchoResponse res;
638 req.set_message(__FUNCTION__);
639 req.set_code(23);
640 CallMethod(&channel, &cntl, &req, &res, async);
641
642 EXPECT_EQ(0, cntl.ErrorCode()) << cntl.ErrorText();
643 EXPECT_EQ(NCHANS, (size_t)cntl.sub_count());
644 for (int i = 0; i < cntl.sub_count(); ++i) {
645 EXPECT_TRUE(cntl.sub(i) && !cntl.sub(i)->Failed()) << "i=" << i;
646 }
647 EXPECT_EQ("received " + std::string(__FUNCTION__), res.message());
648 ASSERT_EQ(NCHANS, (size_t)res.code_list_size());
649 for (size_t i = 0; i < NCHANS; ++i) {
650 ASSERT_EQ((int)i+1, res.code_list(i));
651 }
652 if (short_connection) {
653 // Sleep to let `_messenger' detect `Socket' being `SetFailed'
654 const int64_t start_time = butil::cpuwide_time_us();
655 while (_messenger.ConnectionCount() != 0) {
656 EXPECT_LT(butil::cpuwide_time_us(), start_time + 100000L/*100ms*/);
657 bthread_usleep(1000);
658 }
659 } else {
660 EXPECT_GE(1ul, _messenger.ConnectionCount());
661 }
662 StopAndJoin();
663 }
664
665 void TestSuccessDuplicatedParallel(
666 bool single_server, bool async, bool short_connection) {

Callers

nothing calls this directly

Calls 10

cpuwide_time_usFunction · 0.85
bthread_usleepFunction · 0.85
ErrorCodeMethod · 0.80
ErrorTextMethod · 0.80
sub_countMethod · 0.80
subMethod · 0.80
ConnectionCountMethod · 0.80
AddChannelMethod · 0.45
FailedMethod · 0.45
messageMethod · 0.45

Tested by

no test coverage detected