You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ya...@apache.org on 2017/01/18 01:47:05 UTC
[2/4] mesos git commit: Validate executor IDs in master validation.
Validate executor IDs in master validation.
Review: https://reviews.apache.org/r/55449
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e2d9ff05
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e2d9ff05
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e2d9ff05
Branch: refs/heads/master
Commit: e2d9ff0555622e0241db8da2c6c42ac8597fc0bb
Parents: f9758a6
Author: Jiang Yan Xu <xu...@apple.com>
Authored: Mon Jan 9 16:15:21 2017 -0800
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Tue Jan 17 17:38:38 2017 -0800
----------------------------------------------------------------------
src/master/validation.cpp | 9 +++++++++
src/master/validation.hpp | 2 ++
src/tests/master_validation_tests.cpp | 32 ++++++++++++++++++++++++++++++
3 files changed, 43 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/e2d9ff05/src/master/validation.cpp
----------------------------------------------------------------------
diff --git a/src/master/validation.cpp b/src/master/validation.cpp
index 5fa99bf..2c7e4ee 100644
--- a/src/master/validation.cpp
+++ b/src/master/validation.cpp
@@ -620,6 +620,14 @@ Option<Error> validate(const RepeatedPtrField<Resource>& resources)
namespace executor {
namespace internal {
+Option<Error> validateExecutorID(const ExecutorInfo& executor)
+{
+ // Delegate to the common ExecutorID validation. Here we wrap
+ // around it to be consistent with other executor validators.
+ return common::validation::validateExecutorID(executor.executor_id());
+}
+
+
Option<Error> validateType(const ExecutorInfo& executor)
{
switch (executor.type()) {
@@ -753,6 +761,7 @@ Option<Error> validate(
vector<lambda::function<Option<Error>()>> validators = {
lambda::bind(internal::validateType, executor),
+ lambda::bind(internal::validateExecutorID, executor),
lambda::bind(internal::validateFrameworkID, executor, framework),
lambda::bind(internal::validateShutdownGracePeriod, executor),
lambda::bind(internal::validateResources, executor),
http://git-wip-us.apache.org/repos/asf/mesos/blob/e2d9ff05/src/master/validation.hpp
----------------------------------------------------------------------
diff --git a/src/master/validation.hpp b/src/master/validation.hpp
index 57e8177..78b70a7 100644
--- a/src/master/validation.hpp
+++ b/src/master/validation.hpp
@@ -119,6 +119,8 @@ namespace executor {
// Functions in this namespace are only exposed for testing.
namespace internal {
+Option<Error> validateExecutorID(const ExecutorInfo& executor);
+
// Validates that fields are properly set depending on the type of the executor.
Option<Error> validateType(const ExecutorInfo& executor);
http://git-wip-us.apache.org/repos/asf/mesos/blob/e2d9ff05/src/tests/master_validation_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_validation_tests.cpp b/src/tests/master_validation_tests.cpp
index e5d55e0..c092362 100644
--- a/src/tests/master_validation_tests.cpp
+++ b/src/tests/master_validation_tests.cpp
@@ -1730,6 +1730,38 @@ TEST_F(ExecutorValidationTest, ExecutorType)
}
+TEST_F(ExecutorValidationTest, ExecutorID)
+{
+ {
+ ExecutorInfo executorInfo = DEFAULT_EXECUTOR_INFO;
+ executorInfo.mutable_executor_id()->set_value("abc");
+
+ EXPECT_NONE(::executor::internal::validateExecutorID(executorInfo));
+ }
+
+ {
+ ExecutorInfo executorInfo = DEFAULT_EXECUTOR_INFO;
+ executorInfo.mutable_executor_id()->set_value("");
+
+ EXPECT_SOME(::executor::internal::validateExecutorID(executorInfo));
+ }
+
+ {
+ ExecutorInfo executorInfo = DEFAULT_EXECUTOR_INFO;
+ executorInfo.mutable_executor_id()->set_value("ab c");
+
+ EXPECT_NONE(::executor::internal::validateExecutorID(executorInfo));
+ }
+
+ {
+ ExecutorInfo executorInfo = DEFAULT_EXECUTOR_INFO;
+ executorInfo.mutable_executor_id()->set_value("ab/c");
+
+ EXPECT_SOME(::executor::internal::validateExecutorID(executorInfo));
+ }
+}
+
+
class TaskGroupValidationTest : public MesosTest {};