This test verifies that reconciliation sends the latest task status, when the task state does not match between the framework and the master.
| 80 | // status, when the task state does not match between the framework |
| 81 | // and the master. |
| 82 | TEST_F(ReconciliationTest, TaskStateMismatch) |
| 83 | { |
| 84 | Try<Owned<cluster::Master>> master = StartMaster(); |
| 85 | ASSERT_SOME(master); |
| 86 | |
| 87 | MockExecutor exec(DEFAULT_EXECUTOR_ID); |
| 88 | TestContainerizer containerizer(&exec); |
| 89 | |
| 90 | Owned<MasterDetector> detector = master.get()->createDetector(); |
| 91 | Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), &containerizer); |
| 92 | ASSERT_SOME(slave); |
| 93 | |
| 94 | MockScheduler sched; |
| 95 | MesosSchedulerDriver driver( |
| 96 | &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL); |
| 97 | |
| 98 | Future<FrameworkID> frameworkId; |
| 99 | EXPECT_CALL(sched, registered(&driver, _, _)) |
| 100 | .WillOnce(FutureArg<1>(&frameworkId)); |
| 101 | |
| 102 | EXPECT_CALL(sched, resourceOffers(&driver, _)) |
| 103 | .WillOnce(LaunchTasks(DEFAULT_EXECUTOR_INFO, 1, 1, 512, "*")) |
| 104 | .WillRepeatedly(Return()); // Ignore subsequent offers. |
| 105 | |
| 106 | EXPECT_CALL(exec, registered(_, _, _, _)); |
| 107 | |
| 108 | EXPECT_CALL(exec, launchTask(_, _)) |
| 109 | .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING)); |
| 110 | |
| 111 | Future<TaskStatus> update; |
| 112 | EXPECT_CALL(sched, statusUpdate(&driver, _)) |
| 113 | .WillOnce(FutureArg<1>(&update)); |
| 114 | |
| 115 | driver.start(); |
| 116 | |
| 117 | // Wait until the framework is registered. |
| 118 | AWAIT_READY(frameworkId); |
| 119 | |
| 120 | AWAIT_READY(update); |
| 121 | EXPECT_EQ(TASK_RUNNING, update->state()); |
| 122 | |
| 123 | EXPECT_TRUE(update->has_slave_id()); |
| 124 | |
| 125 | const TaskID taskId = update->task_id(); |
| 126 | const SlaveID slaveId = update->slave_id(); |
| 127 | |
| 128 | // If framework has different state, current state should be reported. |
| 129 | Future<TaskStatus> update2; |
| 130 | EXPECT_CALL(sched, statusUpdate(&driver, _)) |
| 131 | .WillOnce(FutureArg<1>(&update2)); |
| 132 | |
| 133 | TaskStatus status; |
| 134 | status.mutable_task_id()->CopyFrom(taskId); |
| 135 | status.mutable_slave_id()->CopyFrom(slaveId); |
| 136 | status.set_state(TASK_STAGING); // Dummy value. |
| 137 | |
| 138 | driver.reconcileTasks({status}); |
| 139 |
nothing calls this directly
no test coverage detected