| 221 | |
| 222 | |
| 223 | TEST_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 | " }" |
nothing calls this directly
no test coverage detected