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

Function TEST_P

src/tests/disk_quota_tests.cpp:210–308  ·  view source on GitHub ↗

This test verifies that the container will be killed if the disk usage exceeds its quota.

Source from the content-addressed store, hash-verified

208// This test verifies that the container will be killed if the disk
209// usage exceeds its quota.
210TEST_P(DiskQuotaEnforcement, DiskUsageExceedsQuota)
211{
212 // NOTE: We don't use the "ROOT_" tag on the test because that
213 // would require the SANDBOX tests to be run as root as well.
214 // If we did that, then we would lose disk isolator test coverage
215 // in the default CI configuration.
216 if (GetParam() == ParamDiskQuota::ROOTFS && ::geteuid() != 0) {
217 return;
218 }
219
220 Try<Owned<cluster::Master>> master = StartMaster();
221 ASSERT_SOME(master);
222
223 slave::Flags flags = CreateSlaveFlags();
224 flags.isolation = "posix/cpu,posix/mem,disk/du";
225
226 // NOTE: We can't pause the clock because we need the reaper to reap
227 // the 'du' subprocess.
228 flags.container_disk_watch_interval = Milliseconds(1);
229 flags.enforce_container_disk_quota = true;
230
231 if (GetParam() == ParamDiskQuota::ROOTFS) {
232 flags.isolation += ",filesystem/linux,docker/runtime";
233
234 flags.docker_registry = path::join(sandbox.get(), "registry");
235 flags.docker_store_dir = path::join(sandbox.get(), "store");
236 flags.image_providers = "docker";
237 flags.image_provisioner_backend = "overlay";
238
239 AWAIT_READY(CreateDockerImage(flags.docker_registry, "test_image"));
240 }
241
242 Owned<MasterDetector> detector = master.get()->createDetector();
243 Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), flags);
244 ASSERT_SOME(slave);
245
246 MockScheduler sched;
247 MesosSchedulerDriver driver(
248 &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
249
250 EXPECT_CALL(sched, registered(&driver, _, _));
251
252 Future<vector<Offer>> offers;
253 EXPECT_CALL(sched, resourceOffers(&driver, _))
254 .WillOnce(FutureArg<1>(&offers))
255 .WillRepeatedly(Return()); // Ignore subsequent offers.
256
257 driver.start();
258
259 AWAIT_READY(offers);
260 ASSERT_FALSE(offers->empty());
261
262 const Offer& offer = offers.get()[0];
263
264 TaskInfo task;
265
266 // Create a task which requests 1MB disk, but actually uses more
267 // than 2MB disk.

Callers

nothing calls this directly

Calls 15

MillisecondsClass · 0.85
createContainerInfoFunction · 0.85
MegabytesFunction · 0.85
BytesClass · 0.85
SecondsClass · 0.85
formatFunction · 0.85
createPersistentVolumeFunction · 0.85
NoneClass · 0.85
createDiskResourceFunction · 0.85
KilobytesFunction · 0.85
createDetectorMethod · 0.80
CopyFromMethod · 0.80

Tested by

no test coverage detected