This test ensures that a failed over master recovers completed tasks from a slave's re-registration when the slave thinks the framework has completed (but the framework has not actually completed yet from master's point of view).
| 162 | // completed (but the framework has not actually completed yet from master's |
| 163 | // point of view). |
| 164 | TEST_F(FaultToleranceTest, ReregisterCompletedFrameworks) |
| 165 | { |
| 166 | // Step 1. Start Master and Slave. |
| 167 | Try<Owned<cluster::Master>> master = StartMaster(); |
| 168 | ASSERT_SOME(master); |
| 169 | |
| 170 | MockExecutor executor(DEFAULT_EXECUTOR_ID); |
| 171 | |
| 172 | TestContainerizer containerizer(&executor); |
| 173 | |
| 174 | StandaloneMasterDetector slaveDetector(master.get()->pid); |
| 175 | |
| 176 | Try<Owned<cluster::Slave>> slave = StartSlave(&slaveDetector, &containerizer); |
| 177 | ASSERT_SOME(slave); |
| 178 | |
| 179 | // Verify master/slave have 0 completed/running frameworks. |
| 180 | Future<Response> masterState = process::http::get( |
| 181 | master.get()->pid, |
| 182 | "state", |
| 183 | None(), |
| 184 | createBasicAuthHeaders(DEFAULT_CREDENTIAL)); |
| 185 | |
| 186 | AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, masterState); |
| 187 | AWAIT_EXPECT_RESPONSE_HEADER_EQ( |
| 188 | APPLICATION_JSON, |
| 189 | "Content-Type", |
| 190 | masterState); |
| 191 | |
| 192 | Try<JSON::Object> parse = JSON::parse<JSON::Object>(masterState->body); |
| 193 | ASSERT_SOME(parse); |
| 194 | JSON::Object masterJSON = parse.get(); |
| 195 | |
| 196 | EXPECT_EQ( |
| 197 | 0u, |
| 198 | masterJSON.values["completed_frameworks"] |
| 199 | .as<JSON::Array>().values.size()); |
| 200 | EXPECT_EQ( |
| 201 | 0u, |
| 202 | masterJSON.values["frameworks"].as<JSON::Array>().values.size()); |
| 203 | |
| 204 | // Step 2. Create/start framework. |
| 205 | StandaloneMasterDetector schedDetector(master.get()->pid); |
| 206 | |
| 207 | MockScheduler sched; |
| 208 | TestingMesosSchedulerDriver driver(&sched, &schedDetector); |
| 209 | |
| 210 | Future<FrameworkID> frameworkId; |
| 211 | EXPECT_CALL(sched, registered(&driver, _, _)) |
| 212 | .WillOnce(FutureArg<1>(&frameworkId)); |
| 213 | |
| 214 | Future<vector<Offer>> offers; |
| 215 | EXPECT_CALL(sched, resourceOffers(&driver, _)) |
| 216 | .WillOnce(FutureArg<1>(&offers)) |
| 217 | .WillRepeatedly(Return()); // Ignore subsequent offers. |
| 218 | |
| 219 | driver.start(); |
| 220 | |
| 221 | AWAIT_READY(frameworkId); |
nothing calls this directly
no test coverage detected