| 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) { |
nothing calls this directly
no test coverage detected