s/CodegenGeneric/Raw/g

pull/15771/head
ncteisen 7 years ago
parent 8db7788d46
commit a0a59537d2
  1. 82
      CMakeLists.txt
  2. 96
      Makefile
  3. 26
      build.yaml
  4. 8
      include/grpcpp/impl/codegen/rpc_service_method.h
  5. 13
      include/grpcpp/impl/codegen/service_type.h
  6. 24
      src/compiler/cpp_generator.cc
  7. 40
      test/cpp/codegen/compiler_test_golden
  8. 20
      test/cpp/end2end/BUILD
  9. 43
      test/cpp/end2end/hybrid_end2end_test.cc
  10. 36
      test/cpp/end2end/raw_end2end_test.cc
  11. 38
      tools/run_tests/generated/sources_and_headers.json
  12. 48
      tools/run_tests/generated/tests.json

@ -559,7 +559,6 @@ add_dependencies(buildtests_cxx client_crash_test)
endif()
add_dependencies(buildtests_cxx client_crash_test_server)
add_dependencies(buildtests_cxx client_lb_end2end_test)
add_dependencies(buildtests_cxx codegen_generic_end2end_test)
add_dependencies(buildtests_cxx codegen_test_full)
add_dependencies(buildtests_cxx codegen_test_minimal)
add_dependencies(buildtests_cxx credentials_test)
@ -617,6 +616,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx qps_openloop_test)
endif()
add_dependencies(buildtests_cxx qps_worker)
add_dependencies(buildtests_cxx raw_end2end_test)
add_dependencies(buildtests_cxx reconnect_interop_client)
add_dependencies(buildtests_cxx reconnect_interop_server)
add_dependencies(buildtests_cxx ref_counted_ptr_test)
@ -11225,46 +11225,6 @@ target_link_libraries(client_lb_end2end_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(codegen_generic_end2end_test
test/cpp/end2end/codegen_generic_end2end_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(codegen_generic_end2end_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
PRIVATE third_party/googletest/googlemock
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(codegen_generic_end2end_test
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc++_test_util
grpc_test_util
grpc++
grpc
gpr_test_util
gpr
${_gRPC_GFLAGS_LIBRARIES}
)
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(codegen_test_full
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/control.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/control.grpc.pb.cc
@ -13314,6 +13274,46 @@ target_link_libraries(qps_worker
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(raw_end2end_test
test/cpp/end2end/raw_end2end_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(raw_end2end_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
PRIVATE third_party/googletest/googlemock
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(raw_end2end_test
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc++_test_util
grpc_test_util
grpc++
grpc
gpr_test_util
gpr
${_gRPC_GFLAGS_LIBRARIES}
)
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(reconnect_interop_client
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.grpc.pb.cc

@ -1151,7 +1151,6 @@ client_channel_stress_test: $(BINDIR)/$(CONFIG)/client_channel_stress_test
client_crash_test: $(BINDIR)/$(CONFIG)/client_crash_test
client_crash_test_server: $(BINDIR)/$(CONFIG)/client_crash_test_server
client_lb_end2end_test: $(BINDIR)/$(CONFIG)/client_lb_end2end_test
codegen_generic_end2end_test: $(BINDIR)/$(CONFIG)/codegen_generic_end2end_test
codegen_test_full: $(BINDIR)/$(CONFIG)/codegen_test_full
codegen_test_minimal: $(BINDIR)/$(CONFIG)/codegen_test_minimal
credentials_test: $(BINDIR)/$(CONFIG)/credentials_test
@ -1200,6 +1199,7 @@ qps_interarrival_test: $(BINDIR)/$(CONFIG)/qps_interarrival_test
qps_json_driver: $(BINDIR)/$(CONFIG)/qps_json_driver
qps_openloop_test: $(BINDIR)/$(CONFIG)/qps_openloop_test
qps_worker: $(BINDIR)/$(CONFIG)/qps_worker
raw_end2end_test: $(BINDIR)/$(CONFIG)/raw_end2end_test
reconnect_interop_client: $(BINDIR)/$(CONFIG)/reconnect_interop_client
reconnect_interop_server: $(BINDIR)/$(CONFIG)/reconnect_interop_server
ref_counted_ptr_test: $(BINDIR)/$(CONFIG)/ref_counted_ptr_test
@ -1647,7 +1647,6 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/client_crash_test \
$(BINDIR)/$(CONFIG)/client_crash_test_server \
$(BINDIR)/$(CONFIG)/client_lb_end2end_test \
$(BINDIR)/$(CONFIG)/codegen_generic_end2end_test \
$(BINDIR)/$(CONFIG)/codegen_test_full \
$(BINDIR)/$(CONFIG)/codegen_test_minimal \
$(BINDIR)/$(CONFIG)/credentials_test \
@ -1689,6 +1688,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/qps_json_driver \
$(BINDIR)/$(CONFIG)/qps_openloop_test \
$(BINDIR)/$(CONFIG)/qps_worker \
$(BINDIR)/$(CONFIG)/raw_end2end_test \
$(BINDIR)/$(CONFIG)/reconnect_interop_client \
$(BINDIR)/$(CONFIG)/reconnect_interop_server \
$(BINDIR)/$(CONFIG)/ref_counted_ptr_test \
@ -1825,7 +1825,6 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/client_crash_test \
$(BINDIR)/$(CONFIG)/client_crash_test_server \
$(BINDIR)/$(CONFIG)/client_lb_end2end_test \
$(BINDIR)/$(CONFIG)/codegen_generic_end2end_test \
$(BINDIR)/$(CONFIG)/codegen_test_full \
$(BINDIR)/$(CONFIG)/codegen_test_minimal \
$(BINDIR)/$(CONFIG)/credentials_test \
@ -1867,6 +1866,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/qps_json_driver \
$(BINDIR)/$(CONFIG)/qps_openloop_test \
$(BINDIR)/$(CONFIG)/qps_worker \
$(BINDIR)/$(CONFIG)/raw_end2end_test \
$(BINDIR)/$(CONFIG)/reconnect_interop_client \
$(BINDIR)/$(CONFIG)/reconnect_interop_server \
$(BINDIR)/$(CONFIG)/ref_counted_ptr_test \
@ -2275,8 +2275,6 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/client_crash_test || ( echo test client_crash_test failed ; exit 1 )
$(E) "[RUN] Testing client_lb_end2end_test"
$(Q) $(BINDIR)/$(CONFIG)/client_lb_end2end_test || ( echo test client_lb_end2end_test failed ; exit 1 )
$(E) "[RUN] Testing codegen_generic_end2end_test"
$(Q) $(BINDIR)/$(CONFIG)/codegen_generic_end2end_test || ( echo test codegen_generic_end2end_test failed ; exit 1 )
$(E) "[RUN] Testing codegen_test_full"
$(Q) $(BINDIR)/$(CONFIG)/codegen_test_full || ( echo test codegen_test_full failed ; exit 1 )
$(E) "[RUN] Testing codegen_test_minimal"
@ -2339,6 +2337,8 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/proto_utils_test || ( echo test proto_utils_test failed ; exit 1 )
$(E) "[RUN] Testing qps_openloop_test"
$(Q) $(BINDIR)/$(CONFIG)/qps_openloop_test || ( echo test qps_openloop_test failed ; exit 1 )
$(E) "[RUN] Testing raw_end2end_test"
$(Q) $(BINDIR)/$(CONFIG)/raw_end2end_test || ( echo test raw_end2end_test failed ; exit 1 )
$(E) "[RUN] Testing ref_counted_ptr_test"
$(Q) $(BINDIR)/$(CONFIG)/ref_counted_ptr_test || ( echo test ref_counted_ptr_test failed ; exit 1 )
$(E) "[RUN] Testing ref_counted_test"
@ -16943,49 +16943,6 @@ endif
endif
CODEGEN_GENERIC_END2END_TEST_SRC = \
test/cpp/end2end/codegen_generic_end2end_test.cc \
CODEGEN_GENERIC_END2END_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CODEGEN_GENERIC_END2END_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/codegen_generic_end2end_test: openssl_dep_error
else
ifeq ($(NO_PROTOBUF),true)
# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+.
$(BINDIR)/$(CONFIG)/codegen_generic_end2end_test: protobuf_dep_error
else
$(BINDIR)/$(CONFIG)/codegen_generic_end2end_test: $(PROTOBUF_DEP) $(CODEGEN_GENERIC_END2END_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(CODEGEN_GENERIC_END2END_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/codegen_generic_end2end_test
endif
endif
$(OBJDIR)/$(CONFIG)/test/cpp/end2end/codegen_generic_end2end_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_codegen_generic_end2end_test: $(CODEGEN_GENERIC_END2END_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(CODEGEN_GENERIC_END2END_TEST_OBJS:.o=.dep)
endif
endif
CODEGEN_TEST_FULL_SRC = \
$(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc \
$(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc \
@ -19006,6 +18963,49 @@ endif
endif
RAW_END2END_TEST_SRC = \
test/cpp/end2end/raw_end2end_test.cc \
RAW_END2END_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(RAW_END2END_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/raw_end2end_test: openssl_dep_error
else
ifeq ($(NO_PROTOBUF),true)
# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+.
$(BINDIR)/$(CONFIG)/raw_end2end_test: protobuf_dep_error
else
$(BINDIR)/$(CONFIG)/raw_end2end_test: $(PROTOBUF_DEP) $(RAW_END2END_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(RAW_END2END_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/raw_end2end_test
endif
endif
$(OBJDIR)/$(CONFIG)/test/cpp/end2end/raw_end2end_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_raw_end2end_test: $(RAW_END2END_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(RAW_END2END_TEST_OBJS:.o=.dep)
endif
endif
RECONNECT_INTEROP_CLIENT_SRC = \
$(GENDIR)/src/proto/grpc/testing/empty.pb.cc $(GENDIR)/src/proto/grpc/testing/empty.grpc.pb.cc \
$(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc \

@ -4422,19 +4422,6 @@ targets:
- grpc
- gpr_test_util
- gpr
- name: codegen_generic_end2end_test
gtest: true
build: test
language: c++
src:
- test/cpp/end2end/codegen_generic_end2end_test.cc
deps:
- grpc++_test_util
- grpc_test_util
- grpc++
- grpc
- gpr_test_util
- gpr
- name: codegen_test_full
gtest: true
build: test
@ -5111,6 +5098,19 @@ targets:
- gpr_test_util
- gpr
- grpc++_test_config
- name: raw_end2end_test
gtest: true
build: test
language: c++
src:
- test/cpp/end2end/raw_end2end_test.cc
deps:
- grpc++_test_util
- grpc_test_util
- grpc++
- grpc
- gpr_test_util
- gpr
- name: reconnect_interop_client
build: test
run: false

@ -67,7 +67,7 @@ class RpcServiceMethod : public RpcMethod {
enum class AsyncType {
UNSET,
ASYNC,
CODEGEN_GENERIC,
RAW,
};
void set_server_tag(void* tag) { server_tag_ = tag; }
@ -81,7 +81,7 @@ class RpcServiceMethod : public RpcMethod {
handler_.reset();
} else {
// this is not an error condition, as it allows users to declare a server
// like WithCodegenGenericMethod_foo<AsyncService>. However since it
// like WithRawMethod_foo<AsyncService>. However since it
// overwrites behavior, it should be logged.
gpr_log(
GPR_INFO,
@ -104,8 +104,8 @@ class RpcServiceMethod : public RpcMethod {
return "unset";
case AsyncType::ASYNC:
return "async";
case AsyncType::CODEGEN_GENERIC:
return "codegen generic";
case AsyncType::RAW:
return "raw";
default:
GPR_UNREACHABLE_CODE(return "unknown");
}

@ -134,15 +134,14 @@ class Service {
internal::RpcServiceMethod::AsyncType::ASYNC);
}
void MarkMethodCodegenGeneric(int index) {
void MarkMethodRaw(int index) {
// This does not have to be a hard error, however no one has approached us
// with a use case yet. Please file an issue if you believe you have one.
GPR_CODEGEN_ASSERT(
methods_[index].get() != nullptr &&
"Cannot mark the method as 'codegen generic' because it has already "
"been marked as 'generic'.");
GPR_CODEGEN_ASSERT(methods_[index].get() != nullptr &&
"Cannot mark the method as 'raw' because it has already "
"been marked as 'generic'.");
methods_[index]->SetServerAsyncType(
internal::RpcServiceMethod::AsyncType::CODEGEN_GENERIC);
internal::RpcServiceMethod::AsyncType::RAW);
}
void MarkMethodGeneric(int index) {
@ -151,7 +150,7 @@ class Service {
GPR_CODEGEN_ASSERT(
methods_[index]->handler() != nullptr &&
"Cannot mark the method as 'generic' because it has already been "
"marked as 'async' or 'codegen generic'.");
"marked as 'async' or 'raw'.");
methods_[index].reset();
}

@ -591,7 +591,7 @@ void PrintHeaderServerMethodSync(grpc_generator::Printer* printer,
// Helper generator. Disabled the sync API for Request and Response, then adds
// in an async API for RealRequest and RealResponse types. This is to be used
// to generate async and codegen generic APIs.
// to generate async and raw APIs.
void PrintHeaderServerAsyncMethodsHelper(
grpc_generator::Printer* printer, const grpc_generator::Method* method,
std::map<grpc::string, grpc::string>* vars) {
@ -892,30 +892,29 @@ void PrintHeaderServerMethodGeneric(
printer->Print(*vars, "};\n");
}
void PrintHeaderServerMethodCodegenGeneric(
grpc_generator::Printer* printer, const grpc_generator::Method* method,
std::map<grpc::string, grpc::string>* vars) {
void PrintHeaderServerMethodRaw(grpc_generator::Printer* printer,
const grpc_generator::Method* method,
std::map<grpc::string, grpc::string>* vars) {
(*vars)["Method"] = method->name();
// These will be disabled
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
// These will be used for codegen generic API
// These will be used for raw API
(*vars)["RealRequest"] = "::grpc::ByteBuffer";
(*vars)["RealResponse"] = "::grpc::ByteBuffer";
printer->Print(*vars, "template <class BaseClass>\n");
printer->Print(
*vars, "class WithCodegenGenericMethod_$Method$ : public BaseClass {\n");
printer->Print(*vars, "class WithRawMethod_$Method$ : public BaseClass {\n");
printer->Print(
" private:\n"
" void BaseClassMustBeDerivedFromService(const Service *service) {}\n");
printer->Print(" public:\n");
printer->Indent();
printer->Print(*vars,
"WithCodegenGenericMethod_$Method$() {\n"
" ::grpc::Service::MarkMethodCodegenGeneric($Idx$);\n"
"WithRawMethod_$Method$() {\n"
" ::grpc::Service::MarkMethodRaw($Idx$);\n"
"}\n");
printer->Print(*vars,
"~WithCodegenGenericMethod_$Method$() override {\n"
"~WithRawMethod_$Method$() override {\n"
" BaseClassMustBeDerivedFromService(this);\n"
"}\n");
PrintHeaderServerAsyncMethodsHelper(printer, method, vars);
@ -1027,11 +1026,10 @@ void PrintHeaderService(grpc_generator::Printer* printer,
PrintHeaderServerMethodGeneric(printer, service->method(i).get(), vars);
}
// Server side - CodegenGeneric
// Server side - Raw
for (int i = 0; i < service->method_count(); ++i) {
(*vars)["Idx"] = as_string(i);
PrintHeaderServerMethodCodegenGeneric(printer, service->method(i).get(),
vars);
PrintHeaderServerMethodRaw(printer, service->method(i).get(), vars);
}
// Server side - Streamed Unary

@ -346,14 +346,14 @@ class ServiceA final {
}
};
template <class BaseClass>
class WithCodegenGenericMethod_MethodA1 : public BaseClass {
class WithRawMethod_MethodA1 : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
public:
WithCodegenGenericMethod_MethodA1() {
::grpc::Service::MarkMethodCodegenGeneric(0);
WithRawMethod_MethodA1() {
::grpc::Service::MarkMethodRaw(0);
}
~WithCodegenGenericMethod_MethodA1() override {
~WithRawMethod_MethodA1() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
@ -366,14 +366,14 @@ class ServiceA final {
}
};
template <class BaseClass>
class WithCodegenGenericMethod_MethodA2 : public BaseClass {
class WithRawMethod_MethodA2 : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
public:
WithCodegenGenericMethod_MethodA2() {
::grpc::Service::MarkMethodCodegenGeneric(1);
WithRawMethod_MethodA2() {
::grpc::Service::MarkMethodRaw(1);
}
~WithCodegenGenericMethod_MethodA2() override {
~WithRawMethod_MethodA2() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
@ -386,14 +386,14 @@ class ServiceA final {
}
};
template <class BaseClass>
class WithCodegenGenericMethod_MethodA3 : public BaseClass {
class WithRawMethod_MethodA3 : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
public:
WithCodegenGenericMethod_MethodA3() {
::grpc::Service::MarkMethodCodegenGeneric(2);
WithRawMethod_MethodA3() {
::grpc::Service::MarkMethodRaw(2);
}
~WithCodegenGenericMethod_MethodA3() override {
~WithRawMethod_MethodA3() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
@ -406,14 +406,14 @@ class ServiceA final {
}
};
template <class BaseClass>
class WithCodegenGenericMethod_MethodA4 : public BaseClass {
class WithRawMethod_MethodA4 : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
public:
WithCodegenGenericMethod_MethodA4() {
::grpc::Service::MarkMethodCodegenGeneric(3);
WithRawMethod_MethodA4() {
::grpc::Service::MarkMethodRaw(3);
}
~WithCodegenGenericMethod_MethodA4() override {
~WithRawMethod_MethodA4() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
@ -558,14 +558,14 @@ class ServiceB final {
}
};
template <class BaseClass>
class WithCodegenGenericMethod_MethodB1 : public BaseClass {
class WithRawMethod_MethodB1 : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
public:
WithCodegenGenericMethod_MethodB1() {
::grpc::Service::MarkMethodCodegenGeneric(0);
WithRawMethod_MethodB1() {
::grpc::Service::MarkMethodRaw(0);
}
~WithCodegenGenericMethod_MethodB1() override {
~WithRawMethod_MethodB1() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method

@ -241,6 +241,26 @@ grpc_cc_test(
],
)
grpc_cc_test(
name = "raw_end2end_test",
srcs = ["raw_end2end_test.cc"],
external_deps = [
"gtest",
],
deps = [
":test_service_impl",
"//:gpr",
"//:grpc",
"//:grpc++",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
"//test/core/util:gpr_test_util",
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
)
grpc_cc_test(
name = "mock_test",
srcs = ["mock_test.cc"],

@ -74,12 +74,12 @@ void HandleEcho(Service* service, ServerCompletionQueue* cq, bool dup_service) {
Verify(cq, 2, true);
}
// Handlers to handle codegen generic request at a server. To be run in a
// Handlers to handle raw request at a server. To be run in a
// separate thread. Note that this is the same as the async version, except
// that the req/resp are ByteBuffers
template <class Service>
void HandleCodegenGenericEcho(Service* service, ServerCompletionQueue* cq,
bool dup_service) {
void HandleRawEcho(Service* service, ServerCompletionQueue* cq,
bool dup_service) {
ServerContext srv_ctx;
GenericServerAsyncResponseWriter response_writer(&srv_ctx);
ByteBuffer recv_buffer;
@ -114,8 +114,7 @@ void HandleClientStreaming(Service* service, ServerCompletionQueue* cq) {
}
template <class Service>
void HandleCodegenGenericClientStreaming(Service* service,
ServerCompletionQueue* cq) {
void HandleRawClientStreaming(Service* service, ServerCompletionQueue* cq) {
ServerContext srv_ctx;
ByteBuffer recv_buffer;
EchoRequest recv_request;
@ -425,32 +424,30 @@ TEST_F(HybridEnd2endTest, AsyncEcho) {
echo_handler_thread.join();
}
TEST_F(HybridEnd2endTest, CodegenGenericEcho) {
typedef EchoTestService::WithCodegenGenericMethod_Echo<TestServiceImpl> SType;
TEST_F(HybridEnd2endTest, RawEcho) {
typedef EchoTestService::WithRawMethod_Echo<TestServiceImpl> SType;
SType service;
SetUpServer(&service, nullptr, nullptr);
ResetStub();
std::thread echo_handler_thread(HandleCodegenGenericEcho<SType>, &service,
cqs_[0].get(), false);
std::thread echo_handler_thread(HandleRawEcho<SType>, &service, cqs_[0].get(),
false);
TestAllMethods();
echo_handler_thread.join();
}
TEST_F(HybridEnd2endTest, CodegenGenericRequestStream) {
typedef EchoTestService::WithCodegenGenericMethod_RequestStream<
TestServiceImpl>
SType;
TEST_F(HybridEnd2endTest, RawRequestStream) {
typedef EchoTestService::WithRawMethod_RequestStream<TestServiceImpl> SType;
SType service;
SetUpServer(&service, nullptr, nullptr);
ResetStub();
std::thread request_stream_handler_thread(
HandleCodegenGenericClientStreaming<SType>, &service, cqs_[0].get());
std::thread request_stream_handler_thread(HandleRawClientStreaming<SType>,
&service, cqs_[0].get());
TestAllMethods();
request_stream_handler_thread.join();
}
TEST_F(HybridEnd2endTest, AsyncEchoCodegenGenericRequestStream) {
typedef EchoTestService::WithCodegenGenericMethod_RequestStream<
TEST_F(HybridEnd2endTest, AsyncEchoRawRequestStream) {
typedef EchoTestService::WithRawMethod_RequestStream<
EchoTestService::WithAsyncMethod_Echo<TestServiceImpl>>
SType;
SType service;
@ -458,15 +455,15 @@ TEST_F(HybridEnd2endTest, AsyncEchoCodegenGenericRequestStream) {
ResetStub();
std::thread echo_handler_thread(HandleEcho<SType>, &service, cqs_[0].get(),
false);
std::thread request_stream_handler_thread(
HandleCodegenGenericClientStreaming<SType>, &service, cqs_[1].get());
std::thread request_stream_handler_thread(HandleRawClientStreaming<SType>,
&service, cqs_[1].get());
TestAllMethods();
request_stream_handler_thread.join();
echo_handler_thread.join();
}
TEST_F(HybridEnd2endTest, GenericEchoCodegenGenericRequestStream) {
typedef EchoTestService::WithCodegenGenericMethod_RequestStream<
TEST_F(HybridEnd2endTest, GenericEchoRawRequestStream) {
typedef EchoTestService::WithRawMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl>>
SType;
SType service;
@ -475,8 +472,8 @@ TEST_F(HybridEnd2endTest, GenericEchoCodegenGenericRequestStream) {
ResetStub();
std::thread generic_handler_thread(HandleGenericCall, &generic_service,
cqs_[0].get());
std::thread request_stream_handler_thread(
HandleCodegenGenericClientStreaming<SType>, &service, cqs_[1].get());
std::thread request_stream_handler_thread(HandleRawClientStreaming<SType>,
&service, cqs_[1].get());
TestAllMethods();
generic_handler_thread.join();
request_stream_handler_thread.join();

@ -189,9 +189,9 @@ class Verifier {
bool lambda_run_;
};
class CodegenGenericEnd2EndTest : public ::testing::Test {
class RawEnd2EndTest : public ::testing::Test {
protected:
CodegenGenericEnd2EndTest() {}
RawEnd2EndTest() {}
void SetUp() override {
port_ = grpc_pick_unused_port_or_die();
@ -259,7 +259,7 @@ class CodegenGenericEnd2EndTest : public ::testing::Test {
};
// Regular Async, both peers use proto
TEST_F(CodegenGenericEnd2EndTest, PureAsyncService) {
TEST_F(RawEnd2EndTest, PureAsyncService) {
typedef grpc::testing::EchoTestService::AsyncService SType;
ResetStub();
auto service = BuildAndStartServer<SType>();
@ -282,8 +282,8 @@ TEST_F(CodegenGenericEnd2EndTest, PureAsyncService) {
}
// Client uses proto, server uses generic codegen, unary
TEST_F(CodegenGenericEnd2EndTest, CodegenGenericServerUnary) {
typedef grpc::testing::EchoTestService::WithCodegenGenericMethod_Echo<
TEST_F(RawEnd2EndTest, RawServerUnary) {
typedef grpc::testing::EchoTestService::WithRawMethod_Echo<
grpc::testing::EchoTestService::Service>
SType;
ResetStub();
@ -310,11 +310,10 @@ TEST_F(CodegenGenericEnd2EndTest, CodegenGenericServerUnary) {
}
// Client uses proto, server uses generic codegen, client streaming
TEST_F(CodegenGenericEnd2EndTest, CodegenGenericServerClientStreaming) {
typedef grpc::testing::EchoTestService::
WithCodegenGenericMethod_RequestStream<
grpc::testing::EchoTestService::Service>
SType;
TEST_F(RawEnd2EndTest, RawServerClientStreaming) {
typedef grpc::testing::EchoTestService::WithRawMethod_RequestStream<
grpc::testing::EchoTestService::Service>
SType;
ResetStub();
auto service = BuildAndStartServer<SType>();
@ -357,11 +356,10 @@ TEST_F(CodegenGenericEnd2EndTest, CodegenGenericServerClientStreaming) {
}
// Client uses proto, server uses generic codegen, server streaming
TEST_F(CodegenGenericEnd2EndTest, CodegenGenericServerServerStreaming) {
typedef grpc::testing::EchoTestService::
WithCodegenGenericMethod_ResponseStream<
grpc::testing::EchoTestService::Service>
SType;
TEST_F(RawEnd2EndTest, RawServerServerStreaming) {
typedef grpc::testing::EchoTestService::WithRawMethod_ResponseStream<
grpc::testing::EchoTestService::Service>
SType;
ResetStub();
auto service = BuildAndStartServer<SType>();
grpc::GenericServerAsyncWriter srv_stream(&srv_ctx_);
@ -400,8 +398,8 @@ TEST_F(CodegenGenericEnd2EndTest, CodegenGenericServerServerStreaming) {
}
// Client uses proto, server uses generic codegen, bidi streaming
TEST_F(CodegenGenericEnd2EndTest, CodegenGenericServerBidiStreaming) {
typedef grpc::testing::EchoTestService::WithCodegenGenericMethod_BidiStream<
TEST_F(RawEnd2EndTest, RawServerBidiStreaming) {
typedef grpc::testing::EchoTestService::WithRawMethod_BidiStream<
grpc::testing::EchoTestService::Service>
SType;
ResetStub();
@ -443,8 +441,8 @@ TEST_F(CodegenGenericEnd2EndTest, CodegenGenericServerBidiStreaming) {
}
// Testing that this pattern compiles
TEST_F(CodegenGenericEnd2EndTest, CompileTest) {
typedef grpc::testing::EchoTestService::WithCodegenGenericMethod_Echo<
TEST_F(RawEnd2EndTest, CompileTest) {
typedef grpc::testing::EchoTestService::WithRawMethod_Echo<
grpc::testing::EchoTestService::AsyncService>
SType;
ResetStub();

@ -3327,25 +3327,6 @@
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",
"gpr_test_util",
"grpc",
"grpc++",
"grpc++_test_util",
"grpc_test_util"
],
"headers": [],
"is_filegroup": false,
"language": "c++",
"name": "codegen_generic_end2end_test",
"src": [
"test/cpp/end2end/codegen_generic_end2end_test.cc"
],
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",
@ -4299,6 +4280,25 @@
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",
"gpr_test_util",
"grpc",
"grpc++",
"grpc++_test_util",
"grpc_test_util"
],
"headers": [],
"is_filegroup": false,
"language": "c++",
"name": "raw_end2end_test",
"src": [
"test/cpp/end2end/raw_end2end_test.cc"
],
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",

@ -3945,30 +3945,6 @@
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": true,
"language": "c++",
"name": "codegen_generic_end2end_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
@ -4733,6 +4709,30 @@
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": true,
"language": "c++",
"name": "raw_end2end_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,

Loading…
Cancel
Save