Repository: mesos
Updated Branches:
  refs/heads/master 9d82c6cd7 -> 3b4f7de7e


Added unit test for provisioner recursive listContainers().

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


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

Branch: refs/heads/master
Commit: 3b4f7de7ecbddba5fb3660831bb084d15db25a3d
Parents: 9d82c6c
Author: Gilbert Song <songzihao1...@gmail.com>
Authored: Thu Sep 8 16:49:04 2016 -0700
Committer: Jie Yu <yujie....@gmail.com>
Committed: Thu Sep 8 17:21:51 2016 -0700

----------------------------------------------------------------------
 src/Makefile.am                                 |  3 +-
 .../containerizer/provisioner_paths_tests.cpp   | 79 ++++++++++++++++++++
 2 files changed, 81 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3b4f7de7/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 15b9a63..fa71381 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2152,7 +2152,8 @@ mesos_tests_SOURCES =                                     
        \
   tests/containerizer/mesos_containerizer_tests.cpp            \
   tests/containerizer/provisioner_appc_tests.cpp               \
   tests/containerizer/provisioner_backend_tests.cpp            \
-  tests/containerizer/provisioner_docker_tests.cpp
+  tests/containerizer/provisioner_docker_tests.cpp             \
+  tests/containerizer/provisioner_paths_tests.cpp
 
 if ENABLE_XFS_DISK_ISOLATOR
 mesos_tests_SOURCES +=                                         \

http://git-wip-us.apache.org/repos/asf/mesos/blob/3b4f7de7/src/tests/containerizer/provisioner_paths_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/provisioner_paths_tests.cpp 
b/src/tests/containerizer/provisioner_paths_tests.cpp
new file mode 100644
index 0000000..b080562
--- /dev/null
+++ b/src/tests/containerizer/provisioner_paths_tests.cpp
@@ -0,0 +1,79 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <process/gtest.hpp>
+
+#include <stout/gtest.hpp>
+#include <stout/hashset.hpp>
+#include <stout/os.hpp>
+
+#include "slave/containerizer/mesos/provisioner/paths.hpp"
+
+#include "tests/mesos.hpp"
+
+namespace paths = mesos::internal::slave::provisioner::paths;
+
+using std::string;
+
+namespace mesos {
+namespace internal {
+namespace tests {
+
+class ProvisionerPathTest : public TemporaryDirectoryTest {};
+
+
+TEST_F(ProvisionerPathTest, ListProvisionerContainers)
+{
+  ContainerID child1;  // parent1/child1
+  ContainerID child2;  // parent1/child2
+  ContainerID child3;  // parent2/child3
+  ContainerID parent1; // parent1
+  ContainerID parent2; // parent2
+
+  child1.set_value("child1");
+  child1.mutable_parent()->set_value("parent1");
+  child2.set_value("child2");
+  child2.mutable_parent()->set_value("parent1");
+  child3.set_value("child3");
+  child3.mutable_parent()->set_value("parent2");
+  parent1.set_value("parent1");
+  parent2.set_value("parent2");
+
+  const string provisionerDir = os::getcwd();
+  const string containerDir1 = paths::getContainerDir(provisionerDir, child1);
+  const string containerDir2 = paths::getContainerDir(provisionerDir, child2);
+  const string containerDir3 = paths::getContainerDir(provisionerDir, child3);
+
+  ASSERT_SOME(os::mkdir(containerDir1));
+  ASSERT_SOME(os::mkdir(containerDir2));
+  ASSERT_SOME(os::mkdir(containerDir3));
+
+  Try<hashset<ContainerID>> containerIds =
+    paths::listContainers(provisionerDir);
+
+  ASSERT_SOME(containerIds);
+
+  EXPECT_TRUE(containerIds->contains(parent1));
+  EXPECT_TRUE(containerIds->contains(parent2));
+  EXPECT_TRUE(containerIds->contains(child1));
+  EXPECT_TRUE(containerIds->contains(child2));
+  EXPECT_TRUE(containerIds->contains(child3));
+  EXPECT_EQ(5u, containerIds->size());
+}
+
+} // namespace tests {
+} // namespace internal {
+} // namespace mesos {

Reply via email to