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