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 2011/06/05 10:51:31 UTC

svn commit: r1132152 - in /incubator/mesos/trunk/src: ./ common/ event_history/ local/ master/ tests/

Author: benh
Date: Sun Jun  5 08:51:30 2011
New Revision: 1132152

URL: http://svn.apache.org/viewvc?rev=1132152&view=rev
Log:
Renaming event_history files to event_logger. Renaming
currentDateTimeInMicros to currentDateInMicros. Moving to JSON format
for file_writer. Updating unit tests.

Added:
    incubator/mesos/trunk/src/event_history/event_logger.cpp
      - copied, changed from r1132151, incubator/mesos/trunk/src/event_history/event_history.cpp
    incubator/mesos/trunk/src/event_history/event_logger.hpp
      - copied, changed from r1132151, incubator/mesos/trunk/src/event_history/event_history.hpp
Removed:
    incubator/mesos/trunk/src/event_history/event_history.cpp
    incubator/mesos/trunk/src/event_history/event_history.hpp
Modified:
    incubator/mesos/trunk/src/Makefile.in
    incubator/mesos/trunk/src/common/date_utils.cpp
    incubator/mesos/trunk/src/common/date_utils.hpp
    incubator/mesos/trunk/src/event_history/file_event_writer.cpp
    incubator/mesos/trunk/src/event_history/sqlite_event_writer.cpp
    incubator/mesos/trunk/src/local/local.cpp
    incubator/mesos/trunk/src/master/main.cpp
    incubator/mesos/trunk/src/master/master.hpp
    incubator/mesos/trunk/src/tests/test_event_history.cpp
    incubator/mesos/trunk/src/tests/test_master.cpp

Modified: incubator/mesos/trunk/src/Makefile.in
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/Makefile.in?rev=1132152&r1=1132151&r2=1132152&view=diff
==============================================================================
--- incubator/mesos/trunk/src/Makefile.in (original)
+++ incubator/mesos/trunk/src/Makefile.in Sun Jun  5 08:51:30 2011
@@ -127,7 +127,7 @@ SLAVE_SWIG_WEBUI_OBJ = webui/slave/swig/
 WEBUI_OBJ = $(MASTER_WEBUI_OBJ) $(SLAVE_WEBUI_OBJ)
 SWIG_WEBUI_OBJ = $(MASTER_SWIG_WEBUI_OBJ) $(SLAVE_SWIG_WEBUI_OBJ)
 
-EVENT_HISTORY_OBJ = event_history/event_history.o \
+EVENT_HISTORY_OBJ = event_history/event_logger.o \
 										event_history/file_event_writer.o \
 										event_history/sqlite_event_writer.o
 

Modified: incubator/mesos/trunk/src/common/date_utils.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/common/date_utils.cpp?rev=1132152&r1=1132151&r2=1132152&view=diff
==============================================================================
--- incubator/mesos/trunk/src/common/date_utils.cpp (original)
+++ incubator/mesos/trunk/src/common/date_utils.cpp Sun Jun  5 08:51:30 2011
@@ -32,8 +32,8 @@ string DateUtils::currentDate()
 }
 
 
