diff options
author | Alexander Polcyn <apolcyn@google.com> | 2017-10-13 17:01:32 -0700 |
---|---|---|
committer | Alexander Polcyn <apolcyn@google.com> | 2017-10-13 17:01:32 -0700 |
commit | 7a57b0c4a18fbb03714a0d1dd5a25989fd7e5c2d (patch) | |
tree | ae15669583a01a2b8d506ded18849ab3da1ac5f5 /test/cpp/end2end | |
parent | 56a9316e01bbd4aa88417a95e8a454d94ee48da2 (diff) |
explicitly recycle every port after every test run
Diffstat (limited to 'test/cpp/end2end')
-rw-r--r-- | test/cpp/end2end/end2end_test.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index c5178526f8..1aa547d4e3 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -220,7 +220,8 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> { End2endTest() : is_server_started_(false), kMaxMessageSize_(8192), - special_service_("special") { + special_service_("special"), + first_picked_port_(0) { GetParam().Log(); } @@ -229,10 +230,14 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> { server_->Shutdown(); if (proxy_server_) proxy_server_->Shutdown(); } + if (first_picked_port_ > 0) { + grpc_recycle_unused_port(first_picked_port_); + } } void StartServer(const std::shared_ptr<AuthMetadataProcessor>& processor) { int port = grpc_pick_unused_port_or_die(); + first_picked_port_ = port; server_address_ << "127.0.0.1:" << port; // Setup server BuildAndStartServer(processor); @@ -328,6 +333,7 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> { TestServiceImpl special_service_; TestServiceImplDupPkg dup_pkg_service_; grpc::string user_agent_prefix_; + int first_picked_port_; }; static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs, |