Refactored some Docker tests to be more generic.

Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b5727ce5
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b5727ce5
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b5727ce5

Branch: refs/heads/master
Commit: b5727ce526f2e87fc82d3dacce6a56a1e744369c
Parents: 2f2cf5b
Author: Benjamin Hindman <[email protected]>
Authored: Wed Jul 9 13:53:05 2014 -0700
Committer: Benjamin Hindman <[email protected]>
Committed: Mon Aug 4 15:08:17 2014 -0700

----------------------------------------------------------------------
 src/tests/docker_containerizer_tests.cpp | 34 +++++++++++++++++++--------
 1 file changed, 24 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b5727ce5/src/tests/docker_containerizer_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/docker_containerizer_tests.cpp 
b/src/tests/docker_containerizer_tests.cpp
index 3d02e62..c3eee4d 100644
--- a/src/tests/docker_containerizer_tests.cpp
+++ b/src/tests/docker_containerizer_tests.cpp
@@ -405,19 +405,33 @@ TEST_F(DockerContainerizerTest, DOCKER_Update)
 
   AWAIT_READY(update);
 
-  string id = path::join("docker", container.get().id());
+  Result<string> cpuHierarchy = cgroups::hierarchy("cpu");
+  Result<string> memoryHierarchy = cgroups::hierarchy("memory");
 
-  Try<Bytes> mem =
-    cgroups::memory::soft_limit_in_bytes(
-        path::join(flags.cgroups_hierarchy, "memory"), id);
-  ASSERT_SOME(mem);
+  ASSERT_SOME(cpuHierarchy);
+  ASSERT_SOME(memoryHierarchy);
+
+  Option<pid_t> pid = container.get().pid();
+  ASSERT_SOME(pid);
+
+  Result<string> cpuCgroup = cgroups::cpu::cgroup(pid.get());
+  ASSERT_SOME(cpuCgroup);
+
+  Result<string> memoryCgroup = cgroups::memory::cgroup(pid.get());
+  ASSERT_SOME(memoryCgroup);
 
-  Try<uint64_t> cpu =
-    cgroups::cpu::shares(
-        path::join(flags.cgroups_hierarchy, "cpu"), id);
+  Try<uint64_t> cpu = cgroups::cpu::shares(
+      cpuHierarchy.get(),
+      cpuCgroup.get());
 
   ASSERT_SOME(cpu);
 
+  Try<Bytes> mem = cgroups::memory::soft_limit_in_bytes(
+      memoryHierarchy.get(),
+      memoryCgroup.get());
+
+  ASSERT_SOME(mem);
+
   EXPECT_EQ(1024u, cpu.get());
   EXPECT_EQ(128u, mem.get().megabytes());
 
@@ -481,7 +495,7 @@ TEST_F(DockerContainerizerTest, DOCKER_Recover)
 
   Try<process::Subprocess> wait =
     process::subprocess(
-        "docker wait " +
+        tests::flags.docker + " wait " +
         slave::DOCKER_NAME_PREFIX +
         stringify(containerId));
 
@@ -489,7 +503,7 @@ TEST_F(DockerContainerizerTest, DOCKER_Recover)
 
   Try<process::Subprocess> reaped =
     process::subprocess(
-        "docker wait " +
+        tests::flags.docker + " wait " +
         slave::DOCKER_NAME_PREFIX +
         stringify(reapedContainerId));
 

Reply via email to