-// Get the current time in microseconds.
-long DateUtils::currentDateTimeInMicro() {
+// Get the current time in microseconds since the UNIX epoch.
+long DateUtils::currentDateInMicro() {
   struct timeval curr_time;
   struct timezone tzp;
   gettimeofday(&curr_time, &tzp);

Modified: incubator/mesos/trunk/src/common/date_utils.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/common/date_utils.hpp?rev=1132152&r1=1132151&r2=1132152&view=diff
==============================================================================
--- incubator/mesos/trunk/src/common/date_utils.hpp (original)
+++ incubator/mesos/trunk/src/common/date_utils.hpp Sun Jun  5 08:51:30 2011
@@ -18,9 +18,9 @@ public:
   static std::string currentDate();
 
   /**
-   * Get the current time in microseconds.
+   * Get the current time in microseconds since the UNIX epoch.
    */
-  static long currentDateTimeInMicro();
+  static long currentDateInMicro();
 
   /**
    * Unit test utility method that makes this class return a fixed string

Copied: incubator/mesos/trunk/src/event_history/event_logger.cpp (from r1132151, incubator/mesos/trunk/src/event_history/event_history.cpp)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/event_history/event_logger.cpp?p2=incubator/mesos/trunk/src/event_history/event_logger.cpp&p1=incubator/mesos/trunk/src/event_history/event_history.cpp&r1=1132151&r2=1132152&rev=1132152&view=diff
==============================================================================
--- incubator/mesos/trunk/src/event_history/event_history.cpp (original)
+++ incubator/mesos/trunk/src/event_history/event_logger.cpp Sun Jun  5 08:51:30 2011
@@ -1,24 +1,35 @@
 #include <cstdlib>
 #include <stdarg.h>
 #include <sys/stat.h>
+#include <sstream>
 
 #include <glog/logging.h>
 
-#include "event_history.hpp"
+#include "event_logger.hpp"
 #include "file_event_writer.hpp"
 #include "sqlite_event_writer.hpp"
 
 using namespace mesos::internal::eventhistory;
 
+// We use class data members so that the default values that get 
+// printed with --help option match up with those that are used as
+// default values when accessing the configuration settings.
+bool EventLogger::default_ev_hist_file_conf_val = true;
+bool EventLogger::default_ev_hist_sqlite_conf_val = false;
 
-void EventLogger::registerOptions(Configurator* conf) {
-  //TODO(andyk): We don't set the default value here, since this would
-  //             override the defaults set at the param.get() calls later.
-  //             We would like to set the default here and override it later.
-  conf->addOption<bool>("event_history_file",
-        "Enable file event history logging(default: true)");
-  conf->addOption<bool>("event_history_sqlite",
-        "Enable SQLite event history logging (default: false)");
+void EventLogger::registerOptions(Configurator* conf, bool file_writer_default,
+                                  bool sqlite_writer_default)
+{
+  default_ev_hist_file_conf_val = file_writer_default;
+  default_ev_hist_sqlite_conf_val = sqlite_writer_default;
+
+  ostringstream evFileMessage, evSqliteMessage;
+  evFileMessage << "Enable event history file writer (default: "
+                << boolalpha << default_ev_hist_file_conf_val << ")";
+  evSqliteMessage << "Enable event history sqlite writer (default: "
+                  << boolalpha << default_ev_hist_sqlite_conf_val << ")";
+  conf->addOption<bool>("event_history_file", evFileMessage.str());
+  conf->addOption<bool>("event_history_sqlite", evSqliteMessage.str());
 }
 
 
@@ -38,13 +49,14 @@ EventLogger::EventLogger(const Params& c
                    << "file based event history will not be captured";
       }
     }
-    //Create and add file based writers (i.e. writers which depend on log_dir
-    //being set) to writers list.
-    if (conf.get<bool>("event_history_file", true)) {
+    // Create and add file based writers (i.e. writers which depend on log_dir
+    // being set) to writers list.
+    if (conf.get<bool>("event_history_file", default_ev_hist_file_conf_val)) {
       LOG(INFO) << "creating FileEventWriter" << endl;
       writers.push_front(new FileEventWriter(conf));
     }
-    if (conf.get<bool>("event_history_sqlite", false)) {
+    if (conf.get<bool>("event_history_sqlite",
+                       default_ev_hist_sqlite_conf_val)) {
       LOG(INFO) << "creating SqliteEventWriter" << endl;
       writers.push_front(new SqlLiteEventWriter(conf));
     }
@@ -52,13 +64,13 @@ EventLogger::EventLogger(const Params& c
     LOG(INFO) << "No log directory was specified, so not creating "
               << "FileEventWriter or SqliteEventWriter. No event "
               << "logging will happen!";
-    //Create and add non file based writers to writers list here.
+    // Create and add non file based writers to writers list here.
   }
 }
 
 
 EventLogger::~EventLogger() {
-  //Delete all eventWriters in list.
+  // Delete all eventWriters in list.
   list<EventWriter*>::iterator it;
   for (it = writers.begin(); it != writers.end(); it++) {
     delete *it;

Copied: incubator/mesos/trunk/src/event_history/event_logger.hpp (from r1132151, incubator/mesos/trunk/src/event_history/event_history.hpp)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/event_history/event_logger.hpp?p2=incubator/mesos/trunk/src/event_history/event_logger.hpp&p1=incubator/mesos/trunk/src/event_history/event_history.hpp&r1=1132151&r2=1132152&rev=1132152&view=diff
==============================================================================
--- incubator/mesos/trunk/src/event_history/event_history.hpp (original)
+++ incubator/mesos/trunk/src/event_history/event_logger.hpp Sun Jun  5 08:51:30 2011
@@ -16,7 +16,7 @@
 
 namespace mesos { namespace internal { namespace eventhistory {
 
-using namespace std; //for list
+using namespace std; // For list.
 using mesos::FrameworkID;
 using mesos::TaskID;
 using mesos::SlaveID;
@@ -24,21 +24,23 @@ using mesos::FrameworkID;
 using mesos::TaskState;
 using mesos::internal::Resources;
 
-
 class EventLogger {
 private:
   list<EventWriter*> writers; 
 public:
+  static bool default_ev_hist_file_conf_val;
+  static bool default_ev_hist_sqlite_conf_val;
+
   EventLogger();
   EventLogger(const Params&);
   ~EventLogger();
-  static void registerOptions(Configurator*);
+  static void registerOptions(Configurator*, bool file_writer_default = true,
+                                             bool sqlite_writer_default = false);
   int logResourceOffer(FrameworkID, Resources);
   int logTaskCreated(TaskID, FrameworkID, SlaveID, string sHostname, Resources);
   int logTaskStateUpdated(TaskID, FrameworkID, TaskState); 
   int logFrameworkRegistered(FrameworkID, string);
   int logFrameworkUnregistered(FrameworkID);
-  EventLogger operator() (string, string);
 };
 
 }}} /* namespace */

Modified: incubator/mesos/trunk/src/event_history/file_event_writer.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/event_history/file_event_writer.cpp?rev=1132152&r1=1132151&r2=1132152&view=diff
==============================================================================
--- incubator/mesos/trunk/src/event_history/file_event_writer.cpp (original)
+++ incubator/mesos/trunk/src/event_history/file_event_writer.cpp Sun Jun  5 08:51:30 2011
@@ -31,11 +31,14 @@ FileEventWriter::~FileEventWriter() {
 int FileEventWriter::logTaskCreated(TaskID tid, FrameworkID fwid, SlaveID sid,
                                     string webuiUrl, Resources resVec)
 {
-  logfile << DateUtils::currentDate() << ",CreateTask, "
-          << "taskid: " << tid << ", "
-          << "fwid: " << fwid << ", "
-          << "sid: " << sid << ","
-          << "cpus: " << resVec.cpus << ", mem: " << resVec.mem << endl;
+  logfile << "{"
+            << "datetime:" << DateUtils::currentDate() << ","
+            << "event_type:CreateTask,"
+            << "taskid:" << tid << ","
+            << "fwid:" << fwid << ","
+            << "sid:" << sid << ","
+            << "resources:{cpus:" << resVec.cpus << ",mem:" << resVec.mem << "}"
+          << "}" << endl;
 
   return 0;
 }
@@ -44,19 +47,25 @@ int FileEventWriter::logTaskCreated(Task
 int FileEventWriter::logTaskStateUpdated(TaskID tid, FrameworkID fwid,
                                          TaskState state)
 {
-  logfile << DateUtils::currentDate() << ", TaskStateUpdate, "
-          << "taskid: " << tid << ", "
-          << "fwid: " << fwid << ", "
-          << "state: " << state << endl;
+  logfile << "{" 
+            << "datetime:" << DateUtils::currentDate() << "," 
+            << "event_type:TaskStateUpdate,"
+            << "taskid:" << tid << ","
+            << "fwid:" << fwid << ","
+            << "state:" << state
+          << "}" << endl;
 
   return 0;
 }
 
 
 int FileEventWriter::logFrameworkRegistered(FrameworkID fwid, string user) {
-  logfile << DateUtils::currentDate() << ", CreateFramework, "
-          << "fwid: " << fwid << ", "
-          << "userid: " << user << endl;
+  logfile << "{"
+            << "datetime:" << DateUtils::currentDate() << ","
+            << "event_type:CreateFramework,"
+            << "fwid:" << fwid << ","
+            << "userid:" << user
+          << "}" << endl;
 
   return 0;
 }

Modified: incubator/mesos/trunk/src/event_history/sqlite_event_writer.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/event_history/sqlite_event_writer.cpp?rev=1132152&r1=1132151&r2=1132152&view=diff
==============================================================================
--- incubator/mesos/trunk/src/event_history/sqlite_event_writer.cpp (original)
+++ incubator/mesos/trunk/src/event_history/sqlite_event_writer.cpp Sun Jun  5 08:51:30 2011
@@ -4,7 +4,7 @@ using namespace mesos::internal::eventhi
 
 static int callback(void *NotUsed, int argc, char **argv, char **azColName) {
   int i;
-  for(i=0; i<argc; i++) {
+  for (i=0; i<argc; i++) {
     printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
   }
   printf("\n");
@@ -23,16 +23,16 @@ SqlLiteEventWriter::SqlLiteEventWriter(c
   CHECK_NE(logDir, "") << "SqlLiteEventWriter constructor failed pre-condition."
                        << " conf[\"log_dir\" must be set.";
 
-  //set up log file in log dir
+  // Set up log file in log dir.
   int rc = sqlite3_open((logDir + "/event_history_db.sqlite3").c_str(), &db);
-  if( rc ) {
+  if (rc) {
     LOG(ERROR) << "Can't open database: " << sqlite3_errmsg(db) << endl;
     sqlite3_close(db);
   } else {
     DLOG(INFO) << "opened sql lite db" << endl;
   }
-  //create task table in case it doesn't already exist,
-  //if it does this shouldn't destroy it
+  // Create task table in case it doesn't already exist,
+  // if it does this shouldn't destroy it.
   char *errMsg = 0;
   sqlite3_exec(db, "CREATE TABLE task (taskid Varchar(255), fwid Varchar(255), \
                     sid Varchar(255), webuiUrl Varchar(255), \
@@ -66,7 +66,7 @@ int SqlLiteEventWriter::logTaskCreated(T
      << "\"" << fwid << "\"" << ","
      << "\"" << sid << "\"" << ","
      << "\"" << webuiUrl << "\"" << ","
-     << DateUtils::currentDateTimeInMicro() << ","
+     << DateUtils::currentDateInMicro() << ","
      << "'{"
        << "\"cpus\":\"" << resVec.cpus << "\","
        << "\"mem\":\"" << resVec.mem << "\""
@@ -88,7 +88,7 @@ int SqlLiteEventWriter::logTaskStateUpda
      << "\"" << tid << "\"" << ","
      << "\"" << fwid << "\"" << ","
      << "\"" << state << "\"" << ","
-     << DateUtils::currentDateTimeInMicro() << ")" << endl;
+     << DateUtils::currentDateInMicro() << ")" << endl;
   DLOG(INFO) << "executing " << ss.str() << endl;
   char *errMsg = 0;
   sqlite3_exec(db, ss.str().c_str(), callback, 0, &errMsg);
@@ -102,7 +102,7 @@ int SqlLiteEventWriter::logFrameworkRegi
   ss << "INSERT INTO framework VALUES ("
      << "\"" << fwid << "\"" << ","
      << "\"" << user << "\"" << ","
-     << DateUtils::currentDateTimeInMicro() << ")" << endl;
+     << DateUtils::currentDateInMicro() << ")" << endl;
   DLOG(INFO) << "executing " << ss.str() << endl;
   char *errMsg = 0;
   sqlite3_exec(db, ss.str().c_str(), callback, 0, &errMsg); 

Modified: incubator/mesos/trunk/src/local/local.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/local/local.cpp?rev=1132152&r1=1132151&r2=1132152&view=diff
==============================================================================
--- incubator/mesos/trunk/src/local/local.cpp (original)
+++ incubator/mesos/trunk/src/local/local.cpp Sun Jun  5 08:51:30 2011
@@ -10,7 +10,7 @@
 
 #include "configurator/configurator.hpp"
 
-#include "event_history/event_history.hpp"
+#include "event_history/event_logger.hpp"
  
 #include "master/master.hpp"
 

Modified: incubator/mesos/trunk/src/master/main.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master/main.cpp?rev=1132152&r1=1132151&r2=1132152&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master/main.cpp (original)
+++ incubator/mesos/trunk/src/master/main.cpp Sun Jun  5 08:51:30 2011
@@ -59,7 +59,6 @@ int main(int argc, char **argv)
 
   LOG(INFO) << "Creating event logger." << endl;
   EventLogger evLogger(params);
-  LOG(INFO) << "Done creating event logger." << endl;
 
   if (params.contains("port"))
     setenv("LIBPROCESS_PORT", params["port"].c_str(), 1);

Modified: incubator/mesos/trunk/src/master/master.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master/master.hpp?rev=1132152&r1=1132151&r2=1132152&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master/master.hpp (original)
+++ incubator/mesos/trunk/src/master/master.hpp Sun Jun  5 08:51:30 2011
@@ -33,7 +33,7 @@
 
 #include "detector/detector.hpp"
 
-#include "event_history/event_history.hpp"
+#include "event_history/event_logger.hpp"
 
 #include "messaging/messages.hpp"
 

Modified: incubator/mesos/trunk/src/tests/test_event_history.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/test_event_history.cpp?rev=1132152&r1=1132151&r2=1132152&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/test_event_history.cpp (original)
+++ incubator/mesos/trunk/src/tests/test_event_history.cpp Sun Jun  5 08:51:30 2011
@@ -4,7 +4,7 @@
 
 #include "common/params.hpp"
 
-#include "event_history/event_history.hpp"
+#include "event_history/event_logger.hpp"
 
 #include "master/master.hpp"
 
@@ -26,20 +26,18 @@ using mesos::internal::Params;
  */
 
 /*
- * preconditions: /tmp is writable by user running this test
+ * precondition:  cwd does not contain event_history_log.txt or
+ *                event_history_db.sqlite3 files.
+ * postcondition: event_history_log.txt and event_history_db.sqlite3
+ *                still do not exist (i.e. were not created).
  */
 TEST_WITH_WORKDIR(EventHistoryTest, EventLoggingTurnedOffWithLogDir)
 {
   EXPECT_TRUE(GTEST_IS_THREADSAFE);
 
   Params params;
-  const char* testLogDir = "/tmp/mesos-EventLoggingTurnedOff-test-dir";
-  system((string("rm -rf ") + testLogDir).c_str()); // remove tmp dir, if exists
-  struct stat sb;
-  stat((string(testLogDir) + "/event_history_log.txt").c_str(), &sb);
-  EXPECT_FALSE(S_ISREG(sb.st_mode));
-  EXPECT_EQ(0, mkdir(testLogDir, 0777)); // create temporary test dir
-  params.set<string>("log_dir", testLogDir);
+  const char* logDir = "./";
+  params.set<string>("log_dir", logDir);
   params.set<bool>("event_history_sqlite", false);
   params.set<bool>("event_history_file", false);
   EventLogger evLogger(params);
@@ -47,26 +45,28 @@ TEST_WITH_WORKDIR(EventHistoryTest, Even
   evLogger.logFrameworkRegistered(fid, "UserID");
 
   // make sure eventlog file and sqlite db were NOT created
-  EXPECT_NE(0, stat((string(testLogDir) + "/event_history_log.txt").c_str(), &sb));
+  struct stat sb;
+  EXPECT_NE(0, stat((string(logDir) + "/event_history_log.txt").c_str(), &sb));
   EXPECT_FALSE(S_ISREG(sb.st_mode));
 
-  EXPECT_NE(0, stat((string(testLogDir) + "/event_history_db.sqlite3").c_str(), &sb));
+  EXPECT_NE(0, stat((string(logDir) + "/event_history_db.sqlite3").c_str(), &sb));
   EXPECT_FALSE(S_ISREG(sb.st_mode));
 }
 
 
+/*
+ * precondition:  cwd does not contain event_history_log.txt or
+ *                event_history_db.sqlite3 files.
+ * postcondition: event_history_log.txt and event_history_db.sqlite3
+ *                exist (i.e. were created).
+ */
 TEST_WITH_WORKDIR(EventHistoryTest, UsesLogDirLocation)
 {
   EXPECT_TRUE(GTEST_IS_THREADSAFE);
 
   Params params;
-  const char* testLogDir = "/tmp/mesos-EventLoggingTurnedOff-test-dir";
-  system((string("rm -rf ") + testLogDir).c_str()); // remove tmp dir, if exists
-  struct stat sb;
-  stat((string(testLogDir) + "/event_history_log.txt").c_str(), &sb);
-  EXPECT_FALSE(S_ISREG(sb.st_mode));
-  EXPECT_EQ(0, mkdir(testLogDir, 0777)); // create temporary test dir
-  params.set<string>("log_dir", testLogDir);
+  const char* logDir = "./";
+  params.set<string>("log_dir", "./");
   params.set<bool>("event_history_sqlite", true);
   params.set<bool>("event_history_file", true);
   EventLogger evLogger(params);
@@ -74,10 +74,11 @@ TEST_WITH_WORKDIR(EventHistoryTest, Uses
   evLogger.logFrameworkRegistered(fid, "UserID");
 
   // make sure eventlog file and sqlite WERE created in the correct spot
-  EXPECT_EQ(0, stat((string(testLogDir) + "/event_history_log.txt").c_str(), &sb));
+  struct stat sb;
+  EXPECT_EQ(0, stat((string(logDir) + "/event_history_log.txt").c_str(), &sb));
   EXPECT_TRUE(S_ISREG(sb.st_mode));
 
-  EXPECT_EQ(0, stat((string(testLogDir) + "/event_history_db.sqlite3").c_str(), &sb));
+  EXPECT_EQ(0, stat((string(logDir) + "/event_history_db.sqlite3").c_str(), &sb));
   EXPECT_TRUE(S_ISREG(sb.st_mode));
 }
 

Modified: incubator/mesos/trunk/src/tests/test_master.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/test_master.cpp?rev=1132152&r1=1132151&r2=1132152&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/test_master.cpp (original)
+++ incubator/mesos/trunk/src/tests/test_master.cpp Sun Jun  5 08:51:30 2011
@@ -5,7 +5,9 @@
 #include <mesos_exec.hpp>
 #include <mesos_sched.hpp>
 
-#include "event_history/event_history.hpp"
+#include "common/date_utils.hpp"
+
+#include "event_history/event_logger.hpp"
 
 #include "local/local.hpp"
 
@@ -134,123 +136,137 @@ public:
 TEST(MasterTest, DuplicateTaskIdsInResponse)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
+  DateUtils::setMockDate("200102030405");
   PID master = local::launch(1, 3, 3 * Gigabyte, false, false);
   vector<TaskDescription> tasks;
   map<string, string> params;
   params["cpus"] = "1";
   params["mem"] = lexical_cast<string>(1 * Gigabyte);
-  tasks.push_back(TaskDescription(1, "0-0", "", params, ""));
-  tasks.push_back(TaskDescription(2, "0-0", "", params, ""));
-  tasks.push_back(TaskDescription(1, "0-0", "", params, ""));
+  tasks.push_back(TaskDescription(1, "200102030405-0-0", "", params, ""));
+  tasks.push_back(TaskDescription(2, "200102030405-0-0", "", params, ""));
+  tasks.push_back(TaskDescription(1, "200102030405-0-0", "", params, ""));
   FixedResponseScheduler sched(tasks);
   MesosSchedulerDriver driver(&sched, master);
   driver.run();
   EXPECT_EQ("Duplicate task ID: 1", sched.errorMessage);
   local::shutdown();
+  DateUtils::clearMockDate();
 }
 
 
 TEST(MasterTest, TooMuchMemoryInTask)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
+  DateUtils::setMockDate("200102030405");
   PID master = local::launch(1, 3, 3 * Gigabyte, false, false);
   vector<TaskDescription> tasks;
   map<string, string> params;
   params["cpus"] = "1";
   params["mem"] = lexical_cast<string>(4 * Gigabyte);
-  tasks.push_back(TaskDescription(1, "0-0", "", params, ""));
+  tasks.push_back(TaskDescription(1, "200102030405-0-0", "", params, ""));
   FixedResponseScheduler sched(tasks);
   MesosSchedulerDriver driver(&sched, master);
   driver.run();
   EXPECT_EQ("Too many resources accepted", sched.errorMessage);
   local::shutdown();
+  DateUtils::clearMockDate();
 }
 
 
 TEST(MasterTest, TooMuchCpuInTask)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
+  DateUtils::setMockDate("200102030405");
   PID master = local::launch(1, 3, 3 * Gigabyte, false, false);
   vector<TaskDescription> tasks;
   map<string, string> params;
   params["cpus"] = "4";
   params["mem"] = lexical_cast<string>(1 * Gigabyte);
-  tasks.push_back(TaskDescription(1, "0-0", "", params, ""));
+  tasks.push_back(TaskDescription(1, "200102030405-0-0", "", params, ""));
   FixedResponseScheduler sched(tasks);
   MesosSchedulerDriver driver(&sched, master);
   driver.run();
   EXPECT_EQ("Too many resources accepted", sched.errorMessage);
   local::shutdown();
+  DateUtils::clearMockDate();
 }
 
 
 TEST(MasterTest, TooLittleCpuInTask)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
+  DateUtils::setMockDate("200102030405");
   PID master = local::launch(1, 3, 3 * Gigabyte, false, false);
   vector<TaskDescription> tasks;
   map<string, string> params;
   params["cpus"] = "0";
   params["mem"] = lexical_cast<string>(1 * Gigabyte);
-  tasks.push_back(TaskDescription(1, "0-0", "", params, ""));
+  tasks.push_back(TaskDescription(1, "200102030405-0-0", "", params, ""));
   FixedResponseScheduler sched(tasks);
   MesosSchedulerDriver driver(&sched, master);
   driver.run();
   EXPECT_EQ("Invalid task size: <0 CPUs, 1024 MEM>", sched.errorMessage);
   local::shutdown();
+  DateUtils::clearMockDate();
 }
 
 
 TEST(MasterTest, TooLittleMemoryInTask)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
+  DateUtils::setMockDate("200102030405");
   PID master = local::launch(1, 3, 3 * Gigabyte, false, false);
   vector<TaskDescription> tasks;
   map<string, string> params;
   params["cpus"] = "1";
   params["mem"] = "1";
-  tasks.push_back(TaskDescription(1, "0-0", "", params, ""));
+  tasks.push_back(TaskDescription(1, "200102030405-0-0", "", params, ""));
   FixedResponseScheduler sched(tasks);
   MesosSchedulerDriver driver(&sched, master);
   driver.run();
   EXPECT_EQ("Invalid task size: <1 CPUs, 1 MEM>", sched.errorMessage);
   local::shutdown();
+  DateUtils::clearMockDate();
 }
 
 
 TEST(MasterTest, TooMuchMemoryAcrossTasks)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
+  DateUtils::setMockDate("200102030405");
   PID master = local::launch(1, 3, 3 * Gigabyte, false, false);
   vector<TaskDescription> tasks;
   map<string, string> params;
   params["cpus"] = "1";
   params["mem"] = lexical_cast<string>(2 * Gigabyte);
-  tasks.push_back(TaskDescription(1, "0-0", "", params, ""));
-  tasks.push_back(TaskDescription(2, "0-0", "", params, ""));
+  tasks.push_back(TaskDescription(1, "200102030405-0-0", "", params, ""));
+  tasks.push_back(TaskDescription(2, "200102030405-0-0", "", params, ""));
   FixedResponseScheduler sched(tasks);
   MesosSchedulerDriver driver(&sched, master);
   driver.run();
   EXPECT_EQ("Too many resources accepted", sched.errorMessage);
   local::shutdown();
+  DateUtils::clearMockDate();
 }
 
 
 TEST(MasterTest, TooMuchCpuAcrossTasks)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
+  DateUtils::setMockDate("200102030405");
   PID master = local::launch(1, 3, 3 * Gigabyte, false, false);
   vector<TaskDescription> tasks;
   map<string, string> params;
   params["cpus"] = "2";
   params["mem"] = lexical_cast<string>(1 * Gigabyte);
-  tasks.push_back(TaskDescription(1, "0-0", "", params, ""));
-  tasks.push_back(TaskDescription(2, "0-0", "", params, ""));
+  tasks.push_back(TaskDescription(1, "200102030405-0-0", "", params, ""));
+  tasks.push_back(TaskDescription(2, "200102030405-0-0", "", params, ""));
   FixedResponseScheduler sched(tasks);
   MesosSchedulerDriver driver(&sched, master);
   driver.run();
   EXPECT_EQ("Too many resources accepted", sched.errorMessage);
   local::shutdown();
+  DateUtils::clearMockDate();
 }
 
 
@@ -278,13 +294,14 @@ TEST(MasterTest, ResourcesReofferedAfter
 TEST(MasterTest, ResourcesReofferedAfterBadResponse)
 {
   ASSERT_TRUE(GTEST_IS_THREADSAFE);
+  DateUtils::setMockDate("200102030405");
   PID master = local::launch(1, 2, 1 * Gigabyte, false, false);
 
   vector<TaskDescription> tasks;
   map<string, string> params;
   params["cpus"] = "0";
   params["mem"] = lexical_cast<string>(1 * Gigabyte);
-  tasks.push_back(TaskDescription(1, "0-0", "", params, ""));
+  tasks.push_back(TaskDescription(1, "200102030405-0-0", "", params, ""));
   FixedResponseScheduler sched1(tasks);
   MesosSchedulerDriver driver1(&sched1, master);
   driver1.run();
@@ -297,6 +314,7 @@ TEST(MasterTest, ResourcesReofferedAfter
   EXPECT_EQ(1, sched2.offersGotten);
 
   local::shutdown();
+  DateUtils::clearMockDate();
 }