You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2016/11/25 11:02:06 UTC

[1/4] mesos git commit: Cleaned up includes in "tests/utils.{hpp|cpp}".

Repository: mesos
Updated Branches:
  refs/heads/master bd1bd1eee -> 79cee8ad9


Cleaned up includes in "tests/utils.{hpp|cpp}".

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


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

Branch: refs/heads/master
Commit: e30fb8a3c9ee63ce00785fe167c78c6bbdd31f2e
Parents: bd1bd1e
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Fri Nov 25 11:43:08 2016 +0100
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Fri Nov 25 11:43:08 2016 +0100

----------------------------------------------------------------------
 src/tests/utils.cpp | 3 ++-
 src/tests/utils.hpp | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e30fb8a3/src/tests/utils.cpp
----------------------------------------------------------------------
diff --git a/src/tests/utils.cpp b/src/tests/utils.cpp
index eb36616..7dd2069 100644
--- a/src/tests/utils.cpp
+++ b/src/tests/utils.cpp
@@ -14,6 +14,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+#include "tests/utils.hpp"
+
 #include <gtest/gtest.h>
 
 #include <mesos/http.hpp>
@@ -27,7 +29,6 @@
 #include <stout/gtest.hpp>
 
 #include "tests/flags.hpp"
-#include "tests/utils.hpp"
 
 using std::string;
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/e30fb8a3/src/tests/utils.hpp
----------------------------------------------------------------------
diff --git a/src/tests/utils.hpp b/src/tests/utils.hpp
index 140ebaa..dcdb03d 100644
--- a/src/tests/utils.hpp
+++ b/src/tests/utils.hpp
@@ -17,6 +17,8 @@
 #ifndef __TESTS_UTILS_HPP__
 #define __TESTS_UTILS_HPP__
 
