| 1194 | } |
| 1195 | |
| 1196 | void TestAttachment(bool async, bool short_connection) { |
| 1197 | ASSERT_EQ(0, StartAccept(_ep)); |
| 1198 | brpc::Channel channel; |
| 1199 | SetUpChannel(&channel, true, short_connection); |
| 1200 | |
| 1201 | brpc::Controller cntl; |
| 1202 | cntl.request_attachment().append("attachment"); |
| 1203 | test::EchoRequest req; |
| 1204 | test::EchoResponse res; |
| 1205 | req.set_message(__FUNCTION__); |
| 1206 | CallMethod(&channel, &cntl, &req, &res, async); |
| 1207 | |
| 1208 | EXPECT_EQ(0, cntl.ErrorCode()) << short_connection; |
| 1209 | EXPECT_FALSE(cntl.request_attachment().empty()) |
| 1210 | << ", " << async << ", " << short_connection; |
| 1211 | EXPECT_EQ("received " + std::string(__FUNCTION__), res.message()); |
| 1212 | if (short_connection) { |
| 1213 | // Sleep to let `_messenger' detect `Socket' being `SetFailed' |
| 1214 | const int64_t start_time = butil::cpuwide_time_us(); |
| 1215 | while (_messenger.ConnectionCount() != 0) { |
| 1216 | EXPECT_LT(butil::cpuwide_time_us(), start_time + 100000L/*100ms*/); |
| 1217 | bthread_usleep(1000); |
| 1218 | } |
| 1219 | } else { |
| 1220 | EXPECT_GE(1ul, _messenger.ConnectionCount()); |
| 1221 | } |
| 1222 | StopAndJoin(); |
| 1223 | } |
| 1224 | |
| 1225 | void TestRequestNotInit(bool single_server, bool async, |
| 1226 | bool short_connection) { |
nothing calls this directly
no test coverage detected