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

Function TEST_P

src/tests/master_draining_tests.cpp:174–232  ·  view source on GitHub ↗

When an operator submits a DRAIN_AGENT call, the agent with nothing running should be immediately transitioned to the DRAINED state.

Source from the content-addressed store, hash-verified

172// When an operator submits a DRAIN_AGENT call, the agent with nothing running
173// should be immediately transitioned to the DRAINED state.
174TEST_P(MasterAlreadyDrainedTest, DrainAgent)
175{
176 Future<Nothing> registrarApplyDrained;
177 EXPECT_CALL(*master->registrar, apply(_))
178 .WillOnce(DoDefault())
179 .WillOnce(DoAll(
180 FutureSatisfy(&registrarApplyDrained),
181 Invoke(master->registrar.get(), &MockRegistrar::unmocked_apply)));
182
183 ContentType contentType = GetParam();
184
185 {
186 v1::master::Call::DrainAgent drainAgent;
187 drainAgent.mutable_agent_id()->CopyFrom(agentId);
188 drainAgent.mutable_max_grace_period()->set_seconds(10);
189
190 v1::master::Call call;
191 call.set_type(v1::master::Call::DRAIN_AGENT);
192 call.mutable_drain_agent()->CopyFrom(drainAgent);
193
194 AWAIT_EXPECT_RESPONSE_STATUS_EQ(
195 http::OK().status,
196 post(master->pid, call, contentType));
197 }
198
199 AWAIT_READY(registrarApplyDrained);
200
201 mesos::v1::DrainInfo drainInfo;
202 drainInfo.set_state(mesos::v1::DRAINED);
203 drainInfo.mutable_config()->set_mark_gone(false);
204 drainInfo.mutable_config()->mutable_max_grace_period()
205 ->set_nanoseconds(Seconds(10).ns());
206
207 // Ensure that the agent's drain info is reflected in the master's
208 // GET_AGENTS response.
209 {
210 v1::master::Call call;
211 call.set_type(v1::master::Call::GET_AGENTS);
212
213 Future<http::Response> response =
214 post(master->pid, call, contentType);
215 AWAIT_ASSERT_RESPONSE_STATUS_EQ(http::OK().status, response);
216
217 Try<v1::master::Response> getAgents =
218 deserialize<v1::master::Response>(contentType, response->body);
219 ASSERT_SOME(getAgents);
220
221 ASSERT_EQ(v1::master::Response::GET_AGENTS, getAgents->type());
222 ASSERT_EQ(getAgents->get_agents().agents_size(), 1);
223
224 const v1::master::Response::GetAgents::Agent& agent =
225 getAgents->get_agents().agents(0);
226
227 EXPECT_EQ(agent.deactivated(), true);
228
229 EXPECT_EQ(agent.drain_info(), drainInfo);
230 EXPECT_LT(0, agent.estimated_drain_start_time().nanoseconds());
231 }

Callers

nothing calls this directly

Calls 15

FutureSatisfyFunction · 0.85
InvokeClass · 0.85
OKClass · 0.85
SecondsClass · 0.85
createCallAcceptFunction · 0.85
NoneClass · 0.85
createBasicAuthHeadersFunction · 0.85
protobufFunction · 0.85
SlaveOptionsClass · 0.85
generateFunction · 0.85
NothingClass · 0.85
BadRequestClass · 0.85

Tested by

no test coverage detected