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

Method TestRPCTimeoutSelective

test/brpc_channel_unittest.cpp:1407–1440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1405 }
1406
1407 void TestRPCTimeoutSelective(
1408 bool single_server, bool async, bool short_connection) {
1409 std::cout << " *** single=" << single_server
1410 << " async=" << async
1411 << " short=" << short_connection << std::endl;
1412 ASSERT_EQ(0, StartAccept(_ep));
1413
1414 const size_t NCHANS = 8;
1415 brpc::SelectiveChannel channel;
1416 ASSERT_EQ(0, channel.Init("rr", NULL));
1417 for (size_t i = 0; i < NCHANS; ++i) {
1418 brpc::Channel* subchan = new brpc::Channel;
1419 SetUpChannel(subchan, single_server, short_connection);
1420 ASSERT_EQ(0, channel.AddChannel(subchan, NULL)) << "i=" << i;
1421 }
1422
1423 brpc::Controller cntl;
1424 test::EchoRequest req;
1425 test::EchoResponse res;
1426 req.set_message(__FUNCTION__);
1427 cntl.set_timeout_ms(17);
1428 req.set_sleep_us(70000); // 70ms
1429 butil::Timer tm;
1430 tm.start();
1431 CallMethod(&channel, &cntl, &req, &res, async);
1432 tm.stop();
1433 EXPECT_EQ(brpc::ERPCTIMEDOUT, cntl.ErrorCode()) << cntl.ErrorText();
1434 EXPECT_EQ(1, cntl.sub_count());
1435 EXPECT_EQ(brpc::ERPCTIMEDOUT, cntl.sub(0)->ErrorCode());
1436 EXPECT_LT(labs(tm.m_elapsed() - cntl.timeout_ms()), 15);
1437 EXPECT_EQ(-1, cntl.sub(0)->_timeout_ms);
1438 EXPECT_EQ(17, cntl.sub(0)->_real_timeout_ms);
1439 StopAndJoin();
1440 }
1441
1442 void TestBackupRequestSelective(
1443 bool single_server, bool async, bool short_connection) {

Callers

nothing calls this directly

Calls 11

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
InitMethod · 0.45
AddChannelMethod · 0.45
startMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected