This is an automated email from the ASF dual-hosted git repository.

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

commit 79c32082b820ef28447d5f9509936a7992144484
Author: Andrei Sekretenko <[email protected]>
AuthorDate: Wed Jun 12 15:47:02 2019 -0400

    Moved UPDATE_FRAMEWORK test helpers to appropriate namespaces.
    
    Review: https://reviews.apache.org/r/70754/
---
 src/tests/master/update_framework_tests.cpp | 121 ++++++++++++++--------------
 1 file changed, 61 insertions(+), 60 deletions(-)

diff --git a/src/tests/master/update_framework_tests.cpp 
b/src/tests/master/update_framework_tests.cpp
index 5eb7a89..8e4d916 100644
--- a/src/tests/master/update_framework_tests.cpp
+++ b/src/tests/master/update_framework_tests.cpp
@@ -80,28 +80,65 @@ using testing::Return;
 namespace mesos {
 namespace internal {
 namespace tests {
-namespace v1 {
-namespace scheduler {
 
 
-class UpdateFrameworkTest : public MesosTest {};
+template <class TFrameworkInfo>
+static TFrameworkInfo changeAllMutableFields(const TFrameworkInfo& oldInfo)
+{
+  CHECK_EQ(TFrameworkInfo::descriptor()->field_count(), 13)
+    << "After adding a new mutable field to FrameworkInfo, please make sure "
+    << "that this function modifies this field";
 
+  TFrameworkInfo newInfo = oldInfo;
 
-static Future<APIResult> callUpdateFramework(
-    Mesos* mesos,
-    const FrameworkInfo& info)
+  *newInfo.mutable_name() += "_foo";
+  newInfo.set_failover_timeout(newInfo.failover_timeout() + 1000.0);
+  *newInfo.mutable_hostname() += ".foo";
+  *newInfo.mutable_webui_url() += "/foo";
+
+  newInfo.add_capabilities()->set_type(
+      TFrameworkInfo::Capability::REGION_AWARE);
+
+  auto* newLabel = newInfo.mutable_labels()->add_labels();
+  *newLabel->mutable_key() = "UPDATE_FRAMEWORK_KEY";
+  *newLabel->mutable_value() = "UPDATE_FRAMEWORK_VALUE";
+
+  // TODO(asekretenko): Test update of `role` with a non-MULTI_ROLE framework.
+  newInfo.add_roles("new_role");
+
+  CHECK(newInfo.offer_filters().count("new_role") == 0);
+  (*newInfo.mutable_offer_filters())["new_role"] =
+    typename std::remove_reference<decltype(
+      newInfo.offer_filters())>::type::mapped_type();
+
+  return newInfo;
+}
+
+
+template <class TFrameworkInfo>
+static Option<std::string> diff(
+    const TFrameworkInfo& lhs, const TFrameworkInfo& rhs)
 {
-  CHECK(info.has_id());
+  const google::protobuf::Descriptor* descriptor = 
TFrameworkInfo::descriptor();
+  google::protobuf::util::MessageDifferencer differencer;
 
-  Call call;
-  call.set_type(Call::UPDATE_FRAMEWORK);
-  *call.mutable_framework_id() = info.id();
-  *call.mutable_update_framework()->mutable_framework_info() = info;
-  return mesos->call(call);
+  differencer.TreatAsSet(descriptor->FindFieldByName("capabilities"));
+  differencer.TreatAsSet(descriptor->FindFieldByName("roles"));
+
+  string result;
+  differencer.ReportDifferencesToString(&result);
+
+  if (differencer.Compare(lhs, rhs)) {
+    return None();
+  }
+
+  return result;
 }
 
 
-// TODO(asekretenko): Move this function out of 'scheduler' namespace.
+namespace v1 {
+
+
 static Future<v1::master::Response::GetFrameworks> getFrameworks(
     const process::PID<Master>& pid)
 {
@@ -142,59 +179,23 @@ static Future<v1::master::Response::GetFrameworks> 
getFrameworks(
 }
 
 
-// TODO(asekretenko): Move this function out of 'v1' namespace.
-template <class TFrameworkInfo>
-static TFrameworkInfo changeAllMutableFields(const TFrameworkInfo& oldInfo)
-{
-  CHECK_EQ(TFrameworkInfo::descriptor()->field_count(), 13)
-    << "After adding a new mutable field to FrameworkInfo, please make sure "
-    << "that this function modifies this field";
-
-  TFrameworkInfo newInfo = oldInfo;
-
-  *newInfo.mutable_name() += "_foo";
-  newInfo.set_failover_timeout(newInfo.failover_timeout() + 1000.0);
-  *newInfo.mutable_hostname() += ".foo";
-  *newInfo.mutable_webui_url() += "/foo";
-
-  newInfo.add_capabilities()->set_type(
-      TFrameworkInfo::Capability::REGION_AWARE);
-
-  auto* newLabel = newInfo.mutable_labels()->add_labels();
-  *newLabel->mutable_key() = "UPDATE_FRAMEWORK_KEY";
-  *newLabel->mutable_value() = "UPDATE_FRAMEWORK_VALUE";
+namespace scheduler {
 
-  // TODO(asekretenko): Test update of `role` with a non-MULTI_ROLE framework.
-  newInfo.add_roles("new_role");
 
-  CHECK(newInfo.offer_filters().count("new_role") == 0);
-  (*newInfo.mutable_offer_filters())["new_role"] =
-    typename std::remove_reference<decltype(
-      newInfo.offer_filters())>::type::mapped_type();
-
-  return newInfo;
-}
+class UpdateFrameworkTest : public MesosTest {};
 
 
-// TODO(asekretenko): Move this function out of 'v1' namespace.
-template <class TFrameworkInfo>
-static Option<std::string> diff(
-    const TFrameworkInfo& lhs, const TFrameworkInfo& rhs)
+static Future<APIResult> callUpdateFramework(
+    Mesos* mesos,
+    const FrameworkInfo& info)
 {
-  const google::protobuf::Descriptor* descriptor = 
TFrameworkInfo::descriptor();
-  google::protobuf::util::MessageDifferencer differencer;
-
-  differencer.TreatAsSet(descriptor->FindFieldByName("capabilities"));
-  differencer.TreatAsSet(descriptor->FindFieldByName("roles"));
-
-  string result;
-  differencer.ReportDifferencesToString(&result);
-
-  if (differencer.Compare(lhs, rhs)) {
-    return None();
-  }
+  CHECK(info.has_id());
 
-  return result;
+  Call call;
+  call.set_type(Call::UPDATE_FRAMEWORK);
+  *call.mutable_framework_id() = info.id();
+  *call.mutable_update_framework()->mutable_framework_info() = info;
+  return mesos->call(call);
 }
 
 

Reply via email to