aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/grpc/test/cpp/end2end/service_config_end2end_test.cc
diff options
context:
space:
mode:
authorheretic <heretic@yandex-team.ru>2022-03-25 12:34:53 +0300
committerheretic <heretic@yandex-team.ru>2022-03-25 12:34:53 +0300
commita41f3739eed6fceb6f62056a7620d220958a47e7 (patch)
tree278103258b510cb4a96761ea79d6ccd397ca05a0 /contrib/libs/grpc/test/cpp/end2end/service_config_end2end_test.cc
parent73d3613a82e5c217fcbe0ab8bbf8120c1ed1af55 (diff)
downloadydb-a41f3739eed6fceb6f62056a7620d220958a47e7.tar.gz
Update grpc to 1.43.2 DTCC-864
ref:50a492c335cda70f458797cf945e49fe739c2715
Diffstat (limited to 'contrib/libs/grpc/test/cpp/end2end/service_config_end2end_test.cc')
-rw-r--r--contrib/libs/grpc/test/cpp/end2end/service_config_end2end_test.cc41
1 files changed, 21 insertions, 20 deletions
diff --git a/contrib/libs/grpc/test/cpp/end2end/service_config_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/service_config_end2end_test.cc
index 12dde9f35e..b974befd49 100644
--- a/contrib/libs/grpc/test/cpp/end2end/service_config_end2end_test.cc
+++ b/contrib/libs/grpc/test/cpp/end2end/service_config_end2end_test.cc
@@ -24,6 +24,9 @@
#include <util/generic/string.h>
#include <thread>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
#include "y_absl/memory/memory.h"
#include "y_absl/strings/str_cat.h"
@@ -45,25 +48,21 @@
#include "src/core/ext/filters/client_channel/global_subchannel_pool.h"
#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
#include "src/core/ext/filters/client_channel/server_address.h"
+#include "src/core/lib/address_utils/parse_address.h"
#include "src/core/lib/backoff/backoff.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
-#include "src/core/lib/iomgr/parse_address.h"
#include "src/core/lib/iomgr/tcp_client.h"
#include "src/core/lib/security/credentials/fake/fake_credentials.h"
#include "src/cpp/client/secure_credentials.h"
#include "src/cpp/server/secure_server_credentials.h"
-
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
#include "test/core/util/resolve_localhost_ip46.h"
#include "test/core/util/test_config.h"
#include "test/cpp/end2end/test_service_impl.h"
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
@@ -300,32 +299,33 @@ class ServiceConfigEnd2endTest : public ::testing::Test {
}
struct ServerData {
- int port_;
+ const int port_;
std::unique_ptr<Server> server_;
MyTestServiceImpl service_;
std::unique_ptr<std::thread> thread_;
- bool server_ready_ = false;
- bool started_ = false;
- explicit ServerData(int port = 0) {
- port_ = port > 0 ? port : grpc_pick_unused_port_or_die();
- }
+ grpc::internal::Mutex mu_;
+ grpc::internal::CondVar cond_;
+ bool server_ready_ Y_ABSL_GUARDED_BY(mu_) = false;
+ bool started_ Y_ABSL_GUARDED_BY(mu_) = false;
+
+ explicit ServerData(int port = 0)
+ : port_(port > 0 ? port : grpc_pick_unused_port_or_die()) {}
void Start(const TString& server_host) {
gpr_log(GPR_INFO, "starting server on port %d", port_);
+ grpc::internal::MutexLock lock(&mu_);
started_ = true;
- grpc::internal::Mutex mu;
- grpc::internal::MutexLock lock(&mu);
- grpc::internal::CondVar cond;
thread_ = y_absl::make_unique<std::thread>(
- std::bind(&ServerData::Serve, this, server_host, &mu, &cond));
- grpc::internal::WaitUntil(&cond, &mu, [this] { return server_ready_; });
+ std::bind(&ServerData::Serve, this, server_host));
+ while (!server_ready_) {
+ cond_.Wait(&mu_);
+ }
server_ready_ = false;
gpr_log(GPR_INFO, "server startup complete");
}
- void Serve(const TString& server_host, grpc::internal::Mutex* mu,
- grpc::internal::CondVar* cond) {
+ void Serve(const TString& server_host) {
std::ostringstream server_address;
server_address << server_host << ":" << port_;
ServerBuilder builder;
@@ -334,12 +334,13 @@ class ServiceConfigEnd2endTest : public ::testing::Test {
builder.AddListeningPort(server_address.str(), std::move(creds));
builder.RegisterService(&service_);
server_ = builder.BuildAndStart();
- grpc::internal::MutexLock lock(mu);
+ grpc::internal::MutexLock lock(&mu_);
server_ready_ = true;
- cond->Signal();
+ cond_.Signal();
}
void Shutdown() {
+ grpc::internal::MutexLock lock(&mu_);
if (!started_) return;
server_->Shutdown(grpc_timeout_milliseconds_to_deadline(0));
thread_->join();