Repository: mesos
Updated Branches:
  refs/heads/master 0d53c395c -> ec5bdeab8


Speed up FetcherCacheTest.Local* test by reduce loop.

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


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

Branch: refs/heads/master
Commit: ec5bdeab8d35085c20453522c8a79dde865d502d
Parents: 0d53c39
Author: haosdent huang <[email protected]>
Authored: Wed Feb 17 10:37:43 2016 +0100
Committer: Bernd Mathiske <[email protected]>
Committed: Wed Feb 17 10:37:43 2016 +0100

----------------------------------------------------------------------
 src/tests/fetcher_cache_tests.cpp | 80 +++++++++++++++++-----------------
 1 file changed, 39 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ec5bdeab/src/tests/fetcher_cache_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/fetcher_cache_tests.cpp 
b/src/tests/fetcher_cache_tests.cpp
index fc89be4..f9c48f5 100644
--- a/src/tests/fetcher_cache_tests.cpp
+++ b/src/tests/fetcher_cache_tests.cpp
@@ -596,28 +596,27 @@ TEST_F(FetcherCacheTest, LocalUncached)
   startSlave();
   driver->start();
 
-  for (size_t i = 0; i < 3; i++) {
-    CommandInfo::URI uri;
-    uri.set_value(commandPath);
-    uri.set_executable(true);
+  const int index = 0;
+  CommandInfo::URI uri;
+  uri.set_value(commandPath);
+  uri.set_executable(true);
 
-    CommandInfo commandInfo;
-    commandInfo.set_value("./" + COMMAND_NAME + " " + taskName(i));
-    commandInfo.add_uris()->CopyFrom(uri);
+  CommandInfo commandInfo;
+  commandInfo.set_value("./" + COMMAND_NAME + " " + taskName(index));
+  commandInfo.add_uris()->CopyFrom(uri);
 
-    const Try<Task> task = launchTask(commandInfo, i);
-    ASSERT_SOME(task);
+  const Try<Task> task = launchTask(commandInfo, index);
+  ASSERT_SOME(task);
 
-    AWAIT_READY(awaitFinished(task.get()));
+  AWAIT_READY(awaitFinished(task.get()));
 
-    EXPECT_EQ(0u, fetcherProcess->cacheSize());
-    ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
-    EXPECT_EQ(0u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
+  EXPECT_EQ(0u, fetcherProcess->cacheSize());
+  ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
+  EXPECT_EQ(0u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
 
-    const string path = path::join(task.get().runDirectory.value, 
COMMAND_NAME);
-    EXPECT_TRUE(isExecutable(path));
-    EXPECT_TRUE(os::exists(path + taskName(i)));
-  }
+  const string path = path::join(task.get().runDirectory.value, COMMAND_NAME);
+  EXPECT_TRUE(isExecutable(path));
+  EXPECT_TRUE(os::exists(path + taskName(index)));
 }
 
 
@@ -629,7 +628,7 @@ TEST_F(FetcherCacheTest, LocalCached)
   startSlave();
   driver->start();
 
-  for (size_t i = 0; i < 3; i++) {
+  for (size_t i = 0; i < 2; i++) {
     CommandInfo::URI uri;
     uri.set_value(commandPath);
     uri.set_executable(true);
@@ -711,34 +710,33 @@ TEST_F(FetcherCacheTest, LocalUncachedExtract)
   startSlave();
   driver->start();
 
-  for (size_t i = 0; i < 3; i++) {
-    CommandInfo::URI uri;
-    uri.set_value(archivePath);
-    uri.set_extract(true);
+  const int index = 0;
+  CommandInfo::URI uri;
+  uri.set_value(archivePath);
+  uri.set_extract(true);
 
-    CommandInfo commandInfo;
-    commandInfo.set_value("./" + ARCHIVED_COMMAND_NAME + " " + taskName(i));
-    commandInfo.add_uris()->CopyFrom(uri);
+  CommandInfo commandInfo;
+  commandInfo.set_value("./" + ARCHIVED_COMMAND_NAME + " " + taskName(index));
+  commandInfo.add_uris()->CopyFrom(uri);
 
-    const Try<Task> task = launchTask(commandInfo, i);
-    ASSERT_SOME(task);
+  const Try<Task> task = launchTask(commandInfo, index);
+  ASSERT_SOME(task);
 
-    AWAIT_READY(awaitFinished(task.get()));
+  AWAIT_READY(awaitFinished(task.get()));
 
-    EXPECT_TRUE(os::exists(
-        path::join(task.get().runDirectory.value, ARCHIVE_NAME)));
-    EXPECT_FALSE(isExecutable(
-        path::join(task.get().runDirectory.value, ARCHIVE_NAME)));
+  EXPECT_TRUE(os::exists(
+      path::join(task.get().runDirectory.value, ARCHIVE_NAME)));
+  EXPECT_FALSE(isExecutable(
+      path::join(task.get().runDirectory.value, ARCHIVE_NAME)));
 
-    const string path =
-      path::join(task.get().runDirectory.value, ARCHIVED_COMMAND_NAME);
-    EXPECT_TRUE(isExecutable(path));
-    EXPECT_TRUE(os::exists(path + taskName(i)));
+  const string path =
+    path::join(task.get().runDirectory.value, ARCHIVED_COMMAND_NAME);
+  EXPECT_TRUE(isExecutable(path));
+  EXPECT_TRUE(os::exists(path + taskName(index)));
 
-    EXPECT_EQ(0u, fetcherProcess->cacheSize());
-    ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
-    EXPECT_EQ(0u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
-  }
+  EXPECT_EQ(0u, fetcherProcess->cacheSize());
+  ASSERT_SOME(fetcherProcess->cacheFiles(slaveId, flags));
+  EXPECT_EQ(0u, fetcherProcess->cacheFiles(slaveId, flags).get().size());
 }
 
 
@@ -748,7 +746,7 @@ TEST_F(FetcherCacheTest, LocalCachedExtract)
   startSlave();
   driver->start();
 
-  for (size_t i = 0; i < 3; i++) {
+  for (size_t i = 0; i < 2; i++) {
     CommandInfo::URI uri;
     uri.set_value(archivePath);
     uri.set_extract(true);

Reply via email to