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

Function TEST_P

src/tests/command_executor_tests.cpp:92–154  ·  view source on GitHub ↗

This test ensures that the command executor does not send TASK_KILLING to frameworks that do not support the capability.

Source from the content-addressed store, hash-verified

90// This test ensures that the command executor does not send
91// TASK_KILLING to frameworks that do not support the capability.
92TEST_P(CommandExecutorTest, NoTaskKillingCapability)
93{
94 Try<Owned<cluster::Master>> master = StartMaster();
95 ASSERT_SOME(master);
96
97 Owned<MasterDetector> detector = master.get()->createDetector();
98
99 slave::Flags flags = CreateSlaveFlags();
100 flags.http_command_executor = GetParam();
101
102 Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), flags);
103 ASSERT_SOME(slave);
104
105 // Start the framework without the task killing capability.
106 MockScheduler sched;
107 MesosSchedulerDriver driver(
108 &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
109
110 EXPECT_CALL(sched, registered(&driver, _, _));
111
112 Future<vector<Offer>> offers;
113 EXPECT_CALL(sched, resourceOffers(&driver, _))
114 .WillOnce(FutureArg<1>(&offers))
115 .WillRepeatedly(Return()); // Ignore subsequent offers.
116
117 driver.start();
118
119 AWAIT_READY(offers);
120 EXPECT_EQ(1u, offers->size());
121
122 // Launch a task with the command executor.
123 TaskInfo task = createTask(
124 offers->front().slave_id(),
125 offers->front().resources(),
126 SLEEP_COMMAND(1000));
127
128 Future<TaskStatus> statusStarting;
129 Future<TaskStatus> statusRunning;
130 EXPECT_CALL(sched, statusUpdate(_, _))
131 .WillOnce(FutureArg<1>(&statusStarting))
132 .WillOnce(FutureArg<1>(&statusRunning));
133
134 driver.launchTasks(offers->front().id(), {task});
135
136 AWAIT_READY(statusStarting);
137 EXPECT_EQ(TASK_STARTING, statusStarting->state());
138
139 AWAIT_READY(statusRunning);
140 EXPECT_EQ(TASK_RUNNING, statusRunning->state());
141
142 // There should only be a TASK_KILLED update.
143 Future<TaskStatus> statusKilled;
144 EXPECT_CALL(sched, statusUpdate(_, _))
145 .WillOnce(FutureArg<1>(&statusKilled));
146
147 driver.killTask(task.task_id());
148
149 AWAIT_READY(statusKilled);

Callers

nothing calls this directly

Calls 15

SecondsClass · 0.85
formatFunction · 0.85
getTestHelperPathFunction · 0.85
StringClass · 0.85
createDetectorMethod · 0.80
CopyFromMethod · 0.80
nsMethod · 0.80
getOrElseMethod · 0.80
createTaskFunction · 0.70
startMethod · 0.65
launchTasksMethod · 0.65
killTaskMethod · 0.65

Tested by

no test coverage detected