mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vinodk...@apache.org
Subject [1/2] mesos git commit: Renamed shutdown_tests.cpp to teardown_tests.cpp.
Date Mon, 11 May 2015 23:39:00 GMT
Repository: mesos
Updated Branches:
  refs/heads/master 496aac347 -> 7bb58e27b


Renamed shutdown_tests.cpp to teardown_tests.cpp.

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


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

Branch: refs/heads/master
Commit: 7bb58e27b2a7c98548206785ce80bbaa5b43ff08
Parents: b2b03f2
Author: Vinod Kone <vinodkone@gmail.com>
Authored: Tue May 5 16:54:47 2015 -0700
Committer: Vinod Kone <vinodkone@gmail.com>
Committed: Mon May 11 16:32:35 2015 -0700

----------------------------------------------------------------------
 src/Makefile.am              |   2 +-
 src/tests/shutdown_tests.cpp | 317 --------------------------------------
 src/tests/teardown_tests.cpp | 317 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 318 insertions(+), 318 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7bb58e27/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 54271f7..14bc976 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1427,12 +1427,12 @@ mesos_tests_SOURCES =				\
   tests/resources_tests.cpp			\
   tests/scheduler_tests.cpp			\
   tests/script.cpp				\
-  tests/shutdown_tests.cpp			\
   tests/slave_recovery_tests.cpp		\
   tests/slave_tests.cpp				\
   tests/sorter_tests.cpp			\
   tests/state_tests.cpp				\
   tests/status_update_manager_tests.cpp		\
+  tests/teardown_tests.cpp			\
   tests/utils.cpp				\
   tests/values_tests.cpp			\
   tests/zookeeper_url_tests.cpp

