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 2016/10/04 02:20:50 UTC

[4/4] mesos git commit: Refactored some test create* functions.

Refactored some test create* functions.

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


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

Branch: refs/heads/master
Commit: a450d82934b459f1272d8de1a16e955c7d94e116
Parents: bb397f4
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sun Oct 2 17:30:10 2016 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Mon Oct 3 19:20:26 2016 -0700

----------------------------------------------------------------------
 .../containerizer/filesystem_isolator_tests.cpp | 58 +++++------------
 src/tests/containerizer/isolator_tests.cpp      |  6 +-
 .../containerizer/mesos_containerizer_tests.cpp | 22 +++----
 .../volume_sandbox_path_isolator_tests.cpp      |  7 +-
 src/tests/gc_tests.cpp                          |  4 +-
 src/tests/hook_tests.cpp                        |  5 +-
 src/tests/master_allocator_tests.cpp            |  4 +-
 src/tests/master_authorization_tests.cpp        | 10 +--
 src/tests/master_maintenance_tests.cpp          |  4 +-
 src/tests/master_tests.cpp                      |  4 +-
 src/tests/mesos.hpp                             | 68 ++++++++++++++------
 src/tests/slave_authorization_tests.cpp         |  2 +-
 12 files changed, 98 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a450d829/src/tests/containerizer/filesystem_isolator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/filesystem_isolator_tests.cpp b/src/tests/containerizer/filesystem_isolator_tests.cpp
index 3b34b8c..5b6a1d4 100644
--- a/src/tests/containerizer/filesystem_isolator_tests.cpp
+++ b/src/tests/containerizer/filesystem_isolator_tests.cpp
@@ -218,32 +218,6 @@ protected:
     return info;
   }
 
-  Volume createVolumeFromHostPath(
-      const string& containerPath,
-      const string& hostPath,
-      const Volume::Mode& mode)
-  {
-    return CREATE_VOLUME(containerPath, hostPath, mode);
-  }
-
-  Volume createVolumeFromImage(
-      const string& containerPath,
-      const string& imageName,
-      const Volume::Mode& mode)
-  {
-    Volume volume;
-    volume.set_container_path(containerPath);
-    volume.set_mode(mode);
-
-    Image* image = volume.mutable_image();
-    image->set_type(Image::APPC);
-
-    Image::Appc* appc = image->mutable_appc();
-    appc->set_name(imageName);
-
-    return volume;
-  }
-
 private:
   Fetcher fetcher;
 };
