mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [mesos] 04/06: Moved a few allocator test helpers to `tests/allocator.hpp`.
Date Thu, 06 Dec 2018 22:45:32 GMT
This is an automated email from the ASF dual-hosted git repository.

mzhu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 80da1fca1a2b765e2868bd30fc6b306e164cce28
Author: Meng Zhu <mzhu@mesosphere.io>
AuthorDate: Thu Oct 18 10:49:38 2018 -0700

    Moved a few allocator test helpers to `tests/allocator.hpp`.
    
    This helps to share the helpers between
    `hierarchical_allocator_tests.cpp` and
    `hierarchical_allocator_benchmarks.cpp`.
    
    Review: https://reviews.apache.org/r/69096
---
 src/Makefile.am                            |  1 +
 src/tests/CMakeLists.txt                   |  1 +
 src/tests/allocator.cpp                    | 48 ++++++++++++++++++++++++++++++
 src/tests/allocator.hpp                    |  8 +++++
 src/tests/hierarchical_allocator_tests.cpp | 18 -----------
 5 files changed, 58 insertions(+), 18 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index df00617..3550051 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2450,6 +2450,7 @@ mesos_tests_SOURCES =						\
   tests/active_user_test_helper.cpp				\
   tests/active_user_test_helper.hpp				\
   tests/agent_container_api_tests.cpp				\
+  tests/allocator.cpp				    \
   tests/allocator.hpp						\
   tests/anonymous_tests.cpp					\
   tests/api_tests.cpp						\
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 553516a..c588183 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -41,6 +41,7 @@ endif ()
 #################
 set(MESOS_TESTS_UTILS_SRC
   active_user_test_helper.cpp
+  allocator.cpp
   cluster.cpp
   containerizer.cpp
   environment.cpp
diff --git a/src/tests/allocator.cpp b/src/tests/allocator.cpp
new file mode 100644
index 0000000..5534187
--- /dev/null
+++ b/src/tests/allocator.cpp
@@ -0,0 +1,48 @@
+// 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 <string>
+
+#include "tests/allocator.hpp"
+
+using std::string;
+
+namespace mesos {
+namespace internal {
+namespace tests {
+
+Quota createQuota(const string& role, const string& resources)
+{
+  mesos::quota::QuotaInfo quotaInfo;
+  quotaInfo.set_role(role);
+  *quotaInfo.mutable_guarantee() = CHECK_NOTERROR(Resources::parse(resources));
+
+  return Quota{quotaInfo};
+}
+
+
+WeightInfo createWeightInfo(const string& role, double weight)
+{
+  WeightInfo weightInfo;
+  weightInfo.set_role(role);
+  weightInfo.set_weight(weight);
+
+  return weightInfo;
+}
+
+} // namespace tests {
+} // namespace internal {
+} // namespace mesos {
diff --git a/src/tests/allocator.hpp b/src/tests/allocator.hpp
index 9437f58..0718bef 100644
--- a/src/tests/allocator.hpp
+++ b/src/tests/allocator.hpp
@@ -39,6 +39,14 @@ namespace mesos {
 namespace internal {
 namespace tests {
 
+// Allocator test helpers.
+
+Quota createQuota(const std::string& role, const std::string& resources);
+
+
+WeightInfo createWeightInfo(const std::string& role, double weight);
+
+
 // The following actions make up for the fact that DoDefault
 // cannot be used inside a DoAll, for example:
 // EXPECT_CALL(allocator, addFramework(_, _, _, _, _))
diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index ee49b83..a3a6d7b 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -248,15 +248,6 @@ protected:
     return frameworkInfo;
   }
 
-  static Quota createQuota(const string& role, const string& resources)
-  {
-    mesos::quota::QuotaInfo quotaInfo;
-    quotaInfo.set_role(role);
-    quotaInfo.mutable_guarantee()->CopyFrom(Resources::parse(resources).get());
-
-    return Quota{quotaInfo};
-  }
-
   Resources createRevocableResources(
       const string& name,
       const string& value,
@@ -267,15 +258,6 @@ protected:
     return resource;
   }
 
-  static WeightInfo createWeightInfo(const string& role, double weight)
-  {
-    WeightInfo weightInfo;
-    weightInfo.set_role(role);
-    weightInfo.set_weight(weight);
-
-    return weightInfo;
-  }
-
 protected:
   master::Flags flags;
 


Mime
View raw message