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

Method TestRpcz

test/brpc_builtin_service_unittest.cpp:322–504  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320 }
321
322 void TestRpcz(bool enable, bool hex, bool use_html) {
323 std::string expect_type = (use_html ? "text/html" : "text/plain");
324 brpc::RpczService service;
325 brpc::RpczRequest req;
326 brpc::RpczResponse res;
327 if (!enable) {
328 {
329 ClosureChecker done;
330 brpc::Controller cntl;
331 SetUpController(&cntl, use_html);
332 service.disable(&cntl, &req, &res, &done);
333 EXPECT_FALSE(cntl.Failed());
334 EXPECT_FALSE(brpc::FLAGS_enable_rpcz);
335 }
336 {
337 ClosureChecker done;
338 brpc::Controller cntl;
339 SetUpController(&cntl, use_html);
340 service.default_method(&cntl, &req, &res, &done);
341 EXPECT_FALSE(cntl.Failed());
342 EXPECT_EQ(expect_type,
343 cntl.http_response().content_type());
344 if (!use_html) {
345 CheckContent(cntl, "rpcz is not enabled");
346 }
347 }
348 {
349 ClosureChecker done;
350 brpc::Controller cntl;
351 SetUpController(&cntl, use_html);
352 service.stats(&cntl, &req, &res, &done);
353 EXPECT_FALSE(cntl.Failed());
354 if (!use_html) {
355 CheckContent(cntl, "rpcz is not enabled");
356 }
357 }
358 return;
359 }
360
361 {
362 ClosureChecker done;
363 brpc::Controller cntl;
364 SetUpController(&cntl, use_html);
365 service.enable(&cntl, &req, &res, &done);
366 EXPECT_FALSE(cntl.Failed());
367 EXPECT_EQ(expect_type, cntl.http_response().content_type());
368 EXPECT_TRUE(brpc::FLAGS_enable_rpcz);
369 }
370
371 if (hex) {
372 ClosureChecker done;
373 brpc::Controller cntl;
374 SetUpController(&cntl, use_html);
375 service.hex_log_id(&cntl, &req, &res, &done);
376 EXPECT_FALSE(cntl.Failed());
377 EXPECT_TRUE(brpc::FLAGS_rpcz_hex_log_id);
378 } else {
379 ClosureChecker done;

Callers

nothing calls this directly

Calls 15

CheckContentFunction · 0.85
str2endpointFunction · 0.85
snprintfFunction · 0.85
disableMethod · 0.80
statsMethod · 0.80
enableMethod · 0.80
hex_log_idMethod · 0.80
dec_log_idMethod · 0.80
AddServiceMethod · 0.80
SetQueryMethod · 0.80
ErrorTextMethod · 0.80
FailedMethod · 0.45

Tested by

no test coverage detected