You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2015/07/19 21:06:42 UTC

mesos git commit: Fix cgroup tests to not verify order.

Repository: mesos
Updated Branches:
  refs/heads/master b1a23d6a5 -> 49cd532a7


Fix cgroup tests to not verify order.

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


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

Branch: refs/heads/master
Commit: 49cd532a7217466e61fae98504842c007a278060
Parents: b1a23d6
Author: Timothy Chen <tn...@apache.org>
Authored: Sun Jul 19 12:06:21 2015 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Sun Jul 19 12:06:22 2015 -0700

----------------------------------------------------------------------
 src/tests/cgroups_tests.cpp | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/49cd532a/src/tests/cgroups_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cgroups_tests.cpp b/src/tests/cgroups_tests.cpp
index 3924a4a..9f5028f 100644
--- a/src/tests/cgroups_tests.cpp
+++ b/src/tests/cgroups_tests.cpp
@@ -369,11 +369,13 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_Get)
   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<std::string>> cgroups = cgroups::get(hierarchy);
   ASSERT_SOME(cgroups);
 
-  EXPECT_EQ(cgroups.get()[0], "mesos_test2");
-  EXPECT_EQ(cgroups.get()[1], "mesos_test1");
+  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"));
 
   ASSERT_SOME(cgroups::remove(hierarchy, "mesos_test1"));
   ASSERT_SOME(cgroups::remove(hierarchy, "mesos_test2"));
@@ -384,7 +386,10 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_NestedCgroups)
 {
   std::string hierarchy = path::join(baseHierarchy, "cpu");
   ASSERT_SOME(cgroups::create(hierarchy, TEST_CGROUPS_ROOT));
-  ASSERT_SOME(cgroups::create(hierarchy, path::join(TEST_CGROUPS_ROOT, "1")))
+  std::string cgroup1 = path::join(TEST_CGROUPS_ROOT, "1");
+  std::string cgroup2 = path::join(TEST_CGROUPS_ROOT, "2");
+
+  ASSERT_SOME(cgroups::create(hierarchy, cgroup1))
     << "-------------------------------------------------------------\n"
     << "We cannot run this test because it appears you do not have\n"
     << "a modern enough version of the Linux kernel. You won't be\n"
@@ -392,19 +397,21 @@ TEST_F(CgroupsAnyHierarchyTest, ROOT_CGROUPS_NestedCgroups)
     << "this test.\n"
     << "-------------------------------------------------------------";
 
-  ASSERT_SOME(cgroups::create(hierarchy, path::join(TEST_CGROUPS_ROOT, "2")));
+  ASSERT_SOME(cgroups::create(hierarchy, cgroup2));
 
-  Try<std::vector<std::string> > cgroups =
+  Try<std::vector<std::string>> cgroups =
     cgroups::get(hierarchy, TEST_CGROUPS_ROOT);
-
   ASSERT_SOME(cgroups);
+
   ASSERT_EQ(2u, cgroups.get().size());
 
-  EXPECT_EQ(cgroups.get()[0], path::join(TEST_CGROUPS_ROOT, "2"));
-  EXPECT_EQ(cgroups.get()[1], path::join(TEST_CGROUPS_ROOT, "1"));
+  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));
 
-  ASSERT_SOME(cgroups::remove(hierarchy, path::join(TEST_CGROUPS_ROOT, "1")));
-  ASSERT_SOME(cgroups::remove(hierarchy, path::join(TEST_CGROUPS_ROOT, "2")));
+  ASSERT_SOME(cgroups::remove(hierarchy, cgroup1));
+  ASSERT_SOME(cgroups::remove(hierarchy, cgroup2));
 }