@@ -264,7 +238,7 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_ChangeRootFilesystem)
 
   ASSERT_SOME(containerizer);
 
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO(
+  ExecutorInfo executor = createExecutorInfo(
       "test_executor",
       "[ ! -d '" + os::getcwd() + "' ]");
 
@@ -781,7 +755,7 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_Metrics)
   ASSERT_SOME(containerizer);
 
   // Use a long running task so we can reliably capture the moment it's alive.
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO(
+  ExecutorInfo executor = createExecutorInfo(
       "test_executor",
       "sleep 1000");
 
@@ -842,7 +816,7 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_VolumeFromSandbox)
 
   ASSERT_SOME(containerizer);
 
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO(
+  ExecutorInfo executor = createExecutorInfo(
       "test_executor",
       "echo abc > /tmp/file");
 
@@ -898,7 +872,7 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_VolumeFromHost)
 
   ASSERT_SOME(containerizer);
 
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO(
+  ExecutorInfo executor = createExecutorInfo(
       "test_executor",
       "test -d /tmp/sandbox");
 
@@ -952,7 +926,7 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_FileVolumeFromHost)
 
   ASSERT_SOME(containerizer);
 
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO(
+  ExecutorInfo executor = createExecutorInfo(
       "test_executor",
       "test -f /tmp/test/file.txt");
 
@@ -1006,7 +980,7 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_VolumeFromHostSandboxMountPoint)
 
   ASSERT_SOME(containerizer);
 
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO(
+  ExecutorInfo executor = createExecutorInfo(
       "test_executor",
       "test -d mountpoint/sandbox");
 
@@ -1060,7 +1034,7 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_FileVolumeFromHostSandboxMountPoint)
 
   ASSERT_SOME(containerizer);
 
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO(
+  ExecutorInfo executor = createExecutorInfo(
       "test_executor",
       "test -f mountpoint/file.txt");
 
@@ -1117,7 +1091,7 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_PersistentVolumeWithRootFilesystem)
 
   ASSERT_SOME(containerizer);
 
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO(
+  ExecutorInfo executor = createExecutorInfo(
       "test_executor",
       "echo abc > volume/file");
 
@@ -1186,7 +1160,7 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_PersistentVolumeWithoutRootFilesystem)
 
   ASSERT_SOME(containerizer);
 
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO(
+  ExecutorInfo executor = createExecutorInfo(
       "test_executor",
       "echo abc > volume/file");
 
@@ -1260,13 +1234,13 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_ImageInVolumeWithoutRootFilesystem)
 
   ASSERT_SOME(containerizer);
 
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO(
+  ExecutorInfo executor = createExecutorInfo(
       "test_executor",
       "test -d rootfs/bin");
 
   executor.mutable_container()->CopyFrom(createContainerInfo(
       None(),
-      {createVolumeFromImage("rootfs", "test_image", Volume::RW)}));
+      {createVolumeFromAppcImage("rootfs", "test_image", Volume::RW)}));
 
   string directory = path::join(os::getcwd(), "sandbox");
   ASSERT_SOME(os::mkdir(directory));
@@ -1316,13 +1290,13 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_ImageInVolumeWithRootFilesystem)
 
   ASSERT_SOME(containerizer);
 
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO(
+  ExecutorInfo executor = createExecutorInfo(
       "test_executor",
       "[ ! -d '" + os::getcwd() + "' ] && [ -d rootfs/bin ]");
 
   executor.mutable_container()->CopyFrom(createContainerInfo(
       "test_image_rootfs",
-      {createVolumeFromImage("rootfs", "test_image_volume", Volume::RW)}));
+      {createVolumeFromAppcImage("rootfs", "test_image_volume", Volume::RW)}));
 
   string directory = path::join(os::getcwd(), "sandbox");
   ASSERT_SOME(os::mkdir(directory));
@@ -1385,7 +1359,7 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_MultipleContainers)
   // First launch container 1 which has a long running task which
   // guarantees that its work directory mount is in the host mount
   // table when container 2 is launched.
-  ExecutorInfo executor1 = CREATE_EXECUTOR_INFO(
+  ExecutorInfo executor1 = createExecutorInfo(
       "test_executor1",
       "sleep 1000"); // Long running task.
 
@@ -1429,7 +1403,7 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_MultipleContainers)
 
   // Now launch container 2 which will copy the host mount table with
   // container 1's work directory mount in it.
-  ExecutorInfo executor2 = CREATE_EXECUTOR_INFO(
+  ExecutorInfo executor2 = createExecutorInfo(
       "test_executor2",
       "[ ! -d '" + os::getcwd() + "' ]");
 
@@ -1506,7 +1480,7 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_SandboxEnvironmentVariable)
 
   ASSERT_SOME(script);
 
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO(
+  ExecutorInfo executor = createExecutorInfo(
       "test_executor",
       script.get());
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/a450d829/src/tests/containerizer/isolator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/isolator_tests.cpp b/src/tests/containerizer/isolator_tests.cpp
index 9458e7e..8fefeef 100644
--- a/src/tests/containerizer/isolator_tests.cpp
+++ b/src/tests/containerizer/isolator_tests.cpp
@@ -134,7 +134,7 @@ TEST_F(SharedFilesystemIsolatorTest, DISABLED_ROOT_RelativeVolume)
   ContainerInfo containerInfo;
   containerInfo.set_type(ContainerInfo::MESOS);
   containerInfo.add_volumes()->CopyFrom(
-      CREATE_VOLUME(containerPath, hostPath, Volume::RW));
+      createVolumeFromHostPath(containerPath, hostPath, Volume::RW));
 
   ExecutorInfo executorInfo;
   executorInfo.mutable_container()->CopyFrom(containerInfo);
