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

Function TEST_F

src/tests/master_quota_tests.cpp:223–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221
222
223TEST_F(MasterQuotaTest, UpdateAndGetQuota)
224{
225 TestAllocator<> allocator;
226 EXPECT_CALL(allocator, initialize(_, _, _));
227
228 Try<Owned<cluster::Master>> master = StartMaster(&allocator);
229 ASSERT_SOME(master);
230
231 process::http::Headers headers = createBasicAuthHeaders(DEFAULT_CREDENTIAL);
232 headers["Content-Type"] = "application/json";
233
234 // Use force flag to update the quota.
235 Future<Response> response = process::http::post(
236 master.get()->pid,
237 "/api/v1",
238 headers,
239 createUpdateQuotaRequestBody(
240 createQuotaConfig(ROLE1, "cpus:1;mem:1024", "cpus:2;mem:2048"),
241 true));
242
243 AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
244
245 // Verify "/roles".
246 response = process::http::get(
247 master.get()->pid,
248 "roles",
249 None(),
250 createBasicAuthHeaders(DEFAULT_CREDENTIAL));
251
252 AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
253
254 Try<JSON::Value> parse = JSON::parse(response->body);
255 ASSERT_SOME(parse);
256
257 Try<JSON::Value> expected = JSON::parse(
258 "{"
259 " \"roles\": ["
260 " {"
261 " \"frameworks\": [],"
262 " \"name\": \"role1\","
263 " \"resources\": {},"
264 " \"allocated\": {},"
265 " \"offered\": {},"
266 " \"reserved\": {},"
267 " \"quota\": {"
268 " \"consumed\": {},"
269 " \"limit\": {"
270 " \"cpus\": 2.0,"
271 " \"mem\": 2048.0"
272 " },"
273 " \"guarantee\": {"
274 " \"cpus\": 1.0,"
275 " \"mem\": 1024.0"
276 " },"
277 " \"role\": \"role1\""
278 " },"
279 " \"weight\": 1.0"
280 " }"

Callers

nothing calls this directly

Calls 15

createBasicAuthHeadersFunction · 0.85
createQuotaConfigFunction · 0.85
OKClass · 0.85
NoneClass · 0.85
ForbiddenClass · 0.85
BadRequestClass · 0.85
formatFunction · 0.85
protobufFunction · 0.85
createDiskInfoFunction · 0.85
createReservedResourceFunction · 0.85

Tested by

no test coverage detected