+#include <string>
+
 #include <stout/json.hpp>
 
 namespace mesos {


[2/4] mesos git commit: Introduced process using declarations to "tests/utils.cpp".

Posted by al...@apache.org.
Introduced process using declarations to "tests/utils.cpp".

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


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

Branch: refs/heads/master
Commit: 5f84a472e6d716b87304dc6f22ba762dce461cef
Parents: e30fb8a
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Fri Nov 25 11:44:08 2016 +0100
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Fri Nov 25 11:44:08 2016 +0100

----------------------------------------------------------------------
 src/tests/utils.cpp | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5f84a472/src/tests/utils.cpp
----------------------------------------------------------------------
diff --git a/src/tests/utils.cpp b/src/tests/utils.cpp
index 7dd2069..c7769cf 100644
--- a/src/tests/utils.cpp
+++ b/src/tests/utils.cpp
@@ -32,6 +32,12 @@
 
 using std::string;
 
+using process::Future;
+using process::UPID;
+using process::address;
+
+namespace http = process::http;
+
 namespace mesos {
 namespace internal {
 namespace tests {
@@ -44,15 +50,14 @@ const bool searchInstallationDirectory = false;
 
 JSON::Object Metrics()
 {
-  process::UPID upid("metrics", process::address());
+  UPID upid("metrics", address());
 
   // TODO(neilc): This request might timeout if the current value of a
   // metric cannot be determined. In tests, a common cause for this is
   // MESOS-6231 when multiple scheduler drivers are in use.
-  process::Future<process::http::Response> response =
-    process::http::get(upid, "snapshot");
+  Future<http::Response> response = http::get(upid, "snapshot");
 
-  AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response);
+  AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response);
   AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
 
   Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);


[3/4] mesos git commit: Added a test helper to obtain unused port.

Posted by al...@apache.org.
Added a test helper to obtain unused port.

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


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

Branch: refs/heads/master
Commit: 9de5fb277b00e77414075e268e8709c0b6d5d0a9
Parents: 5f84a47
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Fri Nov 25 11:58:46 2016 +0100
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Fri Nov 25 11:58:46 2016 +0100

----------------------------------------------------------------------
 src/tests/utils.cpp | 26 ++++++++++++++++++++++++++
 src/tests/utils.hpp | 10 ++++++++++
 2 files changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9de5fb27/src/tests/utils.cpp
----------------------------------------------------------------------
diff --git a/src/tests/utils.cpp b/src/tests/utils.cpp
index c7769cf..d36aa9c 100644
--- a/src/tests/utils.cpp
+++ b/src/tests/utils.cpp
@@ -20,11 +20,13 @@
 
 #include <mesos/http.hpp>
 
+#include <process/address.hpp>
 #include <process/future.hpp>
 #include <process/gtest.hpp>
 #include <process/http.hpp>
 #include <process/pid.hpp>
 #include <process/process.hpp>
+#include <process/socket.hpp>
 
 #include <stout/gtest.hpp>
 
@@ -37,6 +39,7 @@ using process::UPID;
 using process::address;
 
 namespace http = process::http;
+namespace network = process::network;
 
 namespace mesos {
 namespace internal {
@@ -66,6 +69,29 @@ JSON::Object Metrics()
   return parse.get();
 }
 
+
+Try<uint16_t> getFreePort()
+{
+  // Bind to port=0 to obtain a random unused port.
+  Try<network::Socket> socket = network::Socket::create();
+
+  if (socket.isError()) {
+    return Error(socket.error());
+  }
+
+  Try<network::Address> result = socket->bind(network::Address());
+
+  if (result.isSome()) {
+    return result->port;
+  } else {
+    return Error(result.error());
+  }
+
+  // No explicit cleanup of `socket` as we rely on the implementation
+  // of `Socket` to close the socket on destruction.
+}
+
+
 string getModulePath(const string& name)
 {
   string path = path::join(tests::flags.build_dir, "src", ".libs");

http://git-wip-us.apache.org/repos/asf/mesos/blob/9de5fb27/src/tests/utils.hpp
----------------------------------------------------------------------
diff --git a/src/tests/utils.hpp b/src/tests/utils.hpp
index dcdb03d..cdbbc1c 100644
--- a/src/tests/utils.hpp
+++ b/src/tests/utils.hpp
@@ -17,9 +17,12 @@
 #ifndef __TESTS_UTILS_HPP__
 #define __TESTS_UTILS_HPP__
 
+#include <stdint.h>
+
 #include <string>
 
 #include <stout/json.hpp>
+#include <stout/try.hpp>
 
 namespace mesos {
 namespace internal {
@@ -71,6 +74,13 @@ std::string getSbinDir();
 // Get the path to the directory of the webui files/assets.
 std::string getWebUIDir();
 
+// Get a random unused port.
+//
+// NOTE: While we make sure that the port returned by this function is
+// unused when this function returns, it might become used before the
+// caller can bind to it.
+Try<uint16_t> getFreePort();
+
 } // namespace tests {
 } // namespace internal {
 } // namespace mesos {


[4/4] mesos git commit: Avoided hardcoding ports in some tests.

Posted by al...@apache.org.
Avoided hardcoding ports in some tests.

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


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

Branch: refs/heads/master
Commit: 79cee8ad9653ba2514d0d63ee53e05bb7f78ddc9
Parents: 9de5fb2
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Fri Nov 25 11:58:57 2016 +0100
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Fri Nov 25 11:58:57 2016 +0100

----------------------------------------------------------------------
 .../containerizer/docker_containerizer_tests.cpp  |  2 +-
 src/tests/health_check_tests.cpp                  | 18 +++++++++---------
 2 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/79cee8ad/src/tests/containerizer/docker_containerizer_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/docker_containerizer_tests.cpp b/src/tests/containerizer/docker_containerizer_tests.cpp
index dee7a34..6035171 100644
--- a/src/tests/containerizer/docker_containerizer_tests.cpp
+++ b/src/tests/containerizer/docker_containerizer_tests.cpp
@@ -3970,7 +3970,7 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_NoTransitionFromKillingToRunning)
   AWAIT_READY(offers);
   EXPECT_EQ(1u, offers->size());
 
-  const uint16_t testPort = 31001;
+  const uint16_t testPort = getFreePort().get();
 
   // Launch a HTTP server until SIGTERM is received, then sleep for
   // 15 seconds to let the health check fail.

http://git-wip-us.apache.org/repos/asf/mesos/blob/79cee8ad/src/tests/health_check_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/health_check_tests.cpp b/src/tests/health_check_tests.cpp
index 2c7022a..a4436bd 100644
--- a/src/tests/health_check_tests.cpp
+++ b/src/tests/health_check_tests.cpp
@@ -1339,7 +1339,7 @@ TEST_F(HealthCheckTest, HealthyTaskViaHTTP)
   AWAIT_READY(offers);
   EXPECT_NE(0u, offers.get().size());
 
-  const uint16_t testPort = 31001;
+  const uint16_t testPort = getFreePort().get();
 
   // Use `test-helper` to launch a simple HTTP
   // server to respond to HTTP health checks.
@@ -1421,7 +1421,7 @@ TEST_F(HealthCheckTest, HealthyTaskViaHTTPWithoutType)
   AWAIT_READY(offers);
   EXPECT_NE(0u, offers.get().size());
 
-  const uint16_t testPort = 31001;
+  const uint16_t testPort = getFreePort().get();
 
   // Use `test-helper` to launch a simple HTTP
   // server to respond to HTTP health checks.
@@ -1498,7 +1498,7 @@ TEST_F(HealthCheckTest, HealthyTaskViaTCP)
   AWAIT_READY(offers);
   EXPECT_NE(0u, offers.get().size());
 
-  const uint16_t testPort = 31001;
+  const uint16_t testPort = getFreePort().get();
 
   // Use `test-helper` to launch a simple HTTP
   // server to respond to TCP health checks.
@@ -1578,7 +1578,7 @@ TEST_F(HealthCheckTest, ROOT_INTERNET_CURL_HealthyTaskViaHTTPWithContainerImage)
   AWAIT_READY(offers);
   EXPECT_NE(0u, offers.get().size());
 
-  const uint16_t testPort = 31001;
+  const uint16_t testPort = getFreePort().get();
 
   // Use Netcat to launch a HTTP server.
   const string command = strings::format(
@@ -1663,7 +1663,7 @@ TEST_F(HealthCheckTest,
   AWAIT_READY(offers);
   EXPECT_NE(0u, offers.get().size());
 
-  const uint16_t testPort = 31001;
+  const uint16_t testPort = getFreePort().get();
 
   const string command = strings::format(
       "python https_server.py %u",
@@ -1755,7 +1755,7 @@ TEST_F(HealthCheckTest, ROOT_INTERNET_CURL_HealthyTaskViaTCPWithContainerImage)
   AWAIT_READY(offers);
   EXPECT_NE(0u, offers.get().size());
 
-  const uint16_t testPort = 31001;
+  const uint16_t testPort = getFreePort().get();
 
   // Use Netcat to launch a HTTP server.
   const string command = strings::format(
@@ -1851,7 +1851,7 @@ TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthyTaskViaHTTP)
   AWAIT_READY(offers);
   EXPECT_NE(0u, offers.get().size());
 
-  const uint16_t testPort = 31001;
+  const uint16_t testPort = getFreePort().get();
 
   // Use Netcat to launch a HTTP server.
   const string command = strings::format(
@@ -1978,7 +1978,7 @@ TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthyTaskViaHTTPS)
   AWAIT_READY(offers);
   EXPECT_NE(0u, offers.get().size());
 
-  const uint16_t testPort = 31001;
+  const uint16_t testPort = getFreePort().get();
 
   const string command = strings::format(
       "python https_server.py %u",
@@ -2110,7 +2110,7 @@ TEST_F(HealthCheckTest, ROOT_DOCKER_DockerHealthyTaskViaTCP)
   AWAIT_READY(offers);
   EXPECT_NE(0u, offers.get().size());
 
-  const uint16_t testPort = 31001;
+  const uint16_t testPort = getFreePort().get();
 
   // Use Netcat to launch a HTTP server.
   const string command = strings::format(