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

Function TEST_F

src/tests/containerizer/cgroups_isolator_tests.cpp:116–269  ·  view source on GitHub ↗

This test starts the agent with cgroups isolation and launches a task with an unprivileged user. Then verifies that the unprivileged user has write permission under the corresponding cgroups which are prepared for the container to run the task.

Source from the content-addressed store, hash-verified

114// user has write permission under the corresponding cgroups which are
115// prepared for the container to run the task.
116TEST_F(CgroupsIsolatorTest,
117 ROOT_CGROUPS_PERF_NET_CLS_UNPRIVILEGED_USER_UserCgroup)
118{
119 Try<Owned<cluster::Master>> master = StartMaster();
120 ASSERT_SOME(master);
121
122 const string registry = path::join(os::getcwd(), "registry");
123
124 Future<Nothing> testImage = DockerArchive::create(registry, "alpine");
125 AWAIT_READY(testImage);
126
127 ASSERT_TRUE(os::exists(path::join(registry, "alpine.tar")));
128
129 slave::Flags flags = CreateSlaveFlags();
130 flags.docker_registry = registry;
131 flags.docker_store_dir = path::join(os::getcwd(), "store");
132 flags.image_providers = "docker";
133 flags.perf_events = "cpu-cycles"; // Needed for `PerfEventSubsystem`.
134 flags.isolation =
135 "cgroups/cpu,"
136 "cgroups/devices,"
137 "cgroups/mem,"
138 "cgroups/net_cls,"
139 "cgroups/perf_event,"
140 "docker/runtime,"
141 "filesystem/linux";
142
143 Fetcher fetcher(flags);
144
145 Try<MesosContainerizer*> _containerizer =
146 MesosContainerizer::create(flags, true, &fetcher);
147
148 ASSERT_SOME(_containerizer);
149
150 Owned<MesosContainerizer> containerizer(_containerizer.get());
151
152 Owned<MasterDetector> detector = master.get()->createDetector();
153
154 Try<Owned<cluster::Slave>> slave = StartSlave(
155 detector.get(),
156 containerizer.get());
157
158 ASSERT_SOME(slave);
159
160 MockScheduler sched;
161
162 MesosSchedulerDriver driver(
163 &sched,
164 DEFAULT_FRAMEWORK_INFO,
165 master.get()->pid,
166 DEFAULT_CREDENTIAL);
167
168 EXPECT_CALL(sched, registered(&driver, _, _));
169
170 Future<vector<Offer>> offers;
171 EXPECT_CALL(sched, resourceOffers(&driver, _))
172 .WillOnce(FutureArg<1>(&offers))
173 .WillRepeatedly(Return()); // Ignore subsequent offers.

Callers

nothing calls this directly

Calls 15

SecondsClass · 0.85
allocatedResourcesFunction · 0.85
sharesFunction · 0.85
MegabytesFunction · 0.85
cfs_quota_usFunction · 0.85
soft_limit_in_bytesFunction · 0.85
limit_in_bytesFunction · 0.85
formatFunction · 0.85
trimFunction · 0.85
NoneClass · 0.85
randomFunction · 0.85
createExecutorInfoFunction · 0.85

Tested by

no test coverage detected