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

Function TEST_F

3rdparty/libprocess/src/tests/profiler_tests.cpp:76–115  ·  view source on GitHub ↗

Tests that the profiler's HTTP endpoints return the correct responses based on whether or not the profiler has been enabled.

Source from the content-addressed store, hash-verified

74// Tests that the profiler's HTTP endpoints return the correct responses
75// based on whether or not the profiler has been enabled.
76TEST_F(ProfilerTest, StartAndStop)
77{
78 UPID upid("profiler", process::address());
79
80 Future<Response> response = http::get(upid, "start");
81#ifdef ENABLE_GPERFTOOLS
82 Option<string> profilerEnabled = os::getenv("LIBPROCESS_ENABLE_PROFILER");
83
84 if (profilerEnabled.isSome() && profilerEnabled.get() == "1") {
85 AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
86 AWAIT_EXPECT_RESPONSE_BODY_EQ("Profiler started.\n", response);
87
88 response = http::get(upid, "stop");
89 AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
90 } else {
91 AWAIT_EXPECT_RESPONSE_STATUS_EQ(BadRequest().status, response);
92 AWAIT_EXPECT_RESPONSE_BODY_EQ(
93 "The profiler is not enabled. To enable the profiler, libprocess must "
94 "be started with LIBPROCESS_ENABLE_PROFILER=1 in the environment.\n",
95 response);
96
97 response = http::get(upid, "stop");
98 AWAIT_EXPECT_RESPONSE_STATUS_EQ(BadRequest().status, response);
99 AWAIT_EXPECT_RESPONSE_BODY_EQ("Profiler not running.\n", response);
100 }
101#else
102 AWAIT_EXPECT_RESPONSE_STATUS_EQ(BadRequest().status, response);
103 AWAIT_EXPECT_RESPONSE_BODY_EQ(
104 "Perftools is disabled. To enable perftools, "
105 "configure libprocess with --enable-perftools.\n",
106 response);
107
108 response = http::get(upid, "stop");
109 AWAIT_EXPECT_RESPONSE_STATUS_EQ(BadRequest().status, response);
110 AWAIT_EXPECT_RESPONSE_BODY_EQ(
111 "Perftools is disabled. To enable perftools, "
112 "configure libprocess with --enable-perftools.\n",
113 response);
114#endif
115}
116
117
118// Tests that the profiler's HTTP endpoints reject unauthenticated

Callers

nothing calls this directly

Calls 9

OKClass · 0.85
BadRequestClass · 0.85
setAuthenticatorFunction · 0.85
UnauthorizedClass · 0.85
addressFunction · 0.50
getFunction · 0.50
getenvFunction · 0.50
isSomeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected