You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jp...@apache.org on 2017/11/08 16:24:04 UTC

mesos git commit: Added a test for ExecutorID validation in ReregisterSlaveMessage.

Repository: mesos
Updated Branches:
  refs/heads/master 72e6cde81 -> 677305f0b


Added a test for ExecutorID validation in ReregisterSlaveMessage.

Added a test to ensure that the ReregisterSlaveMessage validation
correctly allows duplicate ExecutorIDs as long as they are scoped
to different frameworks.

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


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

Branch: refs/heads/master
Commit: 677305f0b8a161d87d16ff156f58d2b0789c15e0
Parents: 72e6cde
Author: James Peach <jp...@apache.org>
Authored: Tue Nov 7 16:59:27 2017 -0800
Committer: James Peach <jp...@apache.org>
Committed: Wed Nov 8 08:23:27 2017 -0800

----------------------------------------------------------------------
 src/tests/master_validation_tests.cpp | 46 ++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/677305f0/src/tests/master_validation_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_validation_tests.cpp b/src/tests/master_validation_tests.cpp
index be8c892..0e1c8b4 100644
--- a/src/tests/master_validation_tests.cpp
+++ b/src/tests/master_validation_tests.cpp
@@ -48,6 +48,8 @@
 #include "tests/mesos.hpp"
 #include "tests/resources_utils.hpp"
 
+#include "master/validation.hpp"
+
 #include "master/detector/standalone.hpp"
 
 using namespace mesos::internal::master::validation;
@@ -4205,6 +4207,50 @@ TEST_F(RegisterSlaveValidationTest, DropInvalidRegistration)
   Clock::settle();
 }
 
+
+// Test that duplicate ExecutorIDs are correctly handled when
+// validating the ReregisterSlaveMessage.
+TEST_F(RegisterSlaveValidationTest, DuplicateExecutorID)
+{
+  SlaveInfo slaveInfo;
+  slaveInfo.mutable_id()->set_value("agent-id");
+  slaveInfo.mutable_resources()->CopyFrom(
+      Resources::parse("cpus:2;mem:10").get());
+
+  vector<Task> tasks;
+  vector<Resource> resources;
+  vector<ExecutorInfo> executors;
+  vector<FrameworkInfo> frameworks;
+
+  frameworks.push_back(DEFAULT_FRAMEWORK_INFO);
+  frameworks.back().set_name("framework1");
+  frameworks.back().mutable_id()->set_value("framework1");
+
+  frameworks.push_back(DEFAULT_FRAMEWORK_INFO);
+  frameworks.back().set_name("framework2");
+  frameworks.back().mutable_id()->set_value("framework2");
+
+  executors.push_back(DEFAULT_EXECUTOR_INFO);
+  executors.back().mutable_framework_id()->set_value("framework1");
+
+  executors.push_back(DEFAULT_EXECUTOR_INFO);
+  executors.back().mutable_framework_id()->set_value("framework2");
+
+  // Executors with the same ID in different frameworks are allowed.
+  EXPECT_EQ(executors[0].executor_id(), executors[1].executor_id());
+  EXPECT_NE(executors[0].framework_id(), executors[1].framework_id());
+  EXPECT_NONE(master::validation::master::message::reregisterSlave(
+      slaveInfo, tasks, resources, executors, frameworks));
+
+  executors[1].mutable_framework_id()->set_value("framework1");
+
+  // Executors with the same ID in in the same framework are not allowed.
+  EXPECT_EQ(executors[0].executor_id(), executors[1].executor_id());
+  EXPECT_EQ(executors[0].framework_id(), executors[1].framework_id());
+  EXPECT_SOME(master::validation::master::message::reregisterSlave(
+      slaveInfo, tasks, resources, executors, frameworks));
+}
+
 } // namespace tests {
 } // namespace internal {
 } // namespace mesos {