@@ -240,7 +240,7 @@ TEST_F(SharedFilesystemIsolatorTest, DISABLED_ROOT_AbsoluteVolume)
   ContainerInfo containerInfo;
   containerInfo.set_type(ContainerInfo::MESOS);
   containerInfo.add_volumes()->CopyFrom(
-      CREATE_VOLUME(containerPath, hostPath, Volume::RW));
+      createVolumeFromHostPath(containerPath, hostPath, Volume::RW));
 
   ExecutorInfo executorInfo;
   executorInfo.mutable_container()->CopyFrom(containerInfo);
@@ -329,7 +329,7 @@ TEST_F(NamespacesPidIsolatorTest, ROOT_PidNamespace)
   process::Future<bool> launch = containerizer->launch(
       containerId,
       None(),
-      CREATE_EXECUTOR_INFO("executor", command),
+      createExecutorInfo("executor", command),
       directory,
       None(),
       SlaveID(),

http://git-wip-us.apache.org/repos/asf/mesos/blob/a450d829/src/tests/containerizer/mesos_containerizer_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/mesos_containerizer_tests.cpp b/src/tests/containerizer/mesos_containerizer_tests.cpp
index 8b5a19e..44093ce 100644
--- a/src/tests/containerizer/mesos_containerizer_tests.cpp
+++ b/src/tests/containerizer/mesos_containerizer_tests.cpp
@@ -204,7 +204,7 @@ TEST_F(MesosContainerizerIsolatorPreparationTest, ScriptSucceeds)
   Future<bool> launch = containerizer.get()->launch(
       containerId,
       None(),
-      CREATE_EXECUTOR_INFO("executor", "exit 0"),
+      createExecutorInfo("executor", "exit 0"),
       directory,
       None(),
       SlaveID(),
@@ -257,7 +257,7 @@ TEST_F(MesosContainerizerIsolatorPreparationTest, ScriptFails)
   Future<bool> launch = containerizer.get()->launch(
       containerId,
       None(),
-      CREATE_EXECUTOR_INFO("executor", "exit 0"),
+      createExecutorInfo("executor", "exit 0"),
       directory,
       None(),
       SlaveID(),
@@ -321,7 +321,7 @@ TEST_F(MesosContainerizerIsolatorPreparationTest, MultipleScripts)
   Future<bool> launch = containerizer.get()->launch(
       containerId,
       None(),
-      CREATE_EXECUTOR_INFO("executor", "exit 0"),
+      createExecutorInfo("executor", "exit 0"),
       directory,
       None(),
       SlaveID(),
@@ -389,7 +389,7 @@ TEST_F(MesosContainerizerIsolatorPreparationTest, ExecutorEnvironmentVariable)
     "if [ -n \"$LIBPROCESS_IP\" ]; "
     "then touch $TEST_ENVIRONMENT; fi";
 
-  ExecutorInfo executorInfo = CREATE_EXECUTOR_INFO("executor", executorCmd);
+  ExecutorInfo executorInfo = createExecutorInfo("executor", executorCmd);
   SlaveID slaveId = SlaveID();
 
   slave::Flags flags;
@@ -470,7 +470,7 @@ TEST_F(MesosContainerizerExecuteTest, IoRedirection)
   Future<bool> launch = containerizer->launch(
       containerId,
       None(),
-      CREATE_EXECUTOR_INFO("executor", command),
+      createExecutorInfo("executor", command),
       directory,
       None(),
       SlaveID(),
@@ -659,7 +659,7 @@ TEST_F(MesosContainerizerDestroyTest, DestroyWhileFetching)
   containerizer.launch(
       containerId,
       taskInfo,
-      CREATE_EXECUTOR_INFO("executor", "exit 0"),
+      createExecutorInfo("executor", "exit 0"),
       os::getcwd(),
       None(),
       SlaveID(),
@@ -730,7 +730,7 @@ TEST_F(MesosContainerizerDestroyTest, DestroyWhilePreparing)
   containerizer.launch(
       containerId,
       taskInfo,
-      CREATE_EXECUTOR_INFO("executor", "exit 0"),
+      createExecutorInfo("executor", "exit 0"),
       os::getcwd(),
       None(),
       SlaveID(),
@@ -866,7 +866,7 @@ TEST_F(MesosContainerizerProvisionerTest, ProvisionFailed)
   taskInfo.mutable_command()->MergeFrom(commandInfo);
   taskInfo.mutable_container()->CopyFrom(containerInfo);
 
-  ExecutorInfo executorInfo = CREATE_EXECUTOR_INFO("executor", "exit 0");
+  ExecutorInfo executorInfo = createExecutorInfo("executor", "exit 0");
   executorInfo.mutable_container()->CopyFrom(containerInfo);
 
   Future<bool> launch = containerizer.launch(
@@ -961,7 +961,7 @@ TEST_F(MesosContainerizerProvisionerTest, DestroyWhileProvisioning)
   taskInfo.mutable_command()->MergeFrom(commandInfo);
   taskInfo.mutable_container()->CopyFrom(containerInfo);
 
-  ExecutorInfo executorInfo = CREATE_EXECUTOR_INFO("executor", "exit 0");
+  ExecutorInfo executorInfo = createExecutorInfo("executor", "exit 0");
   executorInfo.mutable_container()->CopyFrom(containerInfo);
 
   Future<bool> launch = containerizer.launch(
@@ -1063,7 +1063,7 @@ TEST_F(MesosContainerizerProvisionerTest, IsolatorCleanupBeforePrepare)
   taskInfo.mutable_command()->MergeFrom(commandInfo);
   taskInfo.mutable_container()->CopyFrom(containerInfo);
 
-  ExecutorInfo executorInfo = CREATE_EXECUTOR_INFO("executor", "exit 0");
+  ExecutorInfo executorInfo = createExecutorInfo("executor", "exit 0");
   executorInfo.mutable_container()->CopyFrom(containerInfo);
 
   Future<bool> launch = containerizer.launch(
@@ -1155,7 +1155,7 @@ TEST_F(MesosContainerizerDestroyTest, LauncherDestroyFailure)
   Future<bool> launch = containerizer.launch(
       containerId,
       taskInfo,
-      CREATE_EXECUTOR_INFO("executor", "sleep 1000"),
+      createExecutorInfo("executor", "sleep 1000"),
       os::getcwd(),
       None(),
       SlaveID(),

http://git-wip-us.apache.org/repos/asf/mesos/blob/a450d829/src/tests/containerizer/volume_sandbox_path_isolator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/volume_sandbox_path_isolator_tests.cpp b/src/tests/containerizer/volume_sandbox_path_isolator_tests.cpp
index d4f074a..f873e28 100644
--- a/src/tests/containerizer/volume_sandbox_path_isolator_tests.cpp
+++ b/src/tests/containerizer/volume_sandbox_path_isolator_tests.cpp
@@ -69,8 +69,7 @@ TEST_F(VolumeSandboxPathIsolatorTest, SharedVolume)
   ContainerID containerId;
   containerId.set_value(UUID::random().toString());
 
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO("executor", "sleep 1000");
-  executor.mutable_resources()->CopyFrom(Resources::parse("cpus:1").get());
+  ExecutorInfo executor = createExecutorInfo("executor", "sleep 99", "cpus:1");
 
   Try<string> directory = environment->mkdtemp();
   ASSERT_SOME(directory);
@@ -107,7 +106,7 @@ TEST_F(VolumeSandboxPathIsolatorTest, SharedVolume)
 
   launch = containerizer->launch(
       nestedContainerId1,
-      CREATE_COMMAND_INFO("touch parent/file; sleep 1000"),
+      createCommandInfo("touch parent/file; sleep 1000"),
       containerInfo,
       None(),
       state.id);
@@ -120,7 +119,7 @@ TEST_F(VolumeSandboxPathIsolatorTest, SharedVolume)
 
   launch = containerizer->launch(
       nestedContainerId2,
-      CREATE_COMMAND_INFO(
+      createCommandInfo(
         "while true; do if [ -f parent/file ]; then exit 0; fi; done"),
       containerInfo,
       None(),

http://git-wip-us.apache.org/repos/asf/mesos/blob/a450d829/src/tests/gc_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/gc_tests.cpp b/src/tests/gc_tests.cpp
index f3aec4a..d9776b6 100644
--- a/src/tests/gc_tests.cpp
+++ b/src/tests/gc_tests.cpp
@@ -735,8 +735,8 @@ TEST_F(GarbageCollectorIntegrationTest, Unschedule)
   Future<SlaveRegisteredMessage> slaveRegistered =
     FUTURE_PROTOBUF(SlaveRegisteredMessage(), _, _);
 
-  ExecutorInfo executor1 = CREATE_EXECUTOR_INFO("executor-1", "exit 1");
-  ExecutorInfo executor2 = CREATE_EXECUTOR_INFO("executor-2", "exit 1");
+  ExecutorInfo executor1 = createExecutorInfo("executor-1", "exit 1");
+  ExecutorInfo executor2 = createExecutorInfo("executor-2", "exit 1");
 
   MockExecutor exec1(executor1.executor_id());
   MockExecutor exec2(executor2.executor_id());

http://git-wip-us.apache.org/repos/asf/mesos/blob/a450d829/src/tests/hook_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hook_tests.cpp b/src/tests/hook_tests.cpp
index f837ca7..d334d6c 100644
--- a/src/tests/hook_tests.cpp
+++ b/src/tests/hook_tests.cpp
@@ -294,8 +294,9 @@ TEST_F(HookTest, VerifySlaveExecutorEnvironmentDecorator)
   ContainerID containerId;
   containerId.set_value("test_container");
 
-  ExecutorInfo executorInfo =
-    CREATE_EXECUTOR_INFO("executor", "test $FOO = 'bar'");
+  ExecutorInfo executorInfo = createExecutorInfo(
+      "executor",
+      "test $FOO = 'bar'");
 
   SlaveID slaveId = SlaveID();
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/a450d829/src/tests/master_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_allocator_tests.cpp b/src/tests/master_allocator_tests.cpp
index b4ecd46..bb94e38 100644
--- a/src/tests/master_allocator_tests.cpp
+++ b/src/tests/master_allocator_tests.cpp
@@ -572,8 +572,8 @@ TYPED_TEST(MasterAllocatorTest, FrameworkExited)
     this->StartMaster(&allocator, masterFlags);
   ASSERT_SOME(master);
 
-  ExecutorInfo executor1 = CREATE_EXECUTOR_INFO("executor-1", "exit 1");
-  ExecutorInfo executor2 = CREATE_EXECUTOR_INFO("executor-2", "exit 1");
+  ExecutorInfo executor1 = createExecutorInfo("executor-1", "exit 1");
+  ExecutorInfo executor2 = createExecutorInfo("executor-2", "exit 1");
 
   MockExecutor exec1(executor1.executor_id());
   MockExecutor exec2(executor2.executor_id());

http://git-wip-us.apache.org/repos/asf/mesos/blob/a450d829/src/tests/master_authorization_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_authorization_tests.cpp b/src/tests/master_authorization_tests.cpp
index 5d08ebc..a4623d1 100644
--- a/src/tests/master_authorization_tests.cpp
+++ b/src/tests/master_authorization_tests.cpp
@@ -108,7 +108,7 @@ TEST_F(MasterAuthorizationTest, AuthorizedTask)
   ASSERT_SOME(master);
 
   // Create an authorized executor.
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO("test-executor", "exit 1");
+  ExecutorInfo executor = createExecutorInfo("test-executor", "exit 1");
   executor.mutable_command()->set_user("foo");
 
   MockExecutor exec(executor.executor_id());
@@ -182,7 +182,7 @@ TEST_F(MasterAuthorizationTest, UnauthorizedTask)
   ASSERT_SOME(master);
 
   // Create an unauthorized executor.
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO("test-executor", "exit 1");
+  ExecutorInfo executor = createExecutorInfo("test-executor", "exit 1");
   executor.mutable_command()->set_user("foo");
 
   MockExecutor exec(executor.executor_id());
@@ -1498,7 +1498,7 @@ TYPED_TEST(MasterAuthorizerTest, FilterStateEndpoint)
   frameworkInfo.set_user(user);
 
   // Create an executor with user "bar".
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO("test-executor", "sleep 2");
+  ExecutorInfo executor = createExecutorInfo("test-executor", "sleep 2");
   executor.mutable_command()->set_user(user);
 
   MockExecutor exec(executor.executor_id());
@@ -1687,7 +1687,7 @@ TYPED_TEST(MasterAuthorizerTest, FilterFrameworksEndpoint)
   frameworkInfo.set_user("bar");
 
   // Create an executor with user "bar".
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO("test-executor", "sleep 2");
+  ExecutorInfo executor = createExecutorInfo("test-executor", "sleep 2");
   executor.mutable_command()->set_user("bar");
 
   MockExecutor exec(executor.executor_id());
@@ -1878,7 +1878,7 @@ TYPED_TEST(MasterAuthorizerTest, FilterTasksEndpoint)
   frameworkInfo.set_user(user);
 
   // Create an executor with user "bar".
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO("test-executor", "sleep 2");
+  ExecutorInfo executor = createExecutorInfo("test-executor", "sleep 2");
   executor.mutable_command()->set_user(user);
 
   MockExecutor exec(executor.executor_id());

http://git-wip-us.apache.org/repos/asf/mesos/blob/a450d829/src/tests/master_maintenance_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_maintenance_tests.cpp b/src/tests/master_maintenance_tests.cpp
index 0820e63..77eb405 100644
--- a/src/tests/master_maintenance_tests.cpp
+++ b/src/tests/master_maintenance_tests.cpp
@@ -1394,8 +1394,8 @@ TEST_F(MasterMaintenanceTest, InverseOffersFilters)
   Try<Owned<cluster::Master>> master = StartMaster(flags);
   ASSERT_SOME(master);
 
-  ExecutorInfo executor1 = CREATE_EXECUTOR_INFO("executor-1", "exit 1");
-  ExecutorInfo executor2 = CREATE_EXECUTOR_INFO("executor-2", "exit 2");
+  ExecutorInfo executor1 = createExecutorInfo("executor-1", "exit 1");
+  ExecutorInfo executor2 = createExecutorInfo("executor-2", "exit 2");
 
   MockExecutor exec1(executor1.executor_id());
   MockExecutor exec2(executor2.executor_id());

http://git-wip-us.apache.org/repos/asf/mesos/blob/a450d829/src/tests/master_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp
index e6c8362..88cf1e6 100644
--- a/src/tests/master_tests.cpp
+++ b/src/tests/master_tests.cpp
@@ -1004,8 +1004,8 @@ TEST_F(MasterTest, MultipleExecutors)
   Try<Owned<cluster::Master>> master = StartMaster();
   ASSERT_SOME(master);
 
-  ExecutorInfo executor1 = CREATE_EXECUTOR_INFO("executor-1", "exit 1");
-  ExecutorInfo executor2 = CREATE_EXECUTOR_INFO("executor-2", "exit 1");
+  ExecutorInfo executor1 = createExecutorInfo("executor-1", "exit 1");
+  ExecutorInfo executor2 = createExecutorInfo("executor-2", "exit 1");
 
   MockExecutor exec1(executor1.executor_id());
   MockExecutor exec2(executor2.executor_id());

http://git-wip-us.apache.org/repos/asf/mesos/blob/a450d829/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index 3876a08..a05e3e0 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -346,13 +346,6 @@ protected:
         executor; })
 
 
-#define CREATE_EXECUTOR_INFO(executorId, command)                       \
-      ({ ExecutorInfo executor;                                         \
-        executor.mutable_executor_id()->set_value(executorId);          \
-        executor.mutable_command()->set_value(command);                 \
-        executor; })
-
-
 #define DEFAULT_CREDENTIAL                                             \
      ({ Credential credential;                                         \
         credential.set_principal("test-principal");                    \
@@ -404,20 +397,55 @@ protected:
         containerId; })
 
 
-#define CREATE_COMMAND_INFO(command)                                  \
-  ({ CommandInfo commandInfo;                                         \
-     commandInfo.set_value(command);                                  \
-     commandInfo; })
+inline ExecutorInfo createExecutorInfo(
+    const std::string& executorId,
+    const std::string& command,
+    const Option<std::string>& resources = None())
+{
+  ExecutorInfo executor;
+  executor.mutable_executor_id()->set_value(executorId);
+  executor.mutable_command()->set_value(command);
+  if (resources.isSome()) {
+    executor.mutable_resources()->CopyFrom(
+        Resources::parse(resources.get()).get());
+  }
+  return executor;
+}
+
+
+inline CommandInfo createCommandInfo(const std::string& command)
+{
+  CommandInfo commandInfo;
+  commandInfo.set_value(command);
+  return commandInfo;
+}
+
 
+inline Volume createVolumeFromHostPath(
+    const std::string& containerPath,
+    const std::string& hostPath,
+    const Volume::Mode& mode)
+{
+  Volume volume;
+  volume.set_container_path(containerPath);
+  volume.set_host_path(hostPath);
+  volume.set_mode(mode);
+  return volume;
+}
 
-// TODO(jieyu): Consider making it a function to support more
-// overloads (e.g., createVolumeFromHost, createVolumeFromImage).
-#define CREATE_VOLUME(containerPath, hostPath, mode)                  \
-      ({ Volume volume;                                               \
-         volume.set_container_path(containerPath);                    \
-         volume.set_host_path(hostPath);                              \
-         volume.set_mode(mode);                                       \
-         volume; })
+
+inline Volume createVolumeFromAppcImage(
+    const std::string& containerPath,
+    const std::string& imageName,
+    const Volume::Mode& mode)
+{
+  Volume volume;
+  volume.set_container_path(containerPath);
+  volume.set_mode(mode);
+  volume.mutable_image()->set_type(Image::APPC);
+  volume.mutable_image()->mutable_appc()->set_name(imageName);
+  return volume;
+}
 
 
 // TODO(bmahler): Refactor this to make the distinction between
@@ -459,7 +487,7 @@ inline TaskInfo createTask(
   return createTask(
       slaveId,
       resources,
-      CREATE_COMMAND_INFO(command),
+      createCommandInfo(command),
       executorId,
       name,
       id);

http://git-wip-us.apache.org/repos/asf/mesos/blob/a450d829/src/tests/slave_authorization_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_authorization_tests.cpp b/src/tests/slave_authorization_tests.cpp
index 20bb712..6bd2aa9 100644
--- a/src/tests/slave_authorization_tests.cpp
+++ b/src/tests/slave_authorization_tests.cpp
@@ -148,7 +148,7 @@ TYPED_TEST(SlaveAuthorizerTest, FilterStateEndpoint)
   frameworkInfo.set_user("bar");
 
   // Create an executor with user "bar".
-  ExecutorInfo executor = CREATE_EXECUTOR_INFO("test-executor", "sleep 2");
+  ExecutorInfo executor = createExecutorInfo("test-executor", "sleep 2");
   executor.mutable_command()->set_user("bar");
 
   MockExecutor exec(executor.executor_id());