Pre-assigned the server port and added more logs

pull/23256/head
Esun Kim 5 years ago
parent 456036d808
commit b3469c723e
  1. 10
      test/cpp/qps/json_run_localhost.cc
  2. 6
      test/cpp/qps/qps_worker.cc
  3. 8
      test/cpp/qps/server_async.cc
  4. 8
      test/cpp/qps/server_callback.cc
  5. 8
      test/cpp/qps/server_sync.cc

@ -88,12 +88,16 @@ int main(int argc, char** argv) {
bool first = true;
for (int i = 0; i < kNumWorkers; i++) {
const auto port = grpc_pick_unused_port_or_die();
const auto driver_port = grpc_pick_unused_port_or_die();
// ServerPort can be used or not later depending on the type of worker
// but we like to issue all ports required here to avoid port conflict.
const auto server_port = grpc_pick_unused_port_or_die();
std::vector<std::string> args = {bin_dir + "/qps_worker", "-driver_port",
as_string(port)};
as_string(driver_port), "-server_port",
as_string(server_port)};
g_workers[i] = new SubProcess(args);
if (!first) env << ",";
env << "localhost:" << port;
env << "localhost:" << driver_port;
first = false;
}

@ -280,6 +280,7 @@ QpsWorker::QpsWorker(int driver_port, int server_port,
gpr_atm_rel_store(&done_, static_cast<gpr_atm>(0));
std::unique_ptr<ServerBuilder> builder = CreateQpsServerBuilder();
builder->AddChannelArgument(GRPC_ARG_ALLOW_REUSEPORT, 0);
if (driver_port >= 0) {
std::string server_address = grpc_core::JoinHostPort("::", driver_port);
builder->AddListeningPort(
@ -291,11 +292,10 @@ QpsWorker::QpsWorker(int driver_port, int server_port,
server_ = builder->BuildAndStart();
if (server_ == nullptr) {
gpr_log(GPR_ERROR,
"QpsWorker: Fail to BuildAndStart(driver_port=%d, server_port=%d)",
"QpsWorker: Fail to BuildAndStart(port=%d) (server_port=%d)",
driver_port, server_port);
} else {
gpr_log(GPR_INFO,
"QpsWorker: BuildAndStart(driver_port=%d, server_port=%d) done",
gpr_log(GPR_INFO, "QpsWorker: BuildAndStart(port=%d) (server_port=%d)",
driver_port, server_port);
}
}

@ -82,7 +82,8 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
if (port_num >= 0) {
std::string server_address = grpc_core::JoinHostPort("::", port_num);
builder->AddListeningPort(server_address.c_str(),
Server::CreateServerCredentials(config));
Server::CreateServerCredentials(config),
&port_num);
}
register_service(builder.get(), &async_service_);
@ -105,6 +106,11 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
ApplyConfigToBuilder(config, builder.get());
server_ = builder->BuildAndStart();
if (server_ == nullptr) {
gpr_log(GPR_ERROR, "Server: Fail to BuildAndStart(port=%d)", port_num);
} else {
gpr_log(GPR_INFO, "Server: BuildAndStart(port=%d)", port_num);
}
auto process_rpc_bound =
std::bind(process_rpc, config.payload_config(), std::placeholders::_1,

@ -104,7 +104,8 @@ class CallbackServer final : public grpc::testing::Server {
if (port_num >= 0) {
std::string server_address = grpc_core::JoinHostPort("::", port_num);
builder->AddListeningPort(server_address.c_str(),
Server::CreateServerCredentials(config));
Server::CreateServerCredentials(config),
&port_num);
}
ApplyConfigToBuilder(config, builder.get());
@ -112,6 +113,11 @@ class CallbackServer final : public grpc::testing::Server {
builder->RegisterService(&service_);
impl_ = builder->BuildAndStart();
if (impl_ == nullptr) {
gpr_log(GPR_ERROR, "Server: Fail to BuildAndStart(port=%d)", port_num);
} else {
gpr_log(GPR_INFO, "Server: BuildAndStart(port=%d)", port_num);
}
}
std::shared_ptr<Channel> InProcessChannel(

@ -162,7 +162,8 @@ class SynchronousServer final : public grpc::testing::Server {
if (port_num >= 0) {
std::string server_address = grpc_core::JoinHostPort("::", port_num);
builder->AddListeningPort(server_address.c_str(),
Server::CreateServerCredentials(config));
Server::CreateServerCredentials(config),
&port_num);
}
ApplyConfigToBuilder(config, builder.get());
@ -170,6 +171,11 @@ class SynchronousServer final : public grpc::testing::Server {
builder->RegisterService(&service_);
impl_ = builder->BuildAndStart();
if (impl_ == nullptr) {
gpr_log(GPR_ERROR, "Server: Fail to BuildAndStart(port=%d)", port_num);
} else {
gpr_log(GPR_INFO, "Server: BuildAndStart(port=%d)", port_num);
}
}
std::shared_ptr<Channel> InProcessChannel(

Loading…
Cancel
Save