http://git-wip-us.apache.org/repos/asf/mesos/blob/7bb58e27/src/tests/shutdown_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/shutdown_tests.cpp b/src/tests/shutdown_tests.cpp
deleted file mode 100644
index b3e999e..0000000
--- a/src/tests/shutdown_tests.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-/**
- * 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 <gmock/gmock.h>
-
-#include <string>
-
-#include <mesos/executor.hpp>
-#include <mesos/scheduler.hpp>
-
-#include <process/future.hpp>
-#include <process/gmock.hpp>
-#include <process/http.hpp>
-#include <process/pid.hpp>
-
-#include <stout/base64.hpp>
-#include <stout/hashmap.hpp>
-#include <stout/option.hpp>
-
-#include "master/flags.hpp"
-#include "master/master.hpp"
-
-#include "tests/mesos.hpp"
-#include "tests/utils.hpp"
-
-using std::string;
-
-using mesos::internal::master::Master;
-using mesos::internal::slave::Slave;
-
-using process::Future;
-using process::PID;
-
-using process::http::BadRequest;
-using process::http::OK;
-using process::http::Response;
-using process::http::Unauthorized;
-
-using testing::_;
-using testing::Eq;
-using testing::SaveArg;
-using testing::Return;
-
-namespace mesos {
-namespace internal {
-namespace tests {
-
-
-class ShutdownTest : public MesosTest {};
-
-
-// Testing /master/shutdown so this endopoint  shuts down
-// designated framework or return adequate error.
-
-// Testing route with authorization header and good credentials.
-TEST_F(ShutdownTest, ShutdownEndpoint)
-{
-  Try<PID<Master> > master = StartMaster();
-  ASSERT_SOME(master);
-
-  MockScheduler sched;
-  MesosSchedulerDriver driver(
-      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
-
-  Future<FrameworkID> frameworkId;
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .WillOnce(FutureArg<1>(&frameworkId));
-
-  ASSERT_EQ(DRIVER_RUNNING, driver.start());
-
-  AWAIT_READY(frameworkId);
-
-  hashmap<string, string> headers;
-  headers["Authorization"] = "Basic " +
-    base64::encode(DEFAULT_CREDENTIAL.principal() +
-                   ":" + DEFAULT_CREDENTIAL.secret());
-
-  Future<Response> response = process::http::post(
-      master.get(),
-      "shutdown",
-      headers,
-      "frameworkId=" + frameworkId.get().value());
-
-  AWAIT_READY(response);
-  AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
-
-  driver.stop();
-  driver.join();
-
-  Shutdown();
-}
-
-
-// Testing route with bad credentials.
-TEST_F(ShutdownTest, ShutdownEndpointBadCredentials)
-{
-  Try<PID<Master> > master = StartMaster();
-  ASSERT_SOME(master);
-
-  MockScheduler sched;
-  MesosSchedulerDriver driver(
-      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
-
-  Future<FrameworkID> frameworkId;
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .WillOnce(FutureArg<1>(&frameworkId));
-
-  ASSERT_EQ(DRIVER_RUNNING, driver.start());
-
-  AWAIT_READY(frameworkId);
-
-  hashmap<string, string> headers;
-  headers["Authorization"] = "Basic " +
-    base64::encode("badPrincipal:badSecret");
-
-  Future<Response> response = process::http::post(
-      master.get(),
-      "shutdown",
-      headers,
-      "frameworkId=" + frameworkId.get().value());
-
-  AWAIT_READY(response);
-  AWAIT_EXPECT_RESPONSE_STATUS_EQ(
-      Unauthorized("Mesos master").status,
-      response);
-
-  driver.stop();
-  driver.join();
-
-  Shutdown();
-}
-
-
-// Testing route with good ACLs.
-TEST_F(ShutdownTest, ShutdownEndpointGoodACLs)
-{
-  // Setup ACLs so that the default principal can shutdown the
-  // framework.
-  ACLs acls;
-  mesos::ACL::ShutdownFramework* acl = acls.add_shutdown_frameworks();
-  acl->mutable_principals()->add_values(DEFAULT_CREDENTIAL.principal());
-  acl->mutable_framework_principals()->add_values(
-      DEFAULT_CREDENTIAL.principal());
-
-  master::Flags flags = CreateMasterFlags();
-  flags.acls = acls;
-  Try<PID<Master> > master = StartMaster(flags);
-  ASSERT_SOME(master);
-
-  MockScheduler sched;
-  MesosSchedulerDriver driver(
-      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
-
-  Future<FrameworkID> frameworkId;
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .WillOnce(FutureArg<1>(&frameworkId));
-
-  ASSERT_EQ(DRIVER_RUNNING, driver.start());
-
-  AWAIT_READY(frameworkId);
-
-  hashmap<string, string> headers;
-  headers["Authorization"] = "Basic " +
-    base64::encode(DEFAULT_CREDENTIAL.principal() +
-                   ":" + DEFAULT_CREDENTIAL.secret());
-
-  Future<Response> response = process::http::post(
-      master.get(),
-      "shutdown",
-      headers,
-      "frameworkId=" + frameworkId.get().value());
-
-  AWAIT_READY(response);
-  AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
-
-  driver.stop();
-  driver.join();
-
-  Shutdown();
-}
-
-
-// Testing route with bad ACLs.
-TEST_F(ShutdownTest, ShutdownEndpointBadACLs)
-{
-  // Setup ACLs so that no principal can do shutdown the framework.
-  ACLs acls;
-  mesos::ACL::ShutdownFramework* acl = acls.add_shutdown_frameworks();
-  acl->mutable_principals()->set_type(mesos::ACL::Entity::NONE);
-  acl->mutable_framework_principals()->add_values(
-      DEFAULT_CREDENTIAL.principal());
-
-  master::Flags flags = CreateMasterFlags();
-  flags.acls = acls;
-  Try<PID<Master> > master = StartMaster(flags);
-  ASSERT_SOME(master);
-
-  MockScheduler sched;
-  MesosSchedulerDriver driver(
-      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
-
-  Future<FrameworkID> frameworkId;
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .WillOnce(FutureArg<1>(&frameworkId));
-
-  ASSERT_EQ(DRIVER_RUNNING, driver.start());
-
-  AWAIT_READY(frameworkId);
-
-  hashmap<string, string> headers;
-  headers["Authorization"] = "Basic " +
-    base64::encode(DEFAULT_CREDENTIAL.principal() +
-                   ":" + DEFAULT_CREDENTIAL.secret());
-
-  Future<Response> response = process::http::post(
-      master.get(),
-      "shutdown",
-      headers,
-      "frameworkId=" + frameworkId.get().value());
-
-  AWAIT_READY(response);
-  AWAIT_EXPECT_RESPONSE_STATUS_EQ(
-      Unauthorized("Mesos master").status,
-      response);
-
-  driver.stop();
-  driver.join();
-
-  Shutdown();
-}
-
-
-// Testing route without frameworkId value.
-TEST_F(ShutdownTest, ShutdownEndpointNoFrameworkId)
-{
-  Try<PID<Master> > master = StartMaster();
-  ASSERT_SOME(master);
-
-  MockScheduler sched;
-  MesosSchedulerDriver driver(
-      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
-
-  Future<FrameworkID> frameworkId;
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .WillOnce(FutureArg<1>(&frameworkId));
-
-  ASSERT_EQ(DRIVER_RUNNING, driver.start());
-
-  AWAIT_READY(frameworkId);
-  hashmap<string, string> headers;
-  headers["Authorization"] = "Basic " +
-    base64::encode("badPrincipal:badSecret");
-  Future<Response> response =
-    process::http::post(master.get(), "shutdown", headers, "");
-  AWAIT_READY(response);
-  AWAIT_EXPECT_RESPONSE_STATUS_EQ(BadRequest().status, response);
-
-  driver.stop();
-  driver.join();
-
-  Shutdown();
-}
-
-
-// Testing route without authorization header.
-TEST_F(ShutdownTest, ShutdownEndpointNoHeader)
-{
-  Try<PID<Master> > master = StartMaster();
-  ASSERT_SOME(master);
-
-  MockScheduler sched;
-  MesosSchedulerDriver driver(
-      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
-
-  Future<FrameworkID> frameworkId;
-  EXPECT_CALL(sched, registered(&driver, _, _))
-    .WillOnce(FutureArg<1>(&frameworkId));
-
-  ASSERT_EQ(DRIVER_RUNNING, driver.start());
-
-  AWAIT_READY(frameworkId);
-
-  Future<Response> response = process::http::post(
-      master.get(),
-      "shutdown",
-      None(),
-      "frameworkId=" + frameworkId.get().value());
-
-  AWAIT_READY(response);
-  AWAIT_EXPECT_RESPONSE_STATUS_EQ(
-      Unauthorized("Mesos master").status,
-      response);
-
-  driver.stop();
-  driver.join();
-
-  Shutdown();
-}
-
-} // namespace tests {
-} // namespace internal {
-} // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/7bb58e27/src/tests/teardown_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/teardown_tests.cpp b/src/tests/teardown_tests.cpp
new file mode 100644
index 0000000..daf748c
--- /dev/null
+++ b/src/tests/teardown_tests.cpp
@@ -0,0 +1,317 @@
+/**
+ * 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 <gmock/gmock.h>
+
+#include <string>
+
+#include <mesos/executor.hpp>
+#include <mesos/scheduler.hpp>
+
+#include <process/future.hpp>
+#include <process/gmock.hpp>
+#include <process/http.hpp>
+#include <process/pid.hpp>
+
+#include <stout/base64.hpp>
+#include <stout/hashmap.hpp>
+#include <stout/option.hpp>
+
+#include "master/flags.hpp"
+#include "master/master.hpp"
+
+#include "tests/mesos.hpp"
+#include "tests/utils.hpp"
+
+using std::string;
+
+using mesos::internal::master::Master;
+using mesos::internal::slave::Slave;
+
+using process::Future;
+using process::PID;
+
+using process::http::BadRequest;
+using process::http::OK;
+using process::http::Response;
+using process::http::Unauthorized;
+
+using testing::_;
+using testing::Eq;
+using testing::SaveArg;
+using testing::Return;
+
+namespace mesos {
+namespace internal {
+namespace tests {
+
+
+class TeardownTest : public MesosTest {};
+
+
+// Testing /master/teardown so this endopoint  shuts down
+// designated framework or return adequate error.
+
+// Testing route with authorization header and good credentials.
+TEST_F(TeardownTest, TeardownEndpoint)
+{
+  Try<PID<Master> > master = StartMaster();
+  ASSERT_SOME(master);
+
+  MockScheduler sched;
+  MesosSchedulerDriver driver(
+      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
+
+  Future<FrameworkID> frameworkId;
+  EXPECT_CALL(sched, registered(&driver, _, _))
+    .WillOnce(FutureArg<1>(&frameworkId));
+
+  ASSERT_EQ(DRIVER_RUNNING, driver.start());
+
+  AWAIT_READY(frameworkId);
+
+  hashmap<string, string> headers;
+  headers["Authorization"] = "Basic " +
+    base64::encode(DEFAULT_CREDENTIAL.principal() +
+                   ":" + DEFAULT_CREDENTIAL.secret());
+
+  Future<Response> response = process::http::post(
+      master.get(),
+      "teardown",
+      headers,
+      "frameworkId=" + frameworkId.get().value());
+
+  AWAIT_READY(response);
+  AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+
+  driver.stop();
+  driver.join();
+
+  Shutdown();
+}
+
+
+// Testing route with bad credentials.
+TEST_F(TeardownTest, TeardownEndpointBadCredentials)
+{
+  Try<PID<Master> > master = StartMaster();
+  ASSERT_SOME(master);
+
+  MockScheduler sched;
+  MesosSchedulerDriver driver(
+      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
+
+  Future<FrameworkID> frameworkId;
+  EXPECT_CALL(sched, registered(&driver, _, _))
+    .WillOnce(FutureArg<1>(&frameworkId));
+
+  ASSERT_EQ(DRIVER_RUNNING, driver.start());
+
+  AWAIT_READY(frameworkId);
+
+  hashmap<string, string> headers;
+  headers["Authorization"] = "Basic " +
+    base64::encode("badPrincipal:badSecret");
+
+  Future<Response> response = process::http::post(
+      master.get(),
+      "teardown",
+      headers,
+      "frameworkId=" + frameworkId.get().value());
+
+  AWAIT_READY(response);
+  AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+      Unauthorized("Mesos master").status,
+      response);
+
+  driver.stop();
+  driver.join();
+
+  Shutdown();
+}
+
+
+// Testing route with good ACLs.
+TEST_F(TeardownTest, TeardownEndpointGoodACLs)
+{
+  // Setup ACLs so that the default principal can teardown the
+  // framework.
+  ACLs acls;
+  mesos::ACL::ShutdownFramework* acl = acls.add_shutdown_frameworks();
+  acl->mutable_principals()->add_values(DEFAULT_CREDENTIAL.principal());
+  acl->mutable_framework_principals()->add_values(
+      DEFAULT_CREDENTIAL.principal());
+
+  master::Flags flags = CreateMasterFlags();
+  flags.acls = acls;
+  Try<PID<Master> > master = StartMaster(flags);
+  ASSERT_SOME(master);
+
+  MockScheduler sched;
+  MesosSchedulerDriver driver(
+      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
+
+  Future<FrameworkID> frameworkId;
+  EXPECT_CALL(sched, registered(&driver, _, _))
+    .WillOnce(FutureArg<1>(&frameworkId));
+
+  ASSERT_EQ(DRIVER_RUNNING, driver.start());
+
+  AWAIT_READY(frameworkId);
+
+  hashmap<string, string> headers;
+  headers["Authorization"] = "Basic " +
+    base64::encode(DEFAULT_CREDENTIAL.principal() +
+                   ":" + DEFAULT_CREDENTIAL.secret());
+
+  Future<Response> response = process::http::post(
+      master.get(),
+      "teardown",
+      headers,
+      "frameworkId=" + frameworkId.get().value());
+
+  AWAIT_READY(response);
+  AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+
+  driver.stop();
+  driver.join();
+
+  Shutdown();
+}
+
+
+// Testing route with bad ACLs.
+TEST_F(TeardownTest, TeardownEndpointBadACLs)
+{
+  // Setup ACLs so that no principal can do teardown the framework.
+  ACLs acls;
+  mesos::ACL::ShutdownFramework* acl = acls.add_shutdown_frameworks();
+  acl->mutable_principals()->set_type(mesos::ACL::Entity::NONE);
+  acl->mutable_framework_principals()->add_values(
+      DEFAULT_CREDENTIAL.principal());
+
+  master::Flags flags = CreateMasterFlags();
+  flags.acls = acls;
+  Try<PID<Master> > master = StartMaster(flags);
+  ASSERT_SOME(master);
+
+  MockScheduler sched;
+  MesosSchedulerDriver driver(
+      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
+
+  Future<FrameworkID> frameworkId;
+  EXPECT_CALL(sched, registered(&driver, _, _))
+    .WillOnce(FutureArg<1>(&frameworkId));
+
+  ASSERT_EQ(DRIVER_RUNNING, driver.start());
+
+  AWAIT_READY(frameworkId);
+
+  hashmap<string, string> headers;
+  headers["Authorization"] = "Basic " +
+    base64::encode(DEFAULT_CREDENTIAL.principal() +
+                   ":" + DEFAULT_CREDENTIAL.secret());
+
+  Future<Response> response = process::http::post(
+      master.get(),
+      "teardown",
+      headers,
+      "frameworkId=" + frameworkId.get().value());
+
+  AWAIT_READY(response);
+  AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+      Unauthorized("Mesos master").status,
+      response);
+
+  driver.stop();
+  driver.join();
+
+  Shutdown();
+}
+
+
+// Testing route without frameworkId value.
+TEST_F(TeardownTest, TeardownEndpointNoFrameworkId)
+{
+  Try<PID<Master> > master = StartMaster();
+  ASSERT_SOME(master);
+
+  MockScheduler sched;
+  MesosSchedulerDriver driver(
+      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
+
+  Future<FrameworkID> frameworkId;
+  EXPECT_CALL(sched, registered(&driver, _, _))
+    .WillOnce(FutureArg<1>(&frameworkId));
+
+  ASSERT_EQ(DRIVER_RUNNING, driver.start());
+
+  AWAIT_READY(frameworkId);
+  hashmap<string, string> headers;
+  headers["Authorization"] = "Basic " +
+    base64::encode("badPrincipal:badSecret");
+  Future<Response> response =
+    process::http::post(master.get(), "teardown", headers, "");
+  AWAIT_READY(response);
+  AWAIT_EXPECT_RESPONSE_STATUS_EQ(BadRequest().status, response);
+
+  driver.stop();
+  driver.join();
+
+  Shutdown();
+}
+
+
+// Testing route without authorization header.
+TEST_F(TeardownTest, TeardownEndpointNoHeader)
+{
+  Try<PID<Master> > master = StartMaster();
+  ASSERT_SOME(master);
+
+  MockScheduler sched;
+  MesosSchedulerDriver driver(
+      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
+
+  Future<FrameworkID> frameworkId;
+  EXPECT_CALL(sched, registered(&driver, _, _))
+    .WillOnce(FutureArg<1>(&frameworkId));
+
+  ASSERT_EQ(DRIVER_RUNNING, driver.start());
+
+  AWAIT_READY(frameworkId);
+
+  Future<Response> response = process::http::post(
+      master.get(),
+      "teardown",
+      None(),
+      "frameworkId=" + frameworkId.get().value());
+
+  AWAIT_READY(response);
+  AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+      Unauthorized("Mesos master").status,
+      response);
+
+  driver.stop();
+  driver.join();
+
+  Shutdown();
+}
+
+} // namespace tests {
+} // namespace internal {
+} // namespace mesos {


Mime
View raw message