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

Method TestDestroyChannel

test/brpc_channel_unittest.cpp:1704–1729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1702 }
1703
1704 void TestDestroyChannel(bool single_server, bool short_connection) {
1705 std::cout << "*** single=" << single_server
1706 << ", short=" << short_connection << std::endl;
1707
1708 ASSERT_EQ(0, StartAccept(_ep));
1709 brpc::Channel* channel = new brpc::Channel();
1710 SetUpChannel(channel, single_server, short_connection);
1711
1712 brpc::Controller cntl;
1713 test::EchoRequest req;
1714 test::EchoResponse res;
1715 req.set_message(__FUNCTION__);
1716 req.set_sleep_us(10000);
1717 CallMethod(channel, &cntl, &req, &res, true, true/*destroy*/);
1718
1719 EXPECT_EQ(0, cntl.ErrorCode()) << cntl.ErrorText();
1720 EXPECT_EQ("received " + std::string(__FUNCTION__), res.message());
1721 // Sleep to let `_messenger' detect `Socket' being `SetFailed'
1722 const int64_t start_time = butil::cpuwide_time_us();
1723 while (_messenger.ConnectionCount() != 0) {
1724 EXPECT_LT(butil::cpuwide_time_us(), start_time + 100000L/*100ms*/);
1725 bthread_usleep(1000);
1726 }
1727
1728 StopAndJoin();
1729 }
1730
1731 void TestDestroyChannelParallel(bool single_server, bool short_connection) {
1732 std::cout << "*** single=" << single_server

Callers

nothing calls this directly

Calls 6

cpuwide_time_usFunction · 0.85
bthread_usleepFunction · 0.85
ErrorCodeMethod · 0.80
ErrorTextMethod · 0.80
ConnectionCountMethod · 0.80
messageMethod · 0.45

Tested by

no test coverage detected