You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2015/09/01 04:26:59 UTC

[1/6] mesos git commit: Removed std:: qualifiers in cgroups_tests.cpp.

Repository: mesos
Updated Branches:
  refs/heads/master f54fa513d -> 7e8370cdc


Removed std:: qualifiers in cgroups_tests.cpp.


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

Branch: refs/heads/master
Commit: 122fe2e8723b47024b964dada02a40d3703481ea
Parents: f54fa51
Author: Paul Brett <pa...@twopensource.com>
Authored: Mon Aug 31 18:41:26 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Aug 31 18:41:26 2015 -0700

----------------------------------------------------------------------
 src/tests/containerizer/cgroups_tests.cpp | 113 +++++++++++++------------
 1 file changed, 57 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/122fe2e8/src/tests/containerizer/cgroups_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/cgroups_tests.cpp b/src/tests/containerizer/cgroups_tests.cpp
index 0b171ee..7a0aaf3 100644
--- a/src/tests/containerizer/cgroups_tests.cpp
+++ b/src/tests/containerizer/cgroups_tests.cpp
@@ -64,6 +64,7 @@ using cgroups::memory::pressure::Level;
 using cgroups::memory::pressure::Counter;
 
 using std::set;
+using std::string;
 
 namespace mesos {
 namespace internal {
@@ -98,7 +99,7 @@ public:
   {
     CgroupsTest::SetUpTestCase();
 
-    Try<std::set<std::string> > hierarchies = cgroups::hierarchies();
+    Try<set<string> > hierarchies = cgroups::hierarchies();
     ASSERT_SOME(hierarchies);
     ASSERT_TRUE(hierarchies.get().empty())
       << "-------------------------------------------------------------\n"
@@ -119,7 +120,7 @@ public:
 class CgroupsAnyHierarchyTest : public CgroupsTest
 {
 public:
-  CgroupsAnyHierarchyTest(const std::string& _subsystems = "cpu")
+  CgroupsAnyHierarchyTest(const string& _subsystems = "cpu")
     : subsystems(_subsystems) {}
 
 protected:
@@ -127,24 +128,24 @@ protected:
   {
     CgroupsTest::SetUp();
 
-    foreach (const std::string& subsystem, strings::tokenize(subsystems, ",")) {
+    foreach (const string& subsystem, strings::tokenize(subsystems, ",")) {
       // Establish the base hierarchy if this is the first subsystem checked.
       if (baseHierarchy.empty()) {
-        Result<std::string> hierarchy = cgroups::hierarchy(subsystem);
+        Result<string> hierarchy = cgroups::hierarchy(subsystem);
         ASSERT_FALSE(hierarchy.isError());
 
         if (hierarchy.isNone()) {
           baseHierarchy = TEST_CGROUPS_HIERARCHY;
         } else {
           // Strip the subsystem to get the base hierarchy.
-          Try<std::string> baseDirname = Path(hierarchy.get()).dirname();
+          Try<string> baseDirname = Path(hierarchy.get()).dirname();
           ASSERT_SOME(baseDirname);
           baseHierarchy = baseDirname.get();
         }
       }
 
       // Mount the subsystem if necessary.
-      std::string hierarchy = path::join(baseHierarchy, subsystem);
+      string hierarchy = path::join(baseHierarchy, subsystem);
       Try<bool> mounted = cgroups::mounted(hierarchy, subsystem);
       ASSERT_SOME(mounted);
       if (!mounted.get()) {
@@ -163,10 +164,10 @@ protected:
           << "-------------------------------------------------------------";
       }
 
-      Try<std::vector<std::string> > cgroups = cgroups::get(hierarchy);
+      Try<std::vector<string> > cgroups = cgroups::get(hierarchy);
       CHECK_SOME(cgroups);
 
-      foreach (const std::string& cgroup, cgroups.get()) {
+      foreach (const string& cgroup, cgroups.get()) {
         // Remove any cgroups that start with TEST_CGROUPS_ROOT.
         if (cgroup == TEST_CGROUPS_ROOT) {
           AWAIT_READY(cgroups::destroy(hierarchy, cgroup));
@@ -178,13 +179,13 @@ protected:
   virtual void TearDown()
   {
     // Remove all *our* cgroups.
-    foreach (const std::string& subsystem, strings::tokenize(subsystems, ",")) {
-      std::string hierarchy = path::join(baseHierarchy, subsystem);
+    foreach (const string& subsystem, strings::tokenize(subsystems, ",")) {
+      string hierarchy = path::join(baseHierarchy, subsystem);
 
-      Try<std::vector<std::string> > cgroups = cgroups::get(hierarchy);
+      Try<std::vector<string> > cgroups = cgroups::get(hierarchy);
       CHECK_SOME(cgroups);
 
-      foreach (const std::string& cgroup, cgroups.get()) {
+      foreach (const string& cgroup, cgroups.get()) {
         // Remove any cgroups that start with TEST_CGROUPS_ROOT.
         if (cgroup == TEST_CGROUPS_ROOT) {
           AWAIT_READY(cgroups::destroy(hierarchy, cgroup));
@@ -195,8 +196,8 @@ protected:
     CgroupsTest::TearDown();
   }
 
-  const std::string subsystems; // Subsystems required to run tests.
-  std::string baseHierarchy; // Path to the hierarchy being used.
+  const string subsystems; // Subsystems required to run tests.
+  string baseHierarchy; // Path to the hierarchy being used.
 };
 
 
@@ -246,12 +247,12 @@ TEST_F(CgroupsAnyHierarchyWithCpuMemoryTest, ROOT_CGROUPS_Busy)
 
 TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Subsystems)
 {
-  Try<std::set<std::string> > names = cgroups::subsystems();
+  Try<set<string> > names = cgroups::subsystems();
   ASSERT_SOME(names);
 
-  Option<std::string> cpu;
-  Option<std::string> memory;
-  foreach (const std::string& name, names.get()) {
+  Option<string> cpu;
+  Option<string> memory;
+  foreach (const string& name, names.get()) {
     if (name == "cpu") {
       cpu = name;
     } else if (name == "memory") {
@@ -266,14 +267,14 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Subsystems)
 
 TEST_F(CgroupsAnyHierarchyWithCpuMemoryTest, ROOT_CGROUPS_SubsystemsHierarchy)
 {
-  std::string cpuHierarchy = path::join(baseHierarchy, "cpu");
+  string cpuHierarchy = path::join(baseHierarchy, "cpu");
 
-  Try<std::set<std::string> > names = cgroups::subsystems(cpuHierarchy);
+  Try<set<string> > names = cgroups::subsystems(cpuHierarchy);
   ASSERT_SOME(names);
 
-  Option<std::string> cpu;
-  Option<std::string> memory;
-  foreach (const std::string& name, names.get()) {
+  Option<string> cpu;
+  Option<string> memory;
+  foreach (const string& name, names.get()) {
     if (name == "cpu") {
       cpu = name;
     } else if (name == "memory") {
@@ -284,13 +285,13 @@ TEST_F(CgroupsAnyHierarchyWithCpuMemoryTest, ROOT_CGROUPS_SubsystemsHierarchy)
   EXPECT_SOME(cpu);
   EXPECT_NONE(memory);
 
-  std::string memoryHierarchy = path::join(baseHierarchy, "memory");
+  string memoryHierarchy = path::join(baseHierarchy, "memory");
   names = cgroups::subsystems(memoryHierarchy);
   ASSERT_SOME(names);
 
   cpu = None();
   memory = None();
-  foreach (const std::string& name, names.get()) {
+  foreach (const string& name, names.get()) {
     if (name == "cpu") {
       cpu = name;
     } else if (name == "memory") {
@@ -305,11 +306,11 @@ TEST_F(CgroupsAnyHierarchyWithCpuMemoryTest, ROOT_CGROUPS_SubsystemsHierarchy)
 TEST_F(CgroupsAnyHierarchyWithCpuMemoryTest, ROOT_CGROUPS_FindCgroupSubsystems)
 {
   pid_t pid = ::getpid();
-  Result<std::string> cpuHierarchy = cgroups::cpu::cgroup(pid);
+  Result<string> cpuHierarchy = cgroups::cpu::cgroup(pid);
   EXPECT_FALSE(cpuHierarchy.isError());
   EXPECT_SOME(cpuHierarchy);
 
-  Result<std::string> memHierarchy = cgroups::memory::cgroup(pid);
+  Result<string> memHierarchy = cgroups::memory::cgroup(pid);
   EXPECT_FALSE(memHierarchy.isError());
   EXPECT_SOME(memHierarchy);
 }
@@ -367,12 +368,12 @@ TEST_F(CgroupsAnyHierarchyWithCpuMemoryTest, ROOT_CGROUPS_CreateRemove)
 
 TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Get)
 {
-  std::string hierarchy = path::join(baseHierarchy, "cpu");
+  string hierarchy = path::join(baseHierarchy, "cpu");
 
   ASSERT_SOME(cgroups::create(hierarchy, "mesos_test1"));
   ASSERT_SOME(cgroups::create(hierarchy, "mesos_test2"));
 
-  Try<std::vector<std::string>> cgroups = cgroups::get(hierarchy);
+  Try<std::vector<string>> cgroups = cgroups::get(hierarchy);
   ASSERT_SOME(cgroups);
 
   EXPECT_NE(cgroups.get().end(),
@@ -387,10 +388,10 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Get)
 
 TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_NestedCgroups)
 {
-  std::string hierarchy = path::join(baseHierarchy, "cpu");
+  string hierarchy = path::join(baseHierarchy, "cpu");
   ASSERT_SOME(cgroups::create(hierarchy, TEST_CGROUPS_ROOT));
-  std::string cgroup1 = path::join(TEST_CGROUPS_ROOT, "1");
-  std::string cgroup2 = path::join(TEST_CGROUPS_ROOT, "2");
+  string cgroup1 = path::join(TEST_CGROUPS_ROOT, "1");
+  string cgroup2 = path::join(TEST_CGROUPS_ROOT, "2");
 
   ASSERT_SOME(cgroups::create(hierarchy, cgroup1))
     << "-------------------------------------------------------------\n"
@@ -402,7 +403,7 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_NestedCgroups)
 
   ASSERT_SOME(cgroups::create(hierarchy, cgroup2));
 
-  Try<std::vector<std::string>> cgroups =
+  Try<std::vector<string>> cgroups =
     cgroups::get(hierarchy, TEST_CGROUPS_ROOT);
   ASSERT_SOME(cgroups);
 
@@ -422,12 +423,12 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Tasks)
 {
   pid_t pid = ::getpid();
 
-  Result<std::string> cgroup = cgroups::cpu::cgroup(pid);
+  Result<string> cgroup = cgroups::cpu::cgroup(pid);
   ASSERT_SOME(cgroup);
 
-  std::string hierarchy = path::join(baseHierarchy, "cpu");
+  string hierarchy = path::join(baseHierarchy, "cpu");
 
-  Try<std::set<pid_t>> pids = cgroups::processes(hierarchy, cgroup.get());
+  Try<set<pid_t>> pids = cgroups::processes(hierarchy, cgroup.get());
   ASSERT_SOME(pids);
 
   EXPECT_NE(0u, pids.get().count(pid));
@@ -436,16 +437,16 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Tasks)
 
 TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Read)
 {
-  std::string hierarchy = path::join(baseHierarchy, "cpu");
+  string hierarchy = path::join(baseHierarchy, "cpu");
 
   EXPECT_ERROR(cgroups::read(hierarchy, TEST_CGROUPS_ROOT, "invalid42"));
 
   pid_t pid = ::getpid();
 
-  Result<std::string> cgroup = cgroups::cpu::cgroup(pid);
+  Result<string> cgroup = cgroups::cpu::cgroup(pid);
   ASSERT_SOME(cgroup);
 
-  Try<std::string> read = cgroups::read(hierarchy, cgroup.get(), "tasks");
+  Try<string> read = cgroups::read(hierarchy, cgroup.get(), "tasks");
   ASSERT_SOME(read);
 
   EXPECT_TRUE(strings::contains(read.get(), stringify(pid)));
@@ -454,7 +455,7 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Read)
 
 TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Write)
 {
-  std::string hierarchy = path::join(baseHierarchy, "cpu");
+  string hierarchy = path::join(baseHierarchy, "cpu");
   EXPECT_ERROR(
       cgroups::write(hierarchy, TEST_CGROUPS_ROOT, "invalid", "invalid"));
 
@@ -482,7 +483,7 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Write)
                      "cgroup.procs",
                      stringify(pid)));
 
-  Try<std::set<pid_t> > pids = cgroups::processes(hierarchy, TEST_CGROUPS_ROOT);
+  Try<set<pid_t> > pids = cgroups::processes(hierarchy, TEST_CGROUPS_ROOT);
   ASSERT_SOME(pids);
 
   EXPECT_NE(0u, pids.get().count(pid));
@@ -500,7 +501,7 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Write)
 
 TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Cfs_Big_Quota)
 {
-  std::string hierarchy = path::join(baseHierarchy, "cpu");
+  string hierarchy = path::join(baseHierarchy, "cpu");
   ASSERT_SOME(cgroups::create(hierarchy, TEST_CGROUPS_ROOT));
 
   Duration quota = Seconds(100); // Big quota.
@@ -526,7 +527,7 @@ TEST_F(CgroupsAnyHierarchyWithCpuAcctMemoryTest, ROOT_CGROUPS_Stat)
 {
   EXPECT_ERROR(cgroups::stat(baseHierarchy, TEST_CGROUPS_ROOT, "invalid"));
 
-  Try<hashmap<std::string, uint64_t> > result =
+  Try<hashmap<string, uint64_t> > result =
     cgroups::stat(
         path::join(baseHierarchy, "cpuacct"), "/", "cpuacct.stat");
   ASSERT_SOME(result);
@@ -545,7 +546,7 @@ TEST_F(CgroupsAnyHierarchyWithCpuAcctMemoryTest, ROOT_CGROUPS_Stat)
 
 TEST_F(CgroupsAnyHierarchyWithCpuMemoryTest, ROOT_CGROUPS_Listen)
 {
-  std::string hierarchy = path::join(baseHierarchy, "memory");
+  string hierarchy = path::join(baseHierarchy, "memory");
   ASSERT_SOME(cgroups::create(hierarchy, TEST_CGROUPS_ROOT));
   ASSERT_SOME(
       cgroups::memory::oom::killer::enabled(hierarchy, TEST_CGROUPS_ROOT))
@@ -598,7 +599,7 @@ TEST_F(CgroupsAnyHierarchyWithFreezerTest, ROOT_CGROUPS_Freeze)
   int dummy;
   ASSERT_NE(-1, ::pipe(pipes));
 
-  std::string hierarchy = path::join(baseHierarchy, "freezer");
+  string hierarchy = path::join(baseHierarchy, "freezer");
   ASSERT_SOME(cgroups::create(hierarchy, TEST_CGROUPS_ROOT));
 
   pid_t pid = ::fork();
@@ -658,7 +659,7 @@ TEST_F(CgroupsAnyHierarchyWithFreezerTest, ROOT_CGROUPS_Freeze)
 
 TEST_F(CgroupsAnyHierarchyWithCpuMemoryTest, ROOT_CGROUPS_FreezeNonFreezer)
 {
-  std::string hierarchy = path::join(baseHierarchy, "cpu");
+  string hierarchy = path::join(baseHierarchy, "cpu");
   ASSERT_SOME(cgroups::create(hierarchy, TEST_CGROUPS_ROOT));
 
   AWAIT_EXPECT_FAILED(cgroups::freezer::freeze(hierarchy, TEST_CGROUPS_ROOT));
@@ -675,7 +676,7 @@ TEST_F(CgroupsAnyHierarchyWithFreezerTest, ROOT_CGROUPS_Kill)
   int dummy;
   ASSERT_NE(-1, ::pipe(pipes));
 
-  std::string hierarchy = path::join(baseHierarchy, "freezer");
+  string hierarchy = path::join(baseHierarchy, "freezer");
   ASSERT_SOME(cgroups::create(hierarchy, TEST_CGROUPS_ROOT));
 
   pid_t pid = ::fork();
@@ -741,7 +742,7 @@ TEST_F(CgroupsAnyHierarchyWithFreezerTest, ROOT_CGROUPS_Destroy)
   int dummy;
   ASSERT_NE(-1, ::pipe(pipes));
 
-  std::string hierarchy = path::join(baseHierarchy, "freezer");
+  string hierarchy = path::join(baseHierarchy, "freezer");
   ASSERT_SOME(cgroups::create(hierarchy, TEST_CGROUPS_ROOT));
 
   pid_t pid = ::fork();
@@ -816,7 +817,7 @@ TEST_F(CgroupsAnyHierarchyWithFreezerTest, ROOT_CGROUPS_AssignThreads)
     });
   }
 
-  std::string hierarchy = path::join(baseHierarchy, "freezer");
+  string hierarchy = path::join(baseHierarchy, "freezer");
   ASSERT_SOME(cgroups::create(hierarchy, TEST_CGROUPS_ROOT));
 
   // Check the test cgroup is initially empty.
@@ -858,7 +859,7 @@ TEST_F(CgroupsAnyHierarchyWithFreezerTest, ROOT_CGROUPS_AssignThreads)
 
 TEST_F(CgroupsAnyHierarchyWithFreezerTest, ROOT_CGROUPS_DestroyStoppedProcess)
 {
-  std::string hierarchy = path::join(baseHierarchy, "freezer");
+  string hierarchy = path::join(baseHierarchy, "freezer");
   ASSERT_SOME(cgroups::create(hierarchy, TEST_CGROUPS_ROOT));
 
   pid_t pid = ::fork();
@@ -891,7 +892,7 @@ TEST_F(CgroupsAnyHierarchyWithFreezerTest, ROOT_CGROUPS_DestroyStoppedProcess)
 
 TEST_F(CgroupsAnyHierarchyWithFreezerTest, ROOT_CGROUPS_DestroyTracedProcess)
 {
-  std::string hierarchy = path::join(baseHierarchy, "freezer");
+  string hierarchy = path::join(baseHierarchy, "freezer");
   ASSERT_SOME(cgroups::create(hierarchy, TEST_CGROUPS_ROOT));
 
   pid_t pid = ::fork();
@@ -955,7 +956,7 @@ TEST_F(CgroupsAnyHierarchyWithPerfEventTest, ROOT_CGROUPS_Perf)
   int dummy;
   ASSERT_NE(-1, ::pipe(pipes));
 
-  std::string hierarchy = path::join(baseHierarchy, "perf_event");
+  string hierarchy = path::join(baseHierarchy, "perf_event");
   ASSERT_SOME(cgroups::create(hierarchy, TEST_CGROUPS_ROOT));
 
   pid_t pid = ::fork();
@@ -991,7 +992,7 @@ TEST_F(CgroupsAnyHierarchyWithPerfEventTest, ROOT_CGROUPS_Perf)
   ASSERT_EQ((ssize_t) sizeof(dummy), len);
   ::close(pipes[1]);
 
-  std::set<std::string> events;
+  set<string> events;
   // Hardware event.
   events.insert("cycles");
   // Software event.
@@ -1063,8 +1064,8 @@ protected:
     }
   }
 
-  std::string hierarchy;
-  const std::string cgroup;
+  string hierarchy;
+  const string cgroup;
 
   hashmap<Level, Owned<Counter>> counters;
 };
@@ -1231,7 +1232,7 @@ TEST_F(CgroupsAnyHierarchyMemoryPressureTest, ROOT_IncreasePageCache)
 // the API.
 TEST_F(CgroupsAnyHierarchyWithCpuAcctMemoryTest, ROOT_CGROUPS_CpuAcctsStats)
 {
-  const std::string hierarchy = path::join(baseHierarchy, "cpuacct");
+  const string hierarchy = path::join(baseHierarchy, "cpuacct");
   ASSERT_SOME(cgroups::create(hierarchy, TEST_CGROUPS_ROOT));
 
   CHECK_SOME(cgroups::assign(hierarchy, TEST_CGROUPS_ROOT, ::getpid()));


[4/6] mesos git commit: Removed use of CHECK_SOME in perf_tests.cpp.

Posted by bm...@apache.org.
Removed use of CHECK_SOME in perf_tests.cpp.


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

Branch: refs/heads/master
Commit: ec58bdd1f575d82755fb6032b989b62ffc7d2a2c
Parents: c3fdefc
Author: Benjamin Mahler <be...@gmail.com>
Authored: Mon Aug 31 18:51:37 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Aug 31 18:56:27 2015 -0700

----------------------------------------------------------------------
 src/tests/containerizer/perf_tests.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ec58bdd1/src/tests/containerizer/perf_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/perf_tests.cpp b/src/tests/containerizer/perf_tests.cpp
index 9a0de3c..d2e3b10 100644
--- a/src/tests/containerizer/perf_tests.cpp
+++ b/src/tests/containerizer/perf_tests.cpp
@@ -63,7 +63,7 @@ TEST_F(PerfTest, Parse)
   // uint64 and floats should be parsed.
   Try<hashmap<string, mesos::PerfStatistics> > parse =
     perf::parse("123,cycles\n0.123,task-clock");
-  CHECK_SOME(parse);
+  ASSERT_SOME(parse);
 
   ASSERT_TRUE(parse->contains(""));
   mesos::PerfStatistics statistics = parse->get("").get();
@@ -78,7 +78,7 @@ TEST_F(PerfTest, Parse)
                       "456,cycles,cgroup2\n"
                       "0.456,task-clock,cgroup2\n"
                       "0.123,task-clock,cgroup1");
-  CHECK_SOME(parse);
+  ASSERT_SOME(parse);
   EXPECT_FALSE(parse->contains(""));
 
   ASSERT_TRUE(parse->contains("cgroup1"));
@@ -99,7 +99,7 @@ TEST_F(PerfTest, Parse)
 
   // Statistics reporting <not supported> should not appear.
   parse = perf::parse("<not supported>,cycles");
-  CHECK_SOME(parse);
+  ASSERT_SOME(parse);
 
   ASSERT_TRUE(parse->contains(""));
   statistics = parse->get("").get();
@@ -107,7 +107,7 @@ TEST_F(PerfTest, Parse)
 
   // Statistics reporting <not counted> should be zero.
   parse = perf::parse("<not counted>,cycles\n<not counted>,task-clock");
-  CHECK_SOME(parse);
+  ASSERT_SOME(parse);
 
   ASSERT_TRUE(parse->contains(""));
   statistics = parse->get("").get();


[6/6] mesos git commit: Used -> operator to clean up perf.cpp.

Posted by bm...@apache.org.
Used -> operator to clean up perf.cpp.


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

Branch: refs/heads/master
Commit: 7e8370cdcf7c0aff2afb295e79e153f35f6a491a
Parents: 3aecee0
Author: Benjamin Mahler <be...@gmail.com>
Authored: Mon Aug 31 18:58:57 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Aug 31 19:10:16 2015 -0700

----------------------------------------------------------------------
 src/linux/perf.cpp | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7e8370cd/src/linux/perf.cpp
----------------------------------------------------------------------
diff --git a/src/linux/perf.cpp b/src/linux/perf.cpp
index 1dda79e..dac7061 100644
--- a/src/linux/perf.cpp
+++ b/src/linux/perf.cpp
@@ -113,8 +113,8 @@ protected:
     // Kill the perf process (if it's still running) by sending
     // SIGTERM to the signal handler which will then SIGKILL the
     // perf process group created by setupChild.
-    if (perf.isSome() && perf.get().status().isPending()) {
-      kill(perf.get().pid(), SIGTERM);
+    if (perf.isSome() && perf->status().isPending()) {
+      kill(perf->pid(), SIGTERM);
     }
 
     promise.discard();
@@ -216,9 +216,9 @@ private:
     perf = _perf.get();
 
     // Wait for the process to exit.
-    await(perf.get().status(),
-          io::read(perf.get().out().get()),
-          io::read(perf.get().err().get()))
+    await(perf->status(),
+          io::read(perf->out().get()),
+          io::read(perf->err().get()))
       .onReady(defer(self(), [this](const tuple<
           Future<Option<int>>,
           Future<string>,
@@ -231,18 +231,18 @@ private:
         if (!status.isReady()) {
           error = Error("Failed to execute perf: " +
                         (status.isFailed() ? status.failure() : "discarded"));
-        } else if (status.get().isNone()) {
+        } else if (status->isNone()) {
           error = Error("Failed to execute perf: failed to reap");
-        } else if (status.get().get() != 0) {
+        } else if (status->get() != 0) {
           error = Error("Failed to execute perf: " +
-                        WSTRINGIFY(status.get().get()));
+                        WSTRINGIFY(status->get()));
         } else if (!output.isReady()) {
           error = Error("Failed to read perf output: " +
                         (output.isFailed() ? output.failure() : "discarded"));
         }
 
         if (error.isSome()) {
-          promise.fail(error.get().message);
+          promise.fail(error->message);
           terminate(self());
           return;
         }


[5/6] mesos git commit: Removed unused per-process perf sampling code for simplification.

Posted by bm...@apache.org.
Removed unused per-process perf sampling code for simplification.

Review: https://reviews.apache.org/r/37976


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

Branch: refs/heads/master
Commit: 3aecee03f72c5eb2130229ad16934c8dba8baf79
Parents: ec58bdd
Author: Paul Brett <pa...@twopensource.com>
Authored: Mon Aug 31 18:02:00 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Aug 31 19:10:15 2015 -0700

----------------------------------------------------------------------
 src/linux/perf.cpp                        | 215 ++++++-------------------
 src/linux/perf.hpp                        |  21 ---
 src/tests/containerizer/cgroups_tests.cpp |  12 +-
 src/tests/containerizer/perf_tests.cpp    |  95 ++---------
 4 files changed, 74 insertions(+), 269 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3aecee03/src/linux/perf.cpp
----------------------------------------------------------------------
diff --git a/src/linux/perf.cpp b/src/linux/perf.cpp
index 56ef391..1dda79e 100644
--- a/src/linux/perf.cpp
+++ b/src/linux/perf.cpp
@@ -61,91 +61,8 @@ namespace perf {
 // Delimiter for fields in perf stat output.
 static const char PERF_DELIMITER[] = ",";
 
-// Use an empty string as the key for the parse output when sampling a
-// set of pids. No valid cgroup can be an empty string.
-static const char PIDS_KEY[] = "";
-
 namespace internal {
 
-vector<string> argv(
-    const set<string>& events,
-    const set<string>& cgroups,
-    const Duration& duration)
-{
-  vector<string> argv = {
-    "stat",
-
-    // System-wide collection from all CPUs.
-    "--all-cpus",
-
-    // Print counts using a CSV-style output to make it easy to import
-    // directly into spreadsheets. Columns are separated by the string
-    // specified in PERF_DELIMITER.
-    "--field-separator", PERF_DELIMITER,
-
-    // Ensure all output goes to stdout.
-    "--log-fd", "1"
-  };
-
-  // Nested loop to produce all pairings of event and cgroup.
-  foreach (const string& event, events) {
-    foreach (const string& cgroup, cgroups) {
-      argv.push_back("--event");
-      argv.push_back(event);
-      argv.push_back("--cgroup");
-      argv.push_back(cgroup);
-    }
-  }
-
-  argv.push_back("--");
-  argv.push_back("sleep");
-  argv.push_back(stringify(duration.secs()));
-
-  return argv;
-}
-
-
-vector<string> argv(
-    const set<string>& events,
-    const string& cgroup,
-    const Duration& duration)
-{
-  set<string> cgroups;
-  cgroups.insert(cgroup);
-
-  return argv(events, cgroups, duration);
-}
-
-
-vector<string> argv(
-    const set<string>& events,
-    const set<pid_t>& pids,
-    const Duration& duration)
-{
-  vector<string> argv = {
-    "stat",
-
-    // System-wide collection from all CPUs.
-    "--all-cpus",
-
-    // Print counts using a CSV-style output to make it easy to import
-    // directly into spreadsheets. Columns are separated by the string
-    // specified in PERF_DELIMITER.
-    "--field-separator", PERF_DELIMITER,
-
-    // Ensure all output goes to stdout.
-    "--log-fd", "1",
-
-    "--event", strings::join(",", events),
-    "--pid", strings::join(",", pids),
-    "--",
-    "sleep", stringify(duration.secs())
-  };
-
-  return argv;
-}
-
-
 // Normalize a perf event name. After normalization the event name
 // should match an event field in the PerfStatistics protobuf.
 inline string normalize(const string& s)
@@ -341,45 +258,6 @@ private:
   Option<Subprocess> perf;
 };
 
-
-// Helper to select a single key from the hashmap of perf statistics.
-Future<mesos::PerfStatistics> select(
-    const string& key,
-    const hashmap<string, mesos::PerfStatistics>& statistics)
-{
-  return statistics.get(key).get();
-}
-
-
-Future<hashmap<string, mesos::PerfStatistics>> sample(
-    const vector<string>& argv,
-    const Duration& duration)
-{
-  Time start = Clock::now();
-
-  Perf* perf = new Perf(argv);
-  Future<string> future = perf->future();
-  spawn(perf, true);
-
-  auto parse = [start, duration](const string& output) ->
-      Future<hashmap<string, mesos::PerfStatistics>> {
-    Try<hashmap<string, mesos::PerfStatistics>> parse = perf::parse(output);
-
-    if (parse.isError()) {
-      return Failure("Failed to parse perf sample: " + parse.error());
-    }
-
-    foreachvalue (mesos::PerfStatistics& statistics, parse.get()) {
-      statistics.set_timestamp(start.secs());
-      statistics.set_duration(duration.secs());
-    }
-
-    return parse.get();
-  };
-
-  return future.then(parse);
-}
-
 } // namespace internal {
 
 
@@ -398,53 +276,67 @@ Future<Version> version()
 };
 
 
-Future<mesos::PerfStatistics> sample(
-    const set<string>& events,
-    pid_t pid,
-    const Duration& duration)
-{
-  set<pid_t> pids;
-  pids.insert(pid);
-  return sample(events, pids, duration);
-}
-
-
-Future<mesos::PerfStatistics> sample(
+Future<hashmap<string, mesos::PerfStatistics>> sample(
     const set<string>& events,
-    const set<pid_t>& pids,
+    const set<string>& cgroups,
     const Duration& duration)
 {
   if (!supported()) {
     return Failure("Perf is not supported");
   }
 
-  return internal::sample(internal::argv(events, pids, duration), duration)
-    .then(lambda::bind(&internal::select, PIDS_KEY, lambda::_1));
-}
+  vector<string> argv = {
+    "stat",
 
+    // System-wide collection from all CPUs.
+    "--all-cpus",
 
-Future<mesos::PerfStatistics> sample(
-    const set<string>& events,
-    const string& cgroup,
-    const Duration& duration)
-{
-  set<string> cgroups;
-  cgroups.insert(cgroup);
-  return sample(events, cgroups, duration)
-    .then(lambda::bind(&internal::select, cgroup, lambda::_1));
-}
+    // Print counts using a CSV-style output to make it easy to import
+    // directly into spreadsheets. Columns are separated by the string
+    // specified in PERF_DELIMITER.
+    "--field-separator", PERF_DELIMITER,
 
+    // Ensure all output goes to stdout.
+    "--log-fd", "1"
+  };
 
-Future<hashmap<string, mesos::PerfStatistics>> sample(
-    const set<string>& events,
-    const set<string>& cgroups,
-    const Duration& duration)
-{
-  if (!supported()) {
-    return Failure("Perf is not supported");
+  // Add all pairwise combinations of event and cgroup.
+  foreach (const string& event, events) {
+    foreach (const string& cgroup, cgroups) {
+      argv.push_back("--event");
+      argv.push_back(event);
+      argv.push_back("--cgroup");
+      argv.push_back(cgroup);
+    }
   }
 
-  return internal::sample(internal::argv(events, cgroups, duration), duration);
+  argv.push_back("--");
+  argv.push_back("sleep");
+  argv.push_back(stringify(duration.secs()));
+
+  Time start = Clock::now();
+
+  internal::Perf* perf = new internal::Perf(argv);
+  Future<string> future = perf->future();
+  spawn(perf, true);
+
+  auto parse = [start, duration](const string& output) ->
+      Future<hashmap<string, mesos::PerfStatistics>> {
+    Try<hashmap<string, mesos::PerfStatistics>> parse = perf::parse(output);
+
+    if (parse.isError()) {
+      return Failure("Failed to parse perf sample: " + parse.error());
+    }
+
+    foreachvalue (mesos::PerfStatistics& statistics, parse.get()) {
+      statistics.set_timestamp(start.secs());
+      statistics.set_duration(duration.secs());
+    }
+
+    return parse.get();
+  };
+
+  return future.then(parse);
 }
 
 
@@ -492,18 +384,15 @@ Try<hashmap<string, mesos::PerfStatistics>> parse(const string& output)
 
   foreach (const string& line, strings::tokenize(output, "\n")) {
     vector<string> tokens = strings::tokenize(line, PERF_DELIMITER);
-    // Expected format for an output line is either:
-    // value,event          (when sampling pids)
-    // value,event,cgroup   (when sampling a cgroup)
-    // assuming PERF_DELIMITER = ",".
-    if (tokens.size() < 2 || tokens.size() > 3) {
+    // Expected format for an output line is: value,event,cgroup
+    // (assuming PERF_DELIMITER = ",").
+    if (tokens.size() != 3) {
       return Error("Unexpected perf output at line: " + line);
     }
 
     const string value = tokens[0];
     const string event = internal::normalize(tokens[1]);
-    // Use the special PIDS_KEY when sampling pids.
-    const string cgroup = (tokens.size() == 3 ? tokens[2] : PIDS_KEY);
+    const string cgroup = tokens[2];
 
     if (!statistics.contains(cgroup)) {
       statistics.put(cgroup, mesos::PerfStatistics());

http://git-wip-us.apache.org/repos/asf/mesos/blob/3aecee03/src/linux/perf.hpp
----------------------------------------------------------------------
diff --git a/src/linux/perf.hpp b/src/linux/perf.hpp
index fbb7649..c444456 100644
--- a/src/linux/perf.hpp
+++ b/src/linux/perf.hpp
@@ -34,20 +34,6 @@
 
 namespace perf {
 
-// Sample the perf events for process pid for duration.
-process::Future<mesos::PerfStatistics> sample(
-    const std::set<std::string>& events,
-    pid_t pid,
-    const Duration& duration);
-
-
-// Sample the perf events for processes in pids for duration.
-process::Future<mesos::PerfStatistics> sample(
-    const std::set<std::string>& events,
-    const std::set<pid_t>& pids,
-    const Duration& duration);
-
-
 // Sample the perf events for process(es) in the perf_event cgroups
 // for duration. The returned hashmap is keyed by cgroup.
 // NOTE: cgroups should be relative to the perf_event subsystem mount,
@@ -58,13 +44,6 @@ process::Future<hashmap<std::string, mesos::PerfStatistics>> sample(
     const Duration& duration);
 
 
-// Sample the perf events for process(es) in the perf_event cgroup.
-process::Future<mesos::PerfStatistics> sample(
-    const std::set<std::string>& events,
-    const std::string& cgroup,
-    const Duration& duration);
-
-
 // Validate a set of events are accepted by `perf stat`.
 bool valid(const std::set<std::string>& events);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/3aecee03/src/tests/containerizer/cgroups_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/cgroups_tests.cpp b/src/tests/containerizer/cgroups_tests.cpp
index ed1306b..75a3bc0 100644
--- a/src/tests/containerizer/cgroups_tests.cpp
+++ b/src/tests/containerizer/cgroups_tests.cpp
@@ -1001,19 +1001,21 @@ TEST_F(CgroupsAnyHierarchyWithPerfEventTest, ROOT_CGROUPS_Perf)
   // NOTE: Wait at least 2 seconds as we've seen some variance in how
   // well 'perf' does across Linux distributions (e.g., Ubuntu 14.04)
   // and we want to make sure that we collect some non-zero values.
-  Future<mesos::PerfStatistics> statistics =
-    perf::sample(events, TEST_CGROUPS_ROOT, Seconds(2));
+  Future<hashmap<string, mesos::PerfStatistics>> statistics =
+    perf::sample(events, {TEST_CGROUPS_ROOT}, Seconds(2));
+
   AWAIT_READY(statistics);
 
-  ASSERT_TRUE(statistics->has_cycles());
+  ASSERT_TRUE(statistics->contains(TEST_CGROUPS_ROOT));
+  ASSERT_TRUE(statistics->at(TEST_CGROUPS_ROOT).has_cycles());
 
   // TODO(benh): Some Linux distributions (Ubuntu 14.04) fail to
   // properly sample 'cycles' with 'perf', so we don't explicitly
   // check the value here. See MESOS-3082.
   // EXPECT_LT(0u, statistics->cycles());
 
-  ASSERT_TRUE(statistics->has_task_clock());
-  EXPECT_LT(0.0, statistics->task_clock());
+  ASSERT_TRUE(statistics->at(TEST_CGROUPS_ROOT).has_task_clock());
+  EXPECT_LT(0.0, statistics->at(TEST_CGROUPS_ROOT).task_clock());
 
   // Kill the child process.
   ASSERT_NE(-1, ::kill(pid, SIGKILL));

http://git-wip-us.apache.org/repos/asf/mesos/blob/3aecee03/src/tests/containerizer/perf_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/perf_tests.cpp b/src/tests/containerizer/perf_tests.cpp
index d2e3b10..8c29ca3 100644
--- a/src/tests/containerizer/perf_tests.cpp
+++ b/src/tests/containerizer/perf_tests.cpp
@@ -24,7 +24,6 @@
 
 #include <process/clock.hpp>
 #include <process/gtest.hpp>
-#include <process/reap.hpp>
 
 #include <stout/gtest.hpp>
 #include <stout/stringify.hpp>
@@ -60,29 +59,18 @@ TEST_F(PerfTest, ROOT_Events)
 
 TEST_F(PerfTest, Parse)
 {
-  // uint64 and floats should be parsed.
-  Try<hashmap<string, mesos::PerfStatistics> > parse =
-    perf::parse("123,cycles\n0.123,task-clock");
-  ASSERT_SOME(parse);
-
-  ASSERT_TRUE(parse->contains(""));
-  mesos::PerfStatistics statistics = parse->get("").get();
-
-  ASSERT_TRUE(statistics.has_cycles());
-  EXPECT_EQ(123u, statistics.cycles());
-  ASSERT_TRUE(statistics.has_task_clock());
-  EXPECT_EQ(0.123, statistics.task_clock());
+  // Parse multiple cgroups with uint64 and floats.
+  Try<hashmap<string, mesos::PerfStatistics>> parse =
+    perf::parse("123,cycles,cgroup1\n"
+                "456,cycles,cgroup2\n"
+                "0.456,task-clock,cgroup2\n"
+                "0.123,task-clock,cgroup1");
 
-  // Parse multiple cgroups.
-  parse = perf::parse("123,cycles,cgroup1\n"
-                      "456,cycles,cgroup2\n"
-                      "0.456,task-clock,cgroup2\n"
-                      "0.123,task-clock,cgroup1");
   ASSERT_SOME(parse);
-  EXPECT_FALSE(parse->contains(""));
+  EXPECT_EQ(2u, parse->size());
 
   ASSERT_TRUE(parse->contains("cgroup1"));
-  statistics = parse->get("cgroup1").get();
+  mesos::PerfStatistics statistics = parse->get("cgroup1").get();
 
   ASSERT_TRUE(statistics.has_cycles());
   EXPECT_EQ(123u, statistics.cycles());
@@ -98,19 +86,20 @@ TEST_F(PerfTest, Parse)
   EXPECT_EQ(0.456, statistics.task_clock());
 
   // Statistics reporting <not supported> should not appear.
-  parse = perf::parse("<not supported>,cycles");
+  parse = perf::parse("<not supported>,cycles,cgroup1");
   ASSERT_SOME(parse);
 
-  ASSERT_TRUE(parse->contains(""));
-  statistics = parse->get("").get();
+  ASSERT_TRUE(parse->contains("cgroup1"));
+  statistics = parse->get("cgroup1").get();
   EXPECT_FALSE(statistics.has_cycles());
 
   // Statistics reporting <not counted> should be zero.
-  parse = perf::parse("<not counted>,cycles\n<not counted>,task-clock");
+  parse = perf::parse("<not counted>,cycles,cgroup1\n"
+                      "<not counted>,task-clock,cgroup1");
   ASSERT_SOME(parse);
 
-  ASSERT_TRUE(parse->contains(""));
-  statistics = parse->get("").get();
+  ASSERT_TRUE(parse->contains("cgroup1"));
+  statistics = parse->get("cgroup1").get();
 
   EXPECT_TRUE(statistics.has_cycles());
   EXPECT_EQ(0u, statistics.cycles());
@@ -125,60 +114,6 @@ TEST_F(PerfTest, Parse)
   EXPECT_ERROR(parse);
 }
 
-
-TEST_F(PerfTest, ROOT_SamplePid)
-{
-  // TODO(idownes): Replace this with a Subprocess when it supports
-  // DEATHSIG.
-  // Fork a child which we'll run perf against.
-  pid_t pid = fork();
-  ASSERT_GE(pid, 0);
-
-  if (pid == 0) {
-    // Kill ourself if the parent dies to prevent leaking the child.
-    prctl(PR_SET_PDEATHSIG, SIGKILL);
-
-    // Spin child to consume cpu cycles.
-    while (true);
-  }
-
-  // Continue in parent.
-  set<string> events;
-  // Hardware event.
-  events.insert("cycles");
-  // Software event.
-  events.insert("task-clock");
-
-  // Sample the child.
-  Duration duration = Milliseconds(100);
-  Future<mesos::PerfStatistics> statistics =
-    perf::sample(events, pid, duration);
-  AWAIT_READY(statistics);
-
-  // Kill the child and reap it.
-  Future<Option<int>> status = reap(pid);
-  kill(pid, SIGKILL);
-  AWAIT_READY(status);
-
-  // Check the sample timestamp is within the last 5 seconds. This is generous
-  // because there's the process reap delay in addition to the sampling
-  // duration.
-  ASSERT_TRUE(statistics->has_timestamp());
-  EXPECT_GT(
-      Seconds(5).secs(), Clock::now().secs() - statistics->timestamp());
-  EXPECT_EQ(duration.secs(), statistics->duration());
-
-  ASSERT_TRUE(statistics->has_cycles());
-
-  // TODO(benh): Some Linux distributions (Ubuntu 14.04) fail to
-  // properly sample 'cycles' with 'perf', so we don't explicitly
-  // check the value here. See MESOS-3082.
-  // EXPECT_LT(0u, statistics->cycles());
-
-  ASSERT_TRUE(statistics->has_task_clock());
-  EXPECT_LT(0.0, statistics->task_clock());
-}
-
 } // namespace tests {
 } // namespace internal {
 } // namespace mesos {


[3/6] mesos git commit: Used -> operator to clean up cgroups_tests.cpp.

Posted by bm...@apache.org.
Used -> operator to clean up cgroups_tests.cpp.


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

Branch: refs/heads/master
Commit: c3fdefc950f22797a12473ae78b783b229d26ecb
Parents: 1f45d50
Author: Benjamin Mahler <be...@gmail.com>
Authored: Mon Aug 31 18:56:20 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Aug 31 18:56:20 2015 -0700

----------------------------------------------------------------------
 src/tests/containerizer/cgroups_tests.cpp | 48 +++++++++++++-------------
 1 file changed, 24 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c3fdefc9/src/tests/containerizer/cgroups_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/cgroups_tests.cpp b/src/tests/containerizer/cgroups_tests.cpp
index 7a0aaf3..ed1306b 100644
--- a/src/tests/containerizer/cgroups_tests.cpp
+++ b/src/tests/containerizer/cgroups_tests.cpp
@@ -101,7 +101,7 @@ public:
 
     Try<set<string> > hierarchies = cgroups::hierarchies();
     ASSERT_SOME(hierarchies);
-    ASSERT_TRUE(hierarchies.get().empty())
+    ASSERT_TRUE(hierarchies->empty())
       << "-------------------------------------------------------------\n"
       << "We cannot run any cgroups tests that require mounting\n"
       << "hierarchies because you have the following hierarchies mounted:\n"
@@ -376,10 +376,10 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Get)
   Try<std::vector<string>> cgroups = cgroups::get(hierarchy);
   ASSERT_SOME(cgroups);
 
-  EXPECT_NE(cgroups.get().end(),
-            find(cgroups.get().begin(), cgroups.get().end(), "mesos_test2"));
-  EXPECT_NE(cgroups.get().end(),
-            find(cgroups.get().begin(), cgroups.get().end(), "mesos_test1"));
+  EXPECT_NE(cgroups->end(),
+            find(cgroups->begin(), cgroups->end(), "mesos_test2"));
+  EXPECT_NE(cgroups->end(),
+            find(cgroups->begin(), cgroups->end(), "mesos_test1"));
 
   ASSERT_SOME(cgroups::remove(hierarchy, "mesos_test1"));
   ASSERT_SOME(cgroups::remove(hierarchy, "mesos_test2"));
@@ -407,12 +407,12 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_NestedCgroups)
     cgroups::get(hierarchy, TEST_CGROUPS_ROOT);
   ASSERT_SOME(cgroups);
 
-  ASSERT_EQ(2u, cgroups.get().size());
+  ASSERT_EQ(2u, cgroups->size());
 
-  EXPECT_NE(cgroups.get().end(),
-            find(cgroups.get().begin(), cgroups.get().end(), cgroup2));
-  EXPECT_NE(cgroups.get().end(),
-            find(cgroups.get().begin(), cgroups.get().end(), cgroup1));
+  EXPECT_NE(cgroups->end(),
+            find(cgroups->begin(), cgroups->end(), cgroup2));
+  EXPECT_NE(cgroups->end(),
+            find(cgroups->begin(), cgroups->end(), cgroup1));
 
   ASSERT_SOME(cgroups::remove(hierarchy, cgroup1));
   ASSERT_SOME(cgroups::remove(hierarchy, cgroup2));
@@ -431,7 +431,7 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Tasks)
   Try<set<pid_t>> pids = cgroups::processes(hierarchy, cgroup.get());
   ASSERT_SOME(pids);
 
-  EXPECT_NE(0u, pids.get().count(pid));
+  EXPECT_NE(0u, pids->count(pid));
 }
 
 
@@ -486,7 +486,7 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Write)
   Try<set<pid_t> > pids = cgroups::processes(hierarchy, TEST_CGROUPS_ROOT);
   ASSERT_SOME(pids);
 
-  EXPECT_NE(0u, pids.get().count(pid));
+  EXPECT_NE(0u, pids->count(pid));
 
   // Kill the child process.
   ASSERT_NE(-1, ::kill(pid, SIGKILL));
@@ -531,16 +531,16 @@ TEST_F(CgroupsAnyHierarchyWithCpuAcctMemoryTest, ROOT_CGROUPS_Stat)
     cgroups::stat(
         path::join(baseHierarchy, "cpuacct"), "/", "cpuacct.stat");
   ASSERT_SOME(result);
-  EXPECT_TRUE(result.get().contains("user"));
-  EXPECT_TRUE(result.get().contains("system"));
-  EXPECT_GT(result.get().get("user").get(), 0llu);
-  EXPECT_GT(result.get().get("system").get(), 0llu);
+  EXPECT_TRUE(result->contains("user"));
+  EXPECT_TRUE(result->contains("system"));
+  EXPECT_GT(result->get("user").get(), 0llu);
+  EXPECT_GT(result->get("system").get(), 0llu);
 
   result = cgroups::stat(
       path::join(baseHierarchy, "memory"), "/", "memory.stat");
   ASSERT_SOME(result);
-  EXPECT_TRUE(result.get().contains("rss"));
-  EXPECT_GT(result.get().get("rss").get(), 0llu);
+  EXPECT_TRUE(result->contains("rss"));
+  EXPECT_GT(result->get("rss").get(), 0llu);
 }
 
 
@@ -824,7 +824,7 @@ TEST_F(CgroupsAnyHierarchyWithFreezerTest, ROOT_CGROUPS_AssignThreads)
   Try<set<pid_t> > cgroupThreads =
     cgroups::threads(hierarchy, TEST_CGROUPS_ROOT);
   EXPECT_SOME(cgroupThreads);
-  EXPECT_EQ(0u, cgroupThreads.get().size());
+  EXPECT_EQ(0u, cgroupThreads->size());
 
   // Assign ourselves to the test cgroup.
   CHECK_SOME(cgroups::assign(hierarchy, TEST_CGROUPS_ROOT, ::getpid()));
@@ -918,7 +918,7 @@ TEST_F(CgroupsAnyHierarchyWithFreezerTest, ROOT_CGROUPS_DestroyTracedProcess)
     Result<proc::ProcessStatus> process = proc::status(pid);
     ASSERT_SOME(process);
 
-    if (process.get().state == 'T' || process.get().state == 't') {
+    if (process->state == 'T' || process->state == 't') {
       break;
     }
 
@@ -1005,15 +1005,15 @@ TEST_F(CgroupsAnyHierarchyWithPerfEventTest, ROOT_CGROUPS_Perf)
     perf::sample(events, TEST_CGROUPS_ROOT, Seconds(2));
   AWAIT_READY(statistics);
 
-  ASSERT_TRUE(statistics.get().has_cycles());
+  ASSERT_TRUE(statistics->has_cycles());
 
   // TODO(benh): Some Linux distributions (Ubuntu 14.04) fail to
   // properly sample 'cycles' with 'perf', so we don't explicitly
   // check the value here. See MESOS-3082.
-  // EXPECT_LT(0u, statistics.get().cycles());
+  // EXPECT_LT(0u, statistics->cycles());
 
-  ASSERT_TRUE(statistics.get().has_task_clock());
-  EXPECT_LT(0.0, statistics.get().task_clock());
+  ASSERT_TRUE(statistics->has_task_clock());
+  EXPECT_LT(0.0, statistics->task_clock());
 
   // Kill the child process.
   ASSERT_NE(-1, ::kill(pid, SIGKILL));


[2/6] mesos git commit: Used -> operator for Try in perf_tests.cpp.

Posted by bm...@apache.org.
Used -> operator for Try in perf_tests.cpp.


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

Branch: refs/heads/master
Commit: 1f45d5059eeb913e39ad825715c44a92503f810c
Parents: 122fe2e
Author: Benjamin Mahler <be...@gmail.com>
Authored: Mon Aug 31 18:43:06 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Aug 31 18:49:22 2015 -0700

----------------------------------------------------------------------
 src/tests/containerizer/perf_tests.cpp | 37 +++++++++++++++--------------
 1 file changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1f45d505/src/tests/containerizer/perf_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/perf_tests.cpp b/src/tests/containerizer/perf_tests.cpp
index 6b3d70f..9a0de3c 100644
--- a/src/tests/containerizer/perf_tests.cpp
+++ b/src/tests/containerizer/perf_tests.cpp
@@ -46,6 +46,7 @@ class PerfTest : public ::testing::Test {};
 TEST_F(PerfTest, ROOT_Events)
 {
   set<string> events;
+
   // Valid events.
   events.insert("cycles");
   events.insert("task-clock");
@@ -64,8 +65,8 @@ TEST_F(PerfTest, Parse)
     perf::parse("123,cycles\n0.123,task-clock");
   CHECK_SOME(parse);
 
-  ASSERT_TRUE(parse.get().contains(""));
-  mesos::PerfStatistics statistics = parse.get().get("").get();
+  ASSERT_TRUE(parse->contains(""));
+  mesos::PerfStatistics statistics = parse->get("").get();
 
   ASSERT_TRUE(statistics.has_cycles());
   EXPECT_EQ(123u, statistics.cycles());
@@ -78,18 +79,18 @@ TEST_F(PerfTest, Parse)
                       "0.456,task-clock,cgroup2\n"
                       "0.123,task-clock,cgroup1");
   CHECK_SOME(parse);
-  EXPECT_FALSE(parse.get().contains(""));
+  EXPECT_FALSE(parse->contains(""));
 
-  ASSERT_TRUE(parse.get().contains("cgroup1"));
-  statistics = parse.get().get("cgroup1").get();
+  ASSERT_TRUE(parse->contains("cgroup1"));
+  statistics = parse->get("cgroup1").get();
 
   ASSERT_TRUE(statistics.has_cycles());
   EXPECT_EQ(123u, statistics.cycles());
   ASSERT_TRUE(statistics.has_task_clock());
   EXPECT_EQ(0.123, statistics.task_clock());
 
-  ASSERT_TRUE(parse.get().contains("cgroup2"));
-  statistics = parse.get().get("cgroup2").get();
+  ASSERT_TRUE(parse->contains("cgroup2"));
+  statistics = parse->get("cgroup2").get();
 
   ASSERT_TRUE(statistics.has_cycles());
   EXPECT_EQ(456u, statistics.cycles());
@@ -100,16 +101,16 @@ TEST_F(PerfTest, Parse)
   parse = perf::parse("<not supported>,cycles");
   CHECK_SOME(parse);
 
-  ASSERT_TRUE(parse.get().contains(""));
-  statistics = parse.get().get("").get();
+  ASSERT_TRUE(parse->contains(""));
+  statistics = parse->get("").get();
   EXPECT_FALSE(statistics.has_cycles());
 
   // Statistics reporting <not counted> should be zero.
   parse = perf::parse("<not counted>,cycles\n<not counted>,task-clock");
   CHECK_SOME(parse);
 
-  ASSERT_TRUE(parse.get().contains(""));
-  statistics = parse.get().get("").get();
+  ASSERT_TRUE(parse->contains(""));
+  statistics = parse->get("").get();
 
   EXPECT_TRUE(statistics.has_cycles());
   EXPECT_EQ(0u, statistics.cycles());
@@ -162,20 +163,20 @@ TEST_F(PerfTest, ROOT_SamplePid)
   // Check the sample timestamp is within the last 5 seconds. This is generous
   // because there's the process reap delay in addition to the sampling
   // duration.
-  ASSERT_TRUE(statistics.get().has_timestamp());
+  ASSERT_TRUE(statistics->has_timestamp());
   EXPECT_GT(
-      Seconds(5).secs(), Clock::now().secs() - statistics.get().timestamp());
-  EXPECT_EQ(duration.secs(), statistics.get().duration());
+      Seconds(5).secs(), Clock::now().secs() - statistics->timestamp());
+  EXPECT_EQ(duration.secs(), statistics->duration());
 
-  ASSERT_TRUE(statistics.get().has_cycles());
+  ASSERT_TRUE(statistics->has_cycles());
 
   // TODO(benh): Some Linux distributions (Ubuntu 14.04) fail to
   // properly sample 'cycles' with 'perf', so we don't explicitly
   // check the value here. See MESOS-3082.
-  // EXPECT_LT(0u, statistics.get().cycles());
+  // EXPECT_LT(0u, statistics->cycles());
 
-  ASSERT_TRUE(statistics.get().has_task_clock());
-  EXPECT_LT(0.0, statistics.get().task_clock());
+  ASSERT_TRUE(statistics->has_task_clock());
+  EXPECT_LT(0.0, statistics->task_clock());
 }
 
 } // namespace tests {