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

Function TEST_F

test/brpc_server_unittest.cpp:214–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212};
213
214TEST_F(ServerTest, sanity) {
215 {
216 brpc::Server server;
217 ASSERT_EQ(-1, server.Start("127.0.0.1:12345:asdf", NULL));
218 ASSERT_EQ(-1, server.Start("127.0.0.1:99999", NULL));
219 ASSERT_EQ(0, server.Start("127.0.0.1:8613", NULL));
220 }
221 {
222 brpc::Server server;
223 // accept hostname as well.
224 ASSERT_EQ(0, server.Start("localhost:8613", NULL));
225 }
226 {
227 brpc::Server server;
228 ASSERT_EQ(0, server.Start("localhost:0", NULL));
229 // port should be replaced with the actually used one.
230 ASSERT_NE(0, server.listen_address().port);
231 }
232
233 {
234 brpc::Server server;
235 ASSERT_EQ(-1, server.Start(99999, NULL));
236 ASSERT_EQ(0, server.Start(8613, NULL));
237 }
238 {
239 brpc::Server server;
240 brpc::ServerOptions options;
241 options.internal_port = 8613; // The same as service port
242 ASSERT_EQ(-1, server.Start("127.0.0.1:8613", &options));
243 ASSERT_FALSE(server.IsRunning()); // Revert server's status
244 // And release the listen port
245 ASSERT_EQ(0, server.Start("127.0.0.1:8613", NULL));
246 }
247 {
248 brpc::Server server;
249 brpc::ServerOptions options;
250 ASSERT_EQ(0, server.Start(brpc::PortRange(8000, 9000), &options));
251 ASSERT_TRUE(server.IsRunning());
252 ASSERT_EQ(0ul, server.service_count());
253 ASSERT_TRUE(NULL == server.first_service());
254 ASSERT_EQ(0, server.Stop(0));
255 ASSERT_EQ(0, server.Join());
256 }
257
258 butil::EndPoint ep;
259 MyAuthenticator auth;
260 brpc::Server server;
261 ASSERT_EQ(0, str2endpoint("127.0.0.1:8613", &ep));
262 brpc::ServerOptions opt;
263 opt.auth = &auth;
264 ASSERT_EQ(0, server.Start(ep, &opt));
265 ASSERT_TRUE(server.IsRunning());
266 ASSERT_EQ(&auth, server.options().auth);
267 ASSERT_EQ(0ul, server.service_count());
268 ASSERT_TRUE(NULL == server.first_service());
269
270 std::vector<google::protobuf::Service*> services;
271 server.ListServices(&services);

Callers

nothing calls this directly

Calls 15

PortRangeClass · 0.85
str2endpointFunction · 0.85
DoNothingFunction · 0.85
bthread_usleepFunction · 0.85
JoinFunction · 0.85
tcp_connectFunction · 0.85
NewCallbackFunction · 0.85
bthread_start_backgroundFunction · 0.85
bthread_joinFunction · 0.85
tcp_listenFunction · 0.85
string_printfFunction · 0.85
SetLogSinkFunction · 0.85

Tested by

no test coverage detected