You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2015/12/09 11:54:27 UTC
mesos git commit: Modified Http fetcher test process to be symmetric
in spawn/terminate.
Repository: mesos
Updated Branches:
refs/heads/master 7cec89b5d -> a92e7b872
Modified Http fetcher test process to be symmetric in spawn/terminate.
This addresses the comment here: https://reviews.apache.org/r/40501/#comment168391
Review: https://reviews.apache.org/r/40978
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a92e7b87
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a92e7b87
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a92e7b87
Branch: refs/heads/master
Commit: a92e7b8727b3e4fb27cebedb8000ecf4c717e592
Parents: 7cec89b
Author: Joseph Wu <jo...@mesosphere.io>
Authored: Wed Dec 9 11:53:27 2015 +0100
Committer: Bernd Mathiske <be...@mesosphere.io>
Committed: Wed Dec 9 11:53:28 2015 +0100
----------------------------------------------------------------------
src/tests/fetcher_tests.cpp | 45 +++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/a92e7b87/src/tests/fetcher_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/fetcher_tests.cpp b/src/tests/fetcher_tests.cpp
index 069c9bc..1831d89 100644
--- a/src/tests/fetcher_tests.cpp
+++ b/src/tests/fetcher_tests.cpp
@@ -275,34 +275,47 @@ TEST_F(FetcherTest, RelativeFilePath)
class HttpProcess : public Process<HttpProcess>
{
public:
- HttpProcess()
+ HttpProcess() {}
+
+ MOCK_METHOD1(test, Future<http::Response>(const http::Request&));
+
+protected:
+ virtual void initialize()
{
route("/test", None(), &HttpProcess::test);
}
+};
- ~HttpProcess()
+
+class Http
+{
+public:
+ Http() : process(new HttpProcess())
{
- terminate(this);
- wait(this);
+ spawn(process.get());
}
- MOCK_METHOD1(test, Future<http::Response>(const http::Request&));
+ ~Http()
+ {
+ terminate(process.get());
+ wait(process.get());
+ }
+
+ Owned<HttpProcess> process;
};
TEST_F(FetcherTest, OSNetUriTest)
{
- HttpProcess process;
-
- spawn(process);
+ Http http;
- const network::Address& address = process.self().address;
+ const network::Address& address = http.process->self().address;
process::http::URL url(
"http",
address.ip,
address.port,
- path::join(process.self().id, "test"));
+ path::join(http.process->self().id, "test"));
string localFile = path::join(os::getcwd(), "test");
EXPECT_FALSE(os::exists(localFile));
@@ -321,7 +334,7 @@ TEST_F(FetcherTest, OSNetUriTest)
Fetcher fetcher;
SlaveID slaveId;
- EXPECT_CALL(process, test(_))
+ EXPECT_CALL(*http.process, test(_))
.WillOnce(Return(http::OK()));
Future<Nothing> fetch = fetcher.fetch(
@@ -339,17 +352,15 @@ TEST_F(FetcherTest, OSNetUriTest)
// TODO(hartem): This test case should be merged with the previous one.
TEST_F(FetcherTest, OSNetUriSpaceTest)
{
- HttpProcess process;
-
- spawn(process);
+ Http http;
- const network::Address& address = process.self().address;
+ const network::Address& address = http.process->self().address;
process::http::URL url(
"http",
address.ip,
address.port,
- path::join(process.self().id, "test"));
+ path::join(http.process->self().id, "test"));
string localFile = path::join(os::getcwd(), "test");
EXPECT_FALSE(os::exists(localFile));
@@ -371,7 +382,7 @@ TEST_F(FetcherTest, OSNetUriSpaceTest)
SlaveID slaveId;
// Verify that the intended endpoint is hit.
- EXPECT_CALL(process, test(_))
+ EXPECT_CALL(*http.process, test(_))
.WillOnce(Return(http::OK()));
Future<Nothing> fetch = fetcher.fetch(