Repository: mesos Updated Branches: refs/heads/master 7aafb8e44 -> 2c1808685
Added a unit-test to test net_cls primary handles set from command line. Review: https://reviews.apache.org/r/42782/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2c180868 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2c180868 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2c180868 Branch: refs/heads/master Commit: 2c1808685aa1ef408455e34af5c4540cf873a5e1 Parents: 7aafb8e Author: Avinash sridharan <[email protected]> Authored: Mon Feb 8 13:43:23 2016 -0800 Committer: Jie Yu <[email protected]> Committed: Mon Feb 8 15:01:38 2016 -0800 ---------------------------------------------------------------------- src/tests/containerizer/isolator_tests.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/2c180868/src/tests/containerizer/isolator_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/containerizer/isolator_tests.cpp b/src/tests/containerizer/isolator_tests.cpp index 84fe4fb..c20f33e 100644 --- a/src/tests/containerizer/isolator_tests.cpp +++ b/src/tests/containerizer/isolator_tests.cpp @@ -914,8 +914,11 @@ TEST_F(NetClsIsolatorTest, ROOT_CGROUPS_NetClsIsolate) Try<PID<Master>> master = StartMaster(); ASSERT_SOME(master); + uint16_t primary = 0x0012; + slave::Flags flags = CreateSlaveFlags(); flags.isolation = "cgroups/net_cls"; + flags.cgroups_net_cls_primary_handle = stringify(primary); Fetcher fetcher; @@ -984,6 +987,19 @@ TEST_F(NetClsIsolatorTest, ROOT_CGROUPS_NetClsIsolate) // There should be at least one TGID associated with this cgroup. EXPECT_LE(1u, pids.get().size()); + // Read the `net_cls.classid` to verify that the handle has been set. + Try<uint32_t> classid = cgroups::net_cls::classid(hierarchy.get(), cgroup); + EXPECT_SOME(classid); + + if (classid.isSome()) { + // Make sure the primary handle is the same as the one set in + // `--cgroup_net_cls_primary_handle`. + EXPECT_EQ(primary, (classid.get() & 0xffff0000) >> 16); + + // Make sure the secondary handle is non-zero. + EXPECT_NE(0, classid.get() & 0xffff); + } + // Isolator cleanup test: Killing the task should cleanup the cgroup // associated with the container. Future<TaskStatus> killStatus;
