aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-10-06 07:56:05 -0700
committerGravatar Mark D. Roth <roth@google.com>2016-10-06 07:56:05 -0700
commit4bcdd73df6162ccadc9d54d3df6956bd378475f0 (patch)
tree60eb936a76b57f383724b04ee20366f03478cfde /test/cpp
parenteb7574b39b2d3c1d3f077bdebe7e548eca283d6e (diff)
parent3a9f49d409d5fa552ea6053eedfa0a8e27d160e0 (diff)
Merge remote-tracking branch 'upstream/master' into fail_fast
Diffstat (limited to 'test/cpp')
-rw-r--r--test/cpp/end2end/proto_server_reflection_test.cc2
-rw-r--r--test/cpp/grpclb/grpclb_test.cc8
-rw-r--r--test/cpp/util/grpc_tool.cc1
-rw-r--r--test/cpp/util/proto_file_parser.cc17
-rw-r--r--test/cpp/util/proto_reflection_descriptor_database.cc13
-rw-r--r--test/cpp/util/proto_reflection_descriptor_database.h6
6 files changed, 29 insertions, 18 deletions
diff --git a/test/cpp/end2end/proto_server_reflection_test.cc b/test/cpp/end2end/proto_server_reflection_test.cc
index efbb0e1f8e..75efd01f06 100644
--- a/test/cpp/end2end/proto_server_reflection_test.cc
+++ b/test/cpp/end2end/proto_server_reflection_test.cc
@@ -144,7 +144,7 @@ class ProtoServerReflectionTest : public ::testing::Test {
TEST_F(ProtoServerReflectionTest, CheckResponseWithLocalDescriptorPool) {
ResetStub();
- std::vector<std::string> services;
+ std::vector<grpc::string> services;
desc_db_->GetServices(&services);
// The service list has at least one service (reflection servcie).
EXPECT_TRUE(services.size() > 0);
diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc
index 95abe38031..7666c4e60b 100644
--- a/test/cpp/grpclb/grpclb_test.cc
+++ b/test/cpp/grpclb/grpclb_test.cc
@@ -59,6 +59,7 @@ extern "C" {
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/server.h"
#include "test/core/end2end/cq_verifier.h"
+#include "test/core/end2end/fake_resolver.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
}
@@ -214,7 +215,7 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports,
request.ParseFromArray(GPR_SLICE_START_PTR(request_payload_slice),
GPR_SLICE_LENGTH(request_payload_slice));
GPR_ASSERT(request.has_initial_request());
- GPR_ASSERT(request.initial_request().name() == "load.balanced.service.name");
+ GPR_ASSERT(request.initial_request().name() == sf->servers_hostport);
gpr_slice_unref(request_payload_slice);
grpc_byte_buffer_reader_destroy(&bbr);
grpc_byte_buffer_destroy(request_payload_recv);
@@ -460,7 +461,7 @@ static void perform_request(client_fixture *cf) {
c = grpc_channel_create_call(cf->client, NULL, GRPC_PROPAGATE_DEFAULTS,
cf->cq, "/foo", "foo.test.google.fr:1234",
- GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1000), NULL);
+ GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL);
gpr_log(GPR_INFO, "Call 0x%" PRIxPTR " created", (intptr_t)c);
GPR_ASSERT(c);
char *peer;
@@ -633,7 +634,7 @@ static test_fixture setup_test_fixture(int lb_server_update_delay_ms) {
gpr_thd_new(&tf.lb_server.tid, fork_lb_server, &tf.lb_server, &options);
char *server_uri;
- gpr_asprintf(&server_uri, "ipv4:%s?lb_policy=grpclb&lb_enabled=1",
+ gpr_asprintf(&server_uri, "test:%s?lb_policy=grpclb&lb_enabled=1",
tf.lb_server.servers_hostport);
setup_client(server_uri, &tf.client);
gpr_free(server_uri);
@@ -716,6 +717,7 @@ TEST(GrpclbTest, InvalidAddressInServerlist) {}
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
grpc_test_init(argc, argv);
+ grpc_fake_resolver_init();
grpc_init();
const auto result = RUN_ALL_TESTS();
grpc_shutdown();
diff --git a/test/cpp/util/grpc_tool.cc b/test/cpp/util/grpc_tool.cc
index 8fb325cf76..03c33abe9f 100644
--- a/test/cpp/util/grpc_tool.cc
+++ b/test/cpp/util/grpc_tool.cc
@@ -52,7 +52,6 @@
#include "test/cpp/util/proto_file_parser.h"
#include "test/cpp/util/proto_reflection_descriptor_database.h"
#include "test/cpp/util/service_describer.h"
-#include "test/cpp/util/test_config.h"
namespace grpc {
namespace testing {
diff --git a/test/cpp/util/proto_file_parser.cc b/test/cpp/util/proto_file_parser.cc
index 0c88c24448..98dd3f14ad 100644
--- a/test/cpp/util/proto_file_parser.cc
+++ b/test/cpp/util/proto_file_parser.cc
@@ -36,6 +36,7 @@
#include <algorithm>
#include <iostream>
#include <sstream>
+#include <unordered_set>
#include <grpc++/support/config.h>
@@ -81,12 +82,13 @@ ProtoFileParser::ProtoFileParser(std::shared_ptr<grpc::Channel> channel,
const grpc::string& proto_path,
const grpc::string& protofiles)
: has_error_(false) {
- std::vector<std::string> service_list;
+ std::vector<grpc::string> service_list;
if (channel) {
reflection_db_.reset(new grpc::ProtoReflectionDescriptorDatabase(channel));
reflection_db_->GetServices(&service_list);
}
+ std::unordered_set<grpc::string> known_services;
if (!protofiles.empty()) {
source_tree_.MapPath("", proto_path);
error_printer_.reset(new ErrorPrinter(this));
@@ -100,6 +102,7 @@ ProtoFileParser::ProtoFileParser(std::shared_ptr<grpc::Channel> channel,
if (file_desc) {
for (int i = 0; i < file_desc->service_count(); i++) {
service_desc_list_.push_back(file_desc->service(i));
+ known_services.insert(file_desc->service(i)->full_name());
}
} else {
std::cerr << file_name << " not found" << std::endl;
@@ -127,9 +130,12 @@ ProtoFileParser::ProtoFileParser(std::shared_ptr<grpc::Channel> channel,
dynamic_factory_.reset(new protobuf::DynamicMessageFactory(desc_pool_.get()));
for (auto it = service_list.begin(); it != service_list.end(); it++) {
- if (const protobuf::ServiceDescriptor* service_desc =
- desc_pool_->FindServiceByName(*it)) {
- service_desc_list_.push_back(service_desc);
+ if (known_services.find(*it) == known_services.end()) {
+ if (const protobuf::ServiceDescriptor* service_desc =
+ desc_pool_->FindServiceByName(*it)) {
+ service_desc_list_.push_back(service_desc);
+ known_services.insert(*it);
+ }
}
}
}
@@ -146,7 +152,8 @@ grpc::string ProtoFileParser::GetFullMethodName(const grpc::string& method) {
const auto* method_desc = service_desc->method(j);
if (MethodNameMatch(method_desc->full_name(), method)) {
if (method_descriptor) {
- std::ostringstream error_stream("Ambiguous method names: ");
+ std::ostringstream error_stream;
+ error_stream << "Ambiguous method names: ";
error_stream << method_descriptor->full_name() << " ";
error_stream << method_desc->full_name();
LogError(error_stream.str());
diff --git a/test/cpp/util/proto_reflection_descriptor_database.cc b/test/cpp/util/proto_reflection_descriptor_database.cc
index f0d14c686a..54790be496 100644
--- a/test/cpp/util/proto_reflection_descriptor_database.cc
+++ b/test/cpp/util/proto_reflection_descriptor_database.cc
@@ -255,7 +255,7 @@ bool ProtoReflectionDescriptorDatabase::FindAllExtensionNumbers(
}
bool ProtoReflectionDescriptorDatabase::GetServices(
- std::vector<std::string>* output) {
+ std::vector<grpc::string>* output) {
ServerReflectionRequest request;
request.set_list_services("");
ServerReflectionResponse response;
@@ -288,7 +288,7 @@ bool ProtoReflectionDescriptorDatabase::GetServices(
const protobuf::FileDescriptorProto
ProtoReflectionDescriptorDatabase::ParseFileDescriptorProtoResponse(
- const std::string& byte_fd_proto) {
+ const grpc::string& byte_fd_proto) {
protobuf::FileDescriptorProto file_desc_proto;
file_desc_proto.ParseFromString(byte_fd_proto);
return file_desc_proto;
@@ -314,13 +314,16 @@ ProtoReflectionDescriptorDatabase::GetStream() {
return stream_;
}
-void ProtoReflectionDescriptorDatabase::DoOneRequest(
+bool ProtoReflectionDescriptorDatabase::DoOneRequest(
const ServerReflectionRequest& request,
ServerReflectionResponse& response) {
+ bool success = false;
stream_mutex_.lock();
- GetStream()->Write(request);
- GetStream()->Read(&response);
+ if (GetStream()->Write(request) && GetStream()->Read(&response)) {
+ success = true;
+ }
stream_mutex_.unlock();
+ return success;
}
} // namespace grpc
diff --git a/test/cpp/util/proto_reflection_descriptor_database.h b/test/cpp/util/proto_reflection_descriptor_database.h
index 0e69696d5f..dfa36044d9 100644
--- a/test/cpp/util/proto_reflection_descriptor_database.h
+++ b/test/cpp/util/proto_reflection_descriptor_database.h
@@ -95,7 +95,7 @@ class ProtoReflectionDescriptorDatabase : public protobuf::DescriptorDatabase {
std::vector<int>* output) GRPC_OVERRIDE;
// Provide a list of full names of registered services
- bool GetServices(std::vector<std::string>* output);
+ bool GetServices(std::vector<grpc::string>* output);
private:
typedef ClientReaderWriter<
@@ -104,14 +104,14 @@ class ProtoReflectionDescriptorDatabase : public protobuf::DescriptorDatabase {
ClientStream;
const protobuf::FileDescriptorProto ParseFileDescriptorProtoResponse(
- const std::string& byte_fd_proto);
+ const grpc::string& byte_fd_proto);
void AddFileFromResponse(
const grpc::reflection::v1alpha::FileDescriptorResponse& response);
const std::shared_ptr<ClientStream> GetStream();
- void DoOneRequest(
+ bool DoOneRequest(
const grpc::reflection::v1alpha::ServerReflectionRequest& request,
grpc::reflection::v1alpha::ServerReflectionResponse& response);