You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2013/03/16 01:45:27 UTC

svn commit: r1457185 - in /incubator/mesos/trunk/src/tests: allocator_tests.cpp gc_tests.cpp status_update_manager_tests.cpp zookeeper_test.cpp

Author: vinodkone
Date: Sat Mar 16 00:45:27 2013
New Revision: 1457185

URL: http://svn.apache.org/r1457185
Log:
Fixed flags used in gc and status update manager
tests to inherit from MesosTest fixture.

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

Modified:
    incubator/mesos/trunk/src/tests/allocator_tests.cpp
    incubator/mesos/trunk/src/tests/gc_tests.cpp
    incubator/mesos/trunk/src/tests/status_update_manager_tests.cpp
    incubator/mesos/trunk/src/tests/zookeeper_test.cpp

Modified: incubator/mesos/trunk/src/tests/allocator_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/allocator_tests.cpp?rev=1457185&r1=1457184&r2=1457185&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/allocator_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/allocator_tests.cpp Sat Mar 16 00:45:27 2013
@@ -278,8 +278,8 @@ protected:
 
   virtual void TearDown()
   {
-    MesosTest::TearDown();
     delete a;
+    MesosTest::TearDown();
   }
 
   MockAllocatorProcess<T> allocator;

Modified: incubator/mesos/trunk/src/tests/gc_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/gc_tests.cpp?rev=1457185&r1=1457184&r2=1457185&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/gc_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/gc_tests.cpp Sat Mar 16 00:45:27 2013
@@ -74,22 +74,13 @@ using testing::Eq;
 using testing::Return;
 using testing::SaveArg;
 
-class GarbageCollectorTest : public ::testing::Test
+class GarbageCollectorTest : public MesosTest
 {
 protected:
-  static void SetUpTestCase()
-  {
-    flags.work_dir = "/tmp/mesos-tests";
-    flags.resources = Option<string>::some("cpus:2;mem:1024");
-
-    Resources resources = Resources::parse(flags.resources.get());
-    Value::Scalar none;
-    cpus = resources.get("cpus", none).value();
-    mem = resources.get("mem", none).value();
-  }
-
   virtual void SetUp()
   {
+    MesosTest::SetUp();
+
     ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
     a = new Allocator(&allocator);
@@ -98,6 +89,11 @@ protected:
     master = process::spawn(m);
 
     execs[DEFAULT_EXECUTOR_ID] = &exec;
+
+    Resources resources = Resources::parse(slaveFlags.resources.get());
+    Value::Scalar none;
+    cpus = resources.get("cpus", none).value();
+    mem = resources.get("mem", none).value();
   }
 
   virtual void TearDown()
@@ -110,14 +106,14 @@ protected:
     delete a;
     delete files;
 
-    os::rmdir(flags.work_dir);
+    MesosTest::TearDown();
   }
 
   void startSlave()
   {
     isolator = new TestingIsolator(execs);
 
-    s = new Slave(flags, true, isolator, files);
+    s = new Slave(slaveFlags, true, isolator, files);
     slave = process::spawn(s);
 
     detector = new BasicMasterDetector(master, slave, true);
@@ -154,18 +150,11 @@ protected:
   TaskStatus status;
   PID<Master> master;
   PID<Slave> slave;
-  static slave::Flags flags;
-  static double cpus;
-  static double mem;
+  double cpus;
+  double mem;
 };
 
 
-// Initialize static members here.
-slave::Flags GarbageCollectorTest::flags;
-double GarbageCollectorTest::cpus;
-double GarbageCollectorTest::mem;
-
-
 TEST_F(GarbageCollectorTest, Restart)
 {
   // Messages expectations.
@@ -227,7 +216,9 @@ TEST_F(GarbageCollectorTest, Restart)
   // Make sure directory exists. Need to do this AFTER getting a
   // status update for a task because the directory won't get created
   // until the SlaveRegisteredMessage has been received.
-  const std::string& slaveDir = flags.work_dir + "/slaves/" + slaveId.value();
+  const std::string& slaveDir =
+    slaveFlags.work_dir + "/slaves/" + slaveId.value();
+
   ASSERT_TRUE(os::exists(slaveDir));
 
   Clock::pause();
@@ -246,7 +237,7 @@ TEST_F(GarbageCollectorTest, Restart)
 
   sleep(1);
 
-  Clock::advance(flags.gc_delay.secs());
+  Clock::advance(slaveFlags.gc_delay.secs());
 
   Clock::settle();
 
@@ -326,7 +317,7 @@ TEST_F(GarbageCollectorTest, ExitedExecu
 
   sleep(1);
 
-  Clock::advance(flags.gc_delay.secs());
+  Clock::advance(slaveFlags.gc_delay.secs());
 
   Clock::settle();
 

Modified: incubator/mesos/trunk/src/tests/status_update_manager_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/status_update_manager_tests.cpp?rev=1457185&r1=1457184&r2=1457185&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/status_update_manager_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/status_update_manager_tests.cpp Sat Mar 16 00:45:27 2013
@@ -73,18 +73,13 @@ using testing::Return;
 using testing::SaveArg;
 
 
-class StatusUpdateManagerTest: public ::testing::Test
+class StatusUpdateManagerTest: public MesosTest
 {
 protected:
-  static void SetUpTestCase()
-  {
-    flags.checkpoint = true;
-    flags.work_dir = "/tmp/mesos-tests";
-    os::rmdir(flags.work_dir);
-  }
-
   virtual void SetUp()
   {
+    MesosTest::SetUp();
+
     ASSERT_TRUE(GTEST_IS_THREADSAFE);
 
     a = new Allocator(&allocator);
@@ -95,7 +90,9 @@ protected:
 
     isolator = new TestingIsolator(execs);
 
-    s = new Slave(flags, true, isolator, &files);
+    slaveFlags.checkpoint = true;
+
+    s = new Slave(slaveFlags, true, isolator, &files);
     slave = process::spawn(s);
 
     detector = new BasicMasterDetector(master, slave, true);
@@ -118,7 +115,7 @@ protected:
     delete m;
     delete a;
 
-    os::rmdir(flags.work_dir);
+    MesosTest::TearDown();
   }
 
   vector<TaskInfo> createTasks(const Offer& offer)
@@ -150,12 +147,8 @@ protected:
   TaskStatus status;
   PID<Master> master;
   PID<Slave> slave;
-  static slave::Flags flags;
 };
 
-// Initialize static members here.
-slave::Flags StatusUpdateManagerTest::flags;
-
 
 TEST_F(StatusUpdateManagerTest, CheckpointStatusUpdate)
 {
@@ -212,7 +205,7 @@ TEST_F(StatusUpdateManagerTest, Checkpoi
 
   // Ensure that both the status update and its acknowledgement
   // are correctly checkpointed.
-  Try<list<string> > found = os::find(flags.work_dir, TASK_UPDATES_FILE);
+  Try<list<string> > found = os::find(slaveFlags.work_dir, TASK_UPDATES_FILE);
   ASSERT_SOME(found);
   ASSERT_EQ(1u, found.get().size());
 

Modified: incubator/mesos/trunk/src/tests/zookeeper_test.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/zookeeper_test.cpp?rev=1457185&r1=1457184&r2=1457185&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/zookeeper_test.cpp (original)
+++ incubator/mesos/trunk/src/tests/zookeeper_test.cpp Sat Mar 16 00:45:27 2013
@@ -110,9 +110,9 @@ void ZooKeeperTest::SetUp()
 
 void ZooKeeperTest::TearDown()
 {
-  MesosTest::TearDown();
   delete server;
   server = NULL;
+  MesosTest::TearDown();
 };