Renamed a test helper for clarity. `HealthCheckTestHelper` is actually a simple libprocess-based HTTP server. To make it clear and enable it usage in non health check related tests, rename it to `HttpServerTestHelper`.
Review: https://reviews.apache.org/r/58191 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/69fd4af6 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/69fd4af6 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/69fd4af6 Branch: refs/heads/master Commit: 69fd4af6ebfba3a6261a927ae1bec0f4a5d22af8 Parents: 674a619 Author: Alexander Rukletsov <[email protected]> Authored: Mon Apr 3 19:20:07 2017 +0200 Committer: Alexander Rukletsov <[email protected]> Committed: Mon Apr 24 12:04:51 2017 +0200 ---------------------------------------------------------------------- src/Makefile.am | 6 +-- src/tests/CMakeLists.txt | 4 +- src/tests/check_tests.cpp | 6 +-- src/tests/health_check_test_helper.cpp | 76 ----------------------------- src/tests/health_check_test_helper.hpp | 56 --------------------- src/tests/health_check_tests.cpp | 8 +-- src/tests/http_server_test_helper.cpp | 76 +++++++++++++++++++++++++++++ src/tests/http_server_test_helper.hpp | 56 +++++++++++++++++++++ src/tests/test_helper_main.cpp | 6 +-- 9 files changed, 147 insertions(+), 147 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/69fd4af6/src/Makefile.am ---------------------------------------------------------------------- diff --git a/src/Makefile.am b/src/Makefile.am index 1fc453c..29da17b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1120,7 +1120,7 @@ libmesos_no_3rdparty_la_SOURCES += \ tests/containerizer.hpp \ tests/environment.hpp \ tests/flags.hpp \ - tests/health_check_test_helper.hpp \ + tests/http_server_test_helper.hpp \ tests/kill_policy_test_helper.hpp \ tests/limiter.hpp \ tests/mesos.hpp \ @@ -2091,7 +2091,7 @@ check_PROGRAMS += test-helper test_helper_SOURCES = \ tests/active_user_test_helper.cpp \ tests/flags.cpp \ - tests/health_check_test_helper.cpp \ + tests/http_server_test_helper.cpp \ tests/kill_policy_test_helper.cpp \ tests/resources_utils.cpp \ tests/test_helper_main.cpp \ @@ -2264,11 +2264,11 @@ mesos_tests_SOURCES = \ tests/gc_tests.cpp \ tests/hdfs_tests.cpp \ tests/health_check_tests.cpp \ - tests/health_check_test_helper.cpp \ tests/hierarchical_allocator_tests.cpp \ tests/hook_tests.cpp \ tests/http_authentication_tests.cpp \ tests/http_fault_tolerance_tests.cpp \ + tests/http_server_test_helper.cpp \ tests/kill_policy_test_helper.cpp \ tests/log_tests.cpp \ tests/logging_tests.cpp \ http://git-wip-us.apache.org/repos/asf/mesos/blob/69fd4af6/src/tests/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 8e368a8..9f2af9c 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -23,7 +23,7 @@ set(TEST_HELPER_SRC ${TEST_HELPER_SRC} active_user_test_helper.cpp flags.cpp - health_check_test_helper.cpp + http_server_test_helper.cpp resources_utils.cpp test_helper_main.cpp utils.cpp @@ -54,7 +54,7 @@ set(MESOS_TESTS_UTILS_SRC containerizer.cpp environment.cpp flags.cpp - health_check_test_helper.cpp + http_server_test_helper.cpp main.cpp mesos.cpp mock_docker.cpp http://git-wip-us.apache.org/repos/asf/mesos/blob/69fd4af6/src/tests/check_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/check_tests.cpp b/src/tests/check_tests.cpp index 72fa64c..2d1a122 100644 --- a/src/tests/check_tests.cpp +++ b/src/tests/check_tests.cpp @@ -36,7 +36,7 @@ #include "slave/containerizer/fetcher.hpp" #include "tests/flags.hpp" -#include "tests/health_check_test_helper.hpp" +#include "tests/http_server_test_helper.hpp" #include "tests/mesos.hpp" #include "tests/utils.hpp" @@ -822,7 +822,7 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(CommandExecutorCheckTest, HTTPCheckDelivered) const string command = strings::format( "%s %s --ip=127.0.0.1 --port=%u", getTestHelperPath("test-helper"), - HealthCheckTestHelper::NAME, + HttpServerTestHelper::NAME, testPort).get(); v1::Resources resources = @@ -1677,7 +1677,7 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(DefaultExecutorCheckTest, HTTPCheckDelivered) const string command = strings::format( "%s %s --ip=127.0.0.1 --port=%u", getTestHelperPath("test-helper"), - HealthCheckTestHelper::NAME, + HttpServerTestHelper::NAME, testPort).get(); v1::TaskInfo taskInfo = v1::createTask(agentId, resources, command); http://git-wip-us.apache.org/repos/asf/mesos/blob/69fd4af6/src/tests/health_check_test_helper.cpp ---------------------------------------------------------------------- diff --git a/src/tests/health_check_test_helper.cpp b/src/tests/health_check_test_helper.cpp deleted file mode 100644 index 88352c1..0000000 --- a/src/tests/health_check_test_helper.cpp +++ /dev/null @@ -1,76 +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 "tests/health_check_test_helper.hpp" - -#include <cstdlib> - -#include <process/id.hpp> -#include <process/process.hpp> - -#include <stout/os.hpp> -#include <stout/stringify.hpp> - -using process::Process; - -using std::cerr; -using std::endl; - -namespace mesos { -namespace internal { -namespace tests { - -const char HealthCheckTestHelper::NAME[] = "HealthCheck"; - - -class HttpServer : public Process<HttpServer> -{ -public: - HttpServer() - : ProcessBase(process::ID::generate("http-server")) {} -}; - - -HealthCheckTestHelper::Flags::Flags() -{ - add(&Flags::ip, - "ip", - "IP address to listen on."); - - add(&Flags::port, - "port", - "Port to listen on."); -} - - -int HealthCheckTestHelper::execute() -{ - os::setenv("LIBPROCESS_IP", flags.ip); - os::setenv("LIBPROCESS_PORT", stringify(flags.port)); - - HttpServer* server = new HttpServer(); - - process::spawn(server); - process::wait(server->self()); - - delete server; - - return EXIT_SUCCESS; -} - -} // namespace tests { -} // namespace internal { -} // namespace mesos { http://git-wip-us.apache.org/repos/asf/mesos/blob/69fd4af6/src/tests/health_check_test_helper.hpp ---------------------------------------------------------------------- diff --git a/src/tests/health_check_test_helper.hpp b/src/tests/health_check_test_helper.hpp deleted file mode 100644 index cdedf09..0000000 --- a/src/tests/health_check_test_helper.hpp +++ /dev/null @@ -1,56 +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. - -#ifndef __HEALTH_CHECK_TEST_HELPER_HPP__ -#define __HEALTH_CHECK_TEST_HELPER_HPP__ - -#include <cstdint> -#include <string> - -#include <stout/flags.hpp> -#include <stout/subcommand.hpp> - -namespace mesos { -namespace internal { -namespace tests { - -class HealthCheckTestHelper : public Subcommand -{ -public: - static const char NAME[]; - - struct Flags : public virtual flags::FlagsBase - { - Flags(); - - std::string ip; - uint16_t port; - }; - - HealthCheckTestHelper() : Subcommand(NAME) {} - - Flags flags; - -protected: - virtual int execute(); - virtual flags::FlagsBase* getFlags() { return &flags; } -}; - -} // namespace tests { -} // namespace internal { -} // namespace mesos { - -#endif // __HEALTH_CHECK_TEST_HELPER_HPP__ http://git-wip-us.apache.org/repos/asf/mesos/blob/69fd4af6/src/tests/health_check_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/health_check_tests.cpp b/src/tests/health_check_tests.cpp index f5375ac..6c1b9a0 100644 --- a/src/tests/health_check_tests.cpp +++ b/src/tests/health_check_tests.cpp @@ -32,7 +32,7 @@ #include "tests/containerizer.hpp" #include "tests/flags.hpp" -#include "tests/health_check_test_helper.hpp" +#include "tests/http_server_test_helper.hpp" #include "tests/mesos.hpp" #include "tests/mock_docker.hpp" #include "tests/resources_utils.hpp" @@ -1291,7 +1291,7 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(HealthCheckTest, HealthyTaskViaHTTP) const string command = strings::format( "%s %s --ip=127.0.0.1 --port=%u", getTestHelperPath("test-helper"), - HealthCheckTestHelper::NAME, + HttpServerTestHelper::NAME, testPort).get(); TaskInfo task = createTask(offers.get()[0], command); @@ -1377,7 +1377,7 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(HealthCheckTest, HealthyTaskViaHTTPWithoutType) const string command = strings::format( "%s %s --ip=127.0.0.1 --port=%u", getTestHelperPath("test-helper"), - HealthCheckTestHelper::NAME, + HttpServerTestHelper::NAME, testPort).get(); TaskInfo task = createTask(offers.get()[0], command); @@ -1454,7 +1454,7 @@ TEST_F(HealthCheckTest, HealthyTaskViaTCP) const string command = strings::format( "%s %s --ip=127.0.0.1 --port=%u", getTestHelperPath("test-helper"), - HealthCheckTestHelper::NAME, + HttpServerTestHelper::NAME, testPort).get(); TaskInfo task = createTask(offers.get()[0], command); http://git-wip-us.apache.org/repos/asf/mesos/blob/69fd4af6/src/tests/http_server_test_helper.cpp ---------------------------------------------------------------------- diff --git a/src/tests/http_server_test_helper.cpp b/src/tests/http_server_test_helper.cpp new file mode 100644 index 0000000..14a9e0f --- /dev/null +++ b/src/tests/http_server_test_helper.cpp @@ -0,0 +1,76 @@ +// 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 "tests/http_server_test_helper.hpp" + +#include <cstdlib> + +#include <process/id.hpp> +#include <process/process.hpp> + +#include <stout/os.hpp> +#include <stout/stringify.hpp> + +using process::Process; + +using std::cerr; +using std::endl; + +namespace mesos { +namespace internal { +namespace tests { + +const char HttpServerTestHelper::NAME[] = "HttpServer"; + + +class HttpServer : public Process<HttpServer> +{ +public: + HttpServer() + : ProcessBase(process::ID::generate("http-server")) {} +}; + + +HttpServerTestHelper::Flags::Flags() +{ + add(&Flags::ip, + "ip", + "IP address to listen on."); + + add(&Flags::port, + "port", + "Port to listen on."); +} + + +int HttpServerTestHelper::execute() +{ + os::setenv("LIBPROCESS_IP", flags.ip); + os::setenv("LIBPROCESS_PORT", stringify(flags.port)); + + HttpServer* server = new HttpServer(); + + process::spawn(server); + process::wait(server->self()); + + delete server; + + return EXIT_SUCCESS; +} + +} // namespace tests { +} // namespace internal { +} // namespace mesos { http://git-wip-us.apache.org/repos/asf/mesos/blob/69fd4af6/src/tests/http_server_test_helper.hpp ---------------------------------------------------------------------- diff --git a/src/tests/http_server_test_helper.hpp b/src/tests/http_server_test_helper.hpp new file mode 100644 index 0000000..d034ef5 --- /dev/null +++ b/src/tests/http_server_test_helper.hpp @@ -0,0 +1,56 @@ +// 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. + +#ifndef __HTTP_SERVER_TEST_HELPER_HPP__ +#define __HTTP_SERVER_TEST_HELPER_HPP__ + +#include <cstdint> +#include <string> + +#include <stout/flags.hpp> +#include <stout/subcommand.hpp> + +namespace mesos { +namespace internal { +namespace tests { + +class HttpServerTestHelper : public Subcommand +{ +public: + static const char NAME[]; + + struct Flags : public virtual flags::FlagsBase + { + Flags(); + + std::string ip; + uint16_t port; + }; + + HttpServerTestHelper() : Subcommand(NAME) {} + + Flags flags; + +protected: + virtual int execute(); + virtual flags::FlagsBase* getFlags() { return &flags; } +}; + +} // namespace tests { +} // namespace internal { +} // namespace mesos { + +#endif // __HTTP_SERVER_TEST_HELPER_HPP__ http://git-wip-us.apache.org/repos/asf/mesos/blob/69fd4af6/src/tests/test_helper_main.cpp ---------------------------------------------------------------------- diff --git a/src/tests/test_helper_main.cpp b/src/tests/test_helper_main.cpp index 5d99ede..845e7d4 100644 --- a/src/tests/test_helper_main.cpp +++ b/src/tests/test_helper_main.cpp @@ -18,7 +18,7 @@ #include <stout/subcommand.hpp> #include "tests/active_user_test_helper.hpp" -#include "tests/health_check_test_helper.hpp" +#include "tests/http_server_test_helper.hpp" #include "tests/kill_policy_test_helper.hpp" #ifndef __WINDOWS__ @@ -30,7 +30,7 @@ #endif using mesos::internal::tests::ActiveUserTestHelper; -using mesos::internal::tests::HealthCheckTestHelper; +using mesos::internal::tests::HttpServerTestHelper; #ifndef __WINDOWS__ using mesos::internal::tests::KillPolicyTestHelper; using mesos::internal::tests::MemoryTestHelper; @@ -51,7 +51,7 @@ int main(int argc, char** argv) new CapabilitiesTestHelper(), new SetnsTestHelper(), #endif - new HealthCheckTestHelper(), + new HttpServerTestHelper(), #ifndef __WINDOWS__ new KillPolicyTestHelper(), new MemoryTestHelper(),
