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

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

commit 8839af89e2ace33c7b7223790a9a75e67cf43110
Author: Andrei Sekretenko <[email protected]>
AuthorDate: Mon Aug 31 18:34:00 2020 +0200

    Removed `bool operator==(const FrameworkInfo&, const FrameworkInfo&)`.
    
    This patch removes the outdated `operator==` for `FrameworkInfo`
    (which has been comparing only `name` and `user` fields)
    and replaces it with `equivalent()` in the tests that need to compare
    `FrameworkInfo`s.
    
    Review: https://reviews.apache.org/r/72833
---
 include/mesos/type_utils.hpp         |  8 ++++----
 include/mesos/v1/mesos.hpp           |  8 ++++----
 src/tests/api_tests.cpp              | 14 ++++++++++++--
 src/tests/master_allocator_tests.cpp |  7 +++----
 src/tests/resources_tests.cpp        |  4 +++-
 5 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/include/mesos/type_utils.hpp b/include/mesos/type_utils.hpp
index 2745ff0..b3a4413 100644
--- a/include/mesos/type_utils.hpp
+++ b/include/mesos/type_utils.hpp
@@ -116,10 +116,10 @@ inline bool operator==(const FrameworkID& left, const 
FrameworkID& right)
 }
 
 
-inline bool operator==(const FrameworkInfo& left, const FrameworkInfo& right)
-{
-  return (left.name() == right.name()) && (left.user() == right.user());
-}
+// This operator, which was comparing only `user` and `name` fields,
+// has been deleted in favor of `typeutils::equivalent()` function (see below)
+// with different semantics.
+bool operator==(const FrameworkInfo& left, const FrameworkInfo& right) = 
delete;
 
 
 namespace typeutils {
diff --git a/include/mesos/v1/mesos.hpp b/include/mesos/v1/mesos.hpp
index 853330a..6779825 100644
--- a/include/mesos/v1/mesos.hpp
+++ b/include/mesos/v1/mesos.hpp
@@ -100,10 +100,10 @@ inline bool operator==(const FrameworkID& left, const 
FrameworkID& right)
 }
 
 
-inline bool operator==(const FrameworkInfo& left, const FrameworkInfo& right)
-{
-  return (left.name() == right.name()) && (left.user() == right.user());
-}
+// This operator, which was comparing only `user` and `name` fields,
+// has been deleted in favor of `typeutils::equivalent()` function (see below)
+// with different semantics.
+bool operator==(const FrameworkInfo& left, const FrameworkInfo& right) = 
delete;
 
 
 namespace typeutils {
diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index e0ce033..22435f7 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -84,6 +84,7 @@ using mesos::slave::ContainerTermination;
 using mesos::v1::scheduler::Call;
 using mesos::v1::scheduler::Event;
 using mesos::v1::scheduler::Mesos;
+using mesos::v1::typeutils::diff;
 
 using mesos::internal::devolve;
 using mesos::internal::evolve;
@@ -3350,6 +3351,12 @@ TEST_P(MasterAPITest, FrameworksEvent)
   // when it reconnects.
   frameworkInfo.set_failover_timeout(Weeks(2).secs());
 
+  // We need to set `checkpoint` explicitly. Otherwise, `jsonify` in the
+  // scheduler driver sets it to the default value, which results in a spurious
+  // diff between the reported `FrameworkInfo` (`checkpoint == false`) and the
+  // one with which the scheduler has subscribed (`checkpoint` not set).
+  frameworkInfo.set_checkpoint(false);
+
   mesos.send(v1::createCallSubscribe(frameworkInfo));
 
   AWAIT_READY(subscribed);
@@ -3366,7 +3373,9 @@ TEST_P(MasterAPITest, FrameworksEvent)
     const v1::master::Response::GetFrameworks::Framework& framework =
       event.get()->framework_added().framework();
 
-    EXPECT_EQ(frameworkInfo, framework.framework_info());
+    EXPECT_NONE(
+        mesos::v1::typeutils::diff(frameworkInfo, framework.framework_info()));
+
     EXPECT_TRUE(framework.active());
     EXPECT_TRUE(framework.connected());
 
@@ -3404,7 +3413,8 @@ TEST_P(MasterAPITest, FrameworksEvent)
     const v1::master::Response::GetFrameworks::Framework& framework =
       event.get()->framework_updated().framework();
 
-    EXPECT_EQ(frameworkInfo, framework.framework_info());
+    EXPECT_NONE(
+        mesos::v1::typeutils::diff(frameworkInfo, framework.framework_info()));
 
     EXPECT_EQ(registeredTime, framework.registered_time());
 
diff --git a/src/tests/master_allocator_tests.cpp 
b/src/tests/master_allocator_tests.cpp
index 416b7ba..b011a34 100644
--- a/src/tests/master_allocator_tests.cpp
+++ b/src/tests/master_allocator_tests.cpp
@@ -350,8 +350,9 @@ TYPED_TEST(MasterAllocatorTest, OutOfOrderDispatch)
   MesosSchedulerDriver driver1(
       &sched1, frameworkInfo1, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework_(_, Eq(frameworkInfo1), _, _, _))
-    .WillOnce(InvokeAddFramework(&allocator));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _))
+    .Times(2)
+    .WillRepeatedly(InvokeAddFramework(&allocator));
 
   Future<FrameworkID> frameworkId1;
   EXPECT_CALL(sched1, registered(_, _, _))
@@ -419,8 +420,6 @@ TYPED_TEST(MasterAllocatorTest, OutOfOrderDispatch)
   MesosSchedulerDriver driver2(
       &sched2, frameworkInfo2, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework_(_, Eq(frameworkInfo2), _, _, _))
-    .WillOnce(InvokeAddFramework(&allocator));
 
   FrameworkID frameworkId2;
   EXPECT_CALL(sched2, registered(_, _, _))
diff --git a/src/tests/resources_tests.cpp b/src/tests/resources_tests.cpp
index bd04431..b6127e3 100644
--- a/src/tests/resources_tests.cpp
+++ b/src/tests/resources_tests.cpp
@@ -3395,7 +3395,9 @@ TEST(ResourceFormatTest, DowngradeWithoutResources)
 {
   FrameworkInfo frameworkInfo = DEFAULT_FRAMEWORK_INFO;
   EXPECT_SOME(downgradeResources(&frameworkInfo));
-  EXPECT_EQ(DEFAULT_FRAMEWORK_INFO, frameworkInfo);
+  EXPECT_EQ(
+      DEFAULT_FRAMEWORK_INFO.SerializeAsString(),
+      frameworkInfo.SerializeAsString());
 }
 
 

Reply via email to