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

Method TestRPCTimeoutParallel

test/brpc_channel_unittest.cpp:1318–1352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1316 }
1317
1318 void TestRPCTimeoutParallel(
1319 bool single_server, bool async, bool short_connection) {
1320 std::cout << " *** single=" << single_server
1321 << " async=" << async
1322 << " short=" << short_connection << std::endl;
1323 ASSERT_EQ(0, StartAccept(_ep));
1324
1325 const size_t NCHANS = 8;
1326 brpc::Channel subchans[NCHANS];
1327 brpc::ParallelChannel channel;
1328 for (size_t i = 0; i < NCHANS; ++i) {
1329 SetUpChannel(&subchans[i], single_server, short_connection);
1330 ASSERT_EQ(0, channel.AddChannel(
1331 &subchans[i], brpc::DOESNT_OWN_CHANNEL,
1332 NULL, NULL));
1333 }
1334
1335 brpc::Controller cntl;
1336 test::EchoRequest req;
1337 test::EchoResponse res;
1338 req.set_message(__FUNCTION__);
1339 cntl.set_timeout_ms(17);
1340 req.set_sleep_us(70000); // 70ms
1341 butil::Timer tm;
1342 tm.start();
1343 CallMethod(&channel, &cntl, &req, &res, async);
1344 tm.stop();
1345 EXPECT_EQ(brpc::ERPCTIMEDOUT, cntl.ErrorCode()) << cntl.ErrorText();
1346 EXPECT_EQ(NCHANS, (size_t)cntl.sub_count());
1347 for (int i = 0; i < cntl.sub_count(); ++i) {
1348 EXPECT_EQ(ECANCELED, cntl.sub(i)->ErrorCode()) << "i=" << i;
1349 }
1350 EXPECT_LT(labs(tm.m_elapsed() - cntl.timeout_ms()), 15);
1351 StopAndJoin();
1352 }
1353
1354 class MakeTheRequestTimeout : public brpc::CallMapper {
1355 public:

Callers

nothing calls this directly

Calls 10

set_timeout_msMethod · 0.80
ErrorCodeMethod · 0.80
ErrorTextMethod · 0.80
sub_countMethod · 0.80
subMethod · 0.80
m_elapsedMethod · 0.80
timeout_msMethod · 0.80
AddChannelMethod · 0.45
startMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected