diff options
author | 2015-10-29 02:23:11 -0700 | |
---|---|---|
committer | 2015-10-29 02:23:11 -0700 | |
commit | 72a633213815f19ac04b51331287e3f7b075dcc1 (patch) | |
tree | 07dc4d99af879455da57b4eca9bc7a7016852ff7 /test/cpp/qps/server.h | |
parent | 119c103ab00f309a66de6f1cb78c648eb3c4e2cc (diff) |
QPS worker no longer needs to specify server port on command line. This is part
of the proto if desired, or just goes to pick_unused_port_or_die if not
specified
Diffstat (limited to 'test/cpp/qps/server.h')
-rw-r--r-- | test/cpp/qps/server.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h index c99ef97564..3ea9382e50 100644 --- a/test/cpp/qps/server.h +++ b/test/cpp/qps/server.h @@ -34,6 +34,7 @@ #ifndef TEST_QPS_SERVER_H #define TEST_QPS_SERVER_H +#include "test/core/util/port.h" #include "test/cpp/qps/timer.h" #include "test/proto/messages.grpc.pb.h" #include "test/proto/perf_tests/perf_control.grpc.pb.h" @@ -43,7 +44,13 @@ namespace testing { class Server { public: - Server() : timer_(new Timer) {} + explicit Server(const ServerConfig& config) : timer_(new Timer) { + if (config.port()) { + port_ = config.port(); + } else { + port_ = grpc_pick_unused_port_or_die(); + } + } virtual ~Server() {} ServerStats Mark(bool reset) { @@ -75,13 +82,14 @@ class Server { return true; } + int Port() const {return port_;} private: + int port_; std::unique_ptr<Timer> timer_; }; -std::unique_ptr<Server> CreateSynchronousServer(const ServerConfig& config, - int port); -std::unique_ptr<Server> CreateAsyncServer(const ServerConfig& config, int port); +std::unique_ptr<Server> CreateSynchronousServer(const ServerConfig& config); +std::unique_ptr<Server> CreateAsyncServer(const ServerConfig& config); } // namespace testing } // namespace grpc |