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

Function TEST_F

src/tests/slave_tests.cpp:206–254  ·  view source on GitHub ↗

This test ensures that when a slave shuts itself down, it unregisters itself and the master notifies the framework immediately and rescinds any offers.

Source from the content-addressed store, hash-verified

204// unregisters itself and the master notifies the framework
205// immediately and rescinds any offers.
206TEST_F(SlaveTest, Shutdown)
207{
208 Try<Owned<cluster::Master>> master = StartMaster();
209 ASSERT_SOME(master);
210
211 Owned<MasterDetector> detector = master.get()->createDetector();
212 Try<Owned<cluster::Slave>> slave = StartSlave(detector.get());
213 ASSERT_SOME(slave);
214
215 MockScheduler sched;
216 MesosSchedulerDriver driver(
217 &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
218
219 EXPECT_CALL(sched, registered(&driver, _, _));
220
221 Future<vector<Offer>> offers;
222 EXPECT_CALL(sched, resourceOffers(&driver, _))
223 .WillOnce(FutureArg<1>(&offers))
224 .WillRepeatedly(Return()); // Ignore subsequent offers.
225
226 driver.start();
227
228 AWAIT_READY(offers);
229 EXPECT_EQ(1u, offers->size());
230
231 Future<Nothing> offerRescinded;
232 EXPECT_CALL(sched, offerRescinded(&driver, offers.get()[0].id()))
233 .WillOnce(FutureSatisfy(&offerRescinded));
234
235 Future<Nothing> slaveLost;
236 EXPECT_CALL(sched, slaveLost(&driver, offers.get()[0].slave_id()))
237 .WillOnce(FutureSatisfy(&slaveLost));
238
239 // Stop the slave with explicit shutdown message so that the slave
240 // unregisters.
241 slave.get()->shutdown();
242 slave->reset();
243
244 AWAIT_READY(offerRescinded);
245 AWAIT_READY(slaveLost);
246
247 JSON::Object stats = Metrics();
248 EXPECT_EQ(1, stats.values["master/slave_removals"]);
249 EXPECT_EQ(1, stats.values["master/slave_removals/reason_unregistered"]);
250 EXPECT_EQ(0, stats.values["master/slave_removals/reason_unhealthy"]);
251
252 driver.stop();
253 driver.join();
254}
255
256
257// This test verifies that the slave rejects duplicate terminal

Callers

nothing calls this directly

Calls 15

FutureSatisfyFunction · 0.85
shutdownFunction · 0.85
chmodFunction · 0.85
SecondsClass · 0.85
MAX_REAP_INTERVALFunction · 0.85
NoneClass · 0.85
createLabelFunction · 0.85
getuidFunction · 0.85
randomFunction · 0.85
FailureClass · 0.85
createBasicAuthHeadersFunction · 0.85
OKClass · 0.85

Tested by

no test coverage detected