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

Function TEST_F

src/tests/master_tests.cpp:147–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145
146
147TEST_F(MasterTest, TaskRunning)
148{
149 Try<Owned<cluster::Master>> master = StartMaster();
150 ASSERT_SOME(master);
151
152 MockExecutor exec(DEFAULT_EXECUTOR_ID);
153 TestContainerizer containerizer(&exec);
154
155 Owned<MasterDetector> detector = master.get()->createDetector();
156 Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), &containerizer);
157 ASSERT_SOME(slave);
158
159 MockScheduler sched;
160 MesosSchedulerDriver driver(
161 &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
162
163 EXPECT_CALL(sched, registered(&driver, _, _));
164
165 Future<vector<Offer>> offers;
166 EXPECT_CALL(sched, resourceOffers(&driver, _))
167 .WillOnce(FutureArg<1>(&offers))
168 .WillRepeatedly(Return()); // Ignore subsequent offers.
169
170 driver.start();
171
172 AWAIT_READY(offers);
173 ASSERT_FALSE(offers->empty());
174
175 // Ensure the hostname and url are set correctly.
176 EXPECT_EQ(
177 slave.get()->pid.address.lookup_hostname().get(),
178 offers.get()[0].hostname());
179
180 mesos::URL url;
181 url.set_scheme("http");
182 url.mutable_address()->set_ip(stringify(slave.get()->pid.address.ip));
183 url.mutable_address()->set_hostname(
184 slave.get()->pid.address.lookup_hostname().get());
185
186 url.mutable_address()->set_port(slave.get()->pid.address.port);
187 url.set_path("/" + slave.get()->pid.id);
188
189 EXPECT_EQ(url, offers.get()[0].url());
190
191 TaskInfo task;
192 task.set_name("");
193 task.mutable_task_id()->set_value("1");
194 task.mutable_slave_id()->MergeFrom(offers.get()[0].slave_id());
195 task.mutable_resources()->MergeFrom(offers.get()[0].resources());
196 task.mutable_executor()->MergeFrom(DEFAULT_EXECUTOR_INFO);
197
198 EXPECT_CALL(exec, registered(_, _, _, _));
199
200 EXPECT_CALL(exec, launchTask(_, _))
201 .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING));
202
203 Future<Nothing> update;
204 EXPECT_CALL(containerizer,

Callers

nothing calls this directly

Calls 15

FutureSatisfyFunction · 0.85
NothingClass · 0.85
shutdownFunction · 0.85
NoneClass · 0.85
createBasicAuthHeadersFunction · 0.85
OKClass · 0.85
StringClass · 0.85
getFrameworkMetricPrefixFunction · 0.85
createDomainInfoFunction · 0.85
allocatedResourcesFunction · 0.85
createExecutorInfoFunction · 0.85
MegabytesFunction · 0.85

Tested by

no test coverage detected