diff options
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | build.yaml | 5 | ||||
-rw-r--r-- | test/cpp/qps/parse_json.cc | 15 | ||||
-rw-r--r-- | test/cpp/qps/parse_json.h | 3 | ||||
-rw-r--r-- | test/cpp/qps/report.cc | 18 | ||||
-rw-r--r-- | tools/run_tests/sources_and_headers.json | 9 | ||||
-rw-r--r-- | vsprojects/vcxproj/qps/qps.vcxproj | 3 | ||||
-rw-r--r-- | vsprojects/vcxproj/qps/qps.vcxproj.filters | 6 | ||||
-rw-r--r-- | vsprojects/vcxproj/test/qps_json_driver/qps_json_driver.vcxproj | 5 | ||||
-rw-r--r-- | vsprojects/vcxproj/test/qps_json_driver/qps_json_driver.vcxproj.filters | 8 |
10 files changed, 39 insertions, 39 deletions
@@ -4255,6 +4255,7 @@ LIBQPS_SRC = \ test/cpp/qps/client_sync.cc \ test/cpp/qps/driver.cc \ test/cpp/qps/limit_cores.cc \ + test/cpp/qps/parse_json.cc \ test/cpp/qps/qps_worker.cc \ test/cpp/qps/report.cc \ test/cpp/qps/server_async.cc \ @@ -4310,6 +4311,7 @@ $(OBJDIR)/$(CONFIG)/test/cpp/qps/client_async.o: $(GENDIR)/src/proto/grpc/testin $(OBJDIR)/$(CONFIG)/test/cpp/qps/client_sync.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/driver.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/limit_cores.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/parse_json.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_worker.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/report.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/server_async.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc @@ -11331,7 +11333,6 @@ endif QPS_JSON_DRIVER_SRC = \ - test/cpp/qps/parse_json.cc \ test/cpp/qps/qps_json_driver.cc \ QPS_JSON_DRIVER_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(QPS_JSON_DRIVER_SRC)))) @@ -11363,8 +11364,6 @@ endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/qps/parse_json.o: $(LIBDIR)/$(CONFIG)/libqps.a $(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 $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a - $(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_json_driver.o: $(LIBDIR)/$(CONFIG)/libqps.a $(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 $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a deps_qps_json_driver: $(QPS_JSON_DRIVER_OBJS:.o=.dep) @@ -14577,6 +14576,7 @@ test/cpp/qps/client_async.cc: $(OPENSSL_DEP) test/cpp/qps/client_sync.cc: $(OPENSSL_DEP) test/cpp/qps/driver.cc: $(OPENSSL_DEP) test/cpp/qps/limit_cores.cc: $(OPENSSL_DEP) +test/cpp/qps/parse_json.cc: $(OPENSSL_DEP) test/cpp/qps/qps_worker.cc: $(OPENSSL_DEP) test/cpp/qps/report.cc: $(OPENSSL_DEP) test/cpp/qps/server_async.cc: $(OPENSSL_DEP) diff --git a/build.yaml b/build.yaml index 8c09c55335..75d21b556d 100644 --- a/build.yaml +++ b/build.yaml @@ -1120,6 +1120,7 @@ libs: - test/cpp/qps/histogram.h - test/cpp/qps/interarrival.h - test/cpp/qps/limit_cores.h + - test/cpp/qps/parse_json.h - test/cpp/qps/qps_worker.h - test/cpp/qps/report.h - test/cpp/qps/server.h @@ -1136,6 +1137,7 @@ libs: - test/cpp/qps/client_sync.cc - test/cpp/qps/driver.cc - test/cpp/qps/limit_cores.cc + - test/cpp/qps/parse_json.cc - test/cpp/qps/qps_worker.cc - test/cpp/qps/report.cc - test/cpp/qps/server_async.cc @@ -2811,10 +2813,7 @@ targets: build: test run: false language: c++ - headers: - - test/cpp/qps/parse_json.h src: - - test/cpp/qps/parse_json.cc - test/cpp/qps/qps_json_driver.cc deps: - qps diff --git a/test/cpp/qps/parse_json.cc b/test/cpp/qps/parse_json.cc index a90bf6153c..be804281f8 100644 --- a/test/cpp/qps/parse_json.cc +++ b/test/cpp/qps/parse_json.cc @@ -61,5 +61,20 @@ void ParseJson(const grpc::string& json, const grpc::string& type, GPR_ASSERT(msg->ParseFromString(binary)); } +grpc::string SerializeJson(const GRPC_CUSTOM_MESSAGE& msg, + const grpc::string& type) { + std::unique_ptr<google::protobuf::util::TypeResolver> type_resolver( + google::protobuf::util::NewTypeResolverForDescriptorPool( + "type.googleapis.com", + google::protobuf::DescriptorPool::generated_pool())); + grpc::string binary; + grpc::string json_string; + msg.SerializeToString(&binary); + auto status = + BinaryToJsonString(type_resolver.get(), type, binary, &json_string); + GPR_ASSERT(status.ok()); + return json_string; +} + } // testing } // grpc diff --git a/test/cpp/qps/parse_json.h b/test/cpp/qps/parse_json.h index 42d7d22c53..ce1821f961 100644 --- a/test/cpp/qps/parse_json.h +++ b/test/cpp/qps/parse_json.h @@ -43,6 +43,9 @@ namespace testing { void ParseJson(const grpc::string& json, const grpc::string& type, GRPC_CUSTOM_MESSAGE* msg); +grpc::string SerializeJson(const GRPC_CUSTOM_MESSAGE& msg, + const grpc::string& type); + } // testing } // grpc diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 3ae41399cf..2ec7d8676c 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -35,11 +35,9 @@ #include <fstream> -#include <google/protobuf/util/json_util.h> -#include <google/protobuf/util/type_resolver_util.h> - #include <grpc/support/log.h> #include "test/cpp/qps/driver.h" +#include "test/cpp/qps/parse_json.h" #include "test/cpp/qps/stats.h" namespace grpc { @@ -104,18 +102,8 @@ void GprLogReporter::ReportTimes(const ScenarioResult& result) { } void JsonReporter::ReportQPS(const ScenarioResult& result) { - std::unique_ptr<google::protobuf::util::TypeResolver> type_resolver( - google::protobuf::util::NewTypeResolverForDescriptorPool( - "type.googleapis.com", - google::protobuf::DescriptorPool::generated_pool())); - grpc::string binary; - grpc::string json_string; - result.SerializeToString(&binary); - auto status = BinaryToJsonString( - type_resolver.get(), "type.googleapis.com/grpc.testing.ScenarioResult", - binary, &json_string); - GPR_ASSERT(status.ok()); - + grpc::string json_string = + SerializeJson(result, "type.googleapis.com/grpc.testing.ScenarioResult"); std::ofstream output_file(report_file_); output_file << json_string; output_file.close(); diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 325aca18a7..b1e0126542 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -2361,14 +2361,10 @@ "grpc_test_util", "qps" ], - "headers": [ - "test/cpp/qps/parse_json.h" - ], + "headers": [], "language": "c++", "name": "qps_json_driver", "src": [ - "test/cpp/qps/parse_json.cc", - "test/cpp/qps/parse_json.h", "test/cpp/qps/qps_json_driver.cc" ], "third_party": false, @@ -4546,6 +4542,7 @@ "test/cpp/qps/histogram.h", "test/cpp/qps/interarrival.h", "test/cpp/qps/limit_cores.h", + "test/cpp/qps/parse_json.h", "test/cpp/qps/qps_worker.h", "test/cpp/qps/report.h", "test/cpp/qps/server.h", @@ -4565,6 +4562,8 @@ "test/cpp/qps/interarrival.h", "test/cpp/qps/limit_cores.cc", "test/cpp/qps/limit_cores.h", + "test/cpp/qps/parse_json.cc", + "test/cpp/qps/parse_json.h", "test/cpp/qps/qps_worker.cc", "test/cpp/qps/qps_worker.h", "test/cpp/qps/report.cc", diff --git a/vsprojects/vcxproj/qps/qps.vcxproj b/vsprojects/vcxproj/qps/qps.vcxproj index 32413625ed..004cf7c9f0 100644 --- a/vsprojects/vcxproj/qps/qps.vcxproj +++ b/vsprojects/vcxproj/qps/qps.vcxproj @@ -152,6 +152,7 @@ <ClInclude Include="$(SolutionDir)\..\test\cpp\qps\histogram.h" /> <ClInclude Include="$(SolutionDir)\..\test\cpp\qps\interarrival.h" /> <ClInclude Include="$(SolutionDir)\..\test\cpp\qps\limit_cores.h" /> + <ClInclude Include="$(SolutionDir)\..\test\cpp\qps\parse_json.h" /> <ClInclude Include="$(SolutionDir)\..\test\cpp\qps\qps_worker.h" /> <ClInclude Include="$(SolutionDir)\..\test\cpp\qps\report.h" /> <ClInclude Include="$(SolutionDir)\..\test\cpp\qps\server.h" /> @@ -208,6 +209,8 @@ </ClCompile> <ClCompile Include="$(SolutionDir)\..\test\cpp\qps\limit_cores.cc"> </ClCompile> + <ClCompile Include="$(SolutionDir)\..\test\cpp\qps\parse_json.cc"> + </ClCompile> <ClCompile Include="$(SolutionDir)\..\test\cpp\qps\qps_worker.cc"> </ClCompile> <ClCompile Include="$(SolutionDir)\..\test\cpp\qps\report.cc"> diff --git a/vsprojects/vcxproj/qps/qps.vcxproj.filters b/vsprojects/vcxproj/qps/qps.vcxproj.filters index 54d438f536..d3a440ba73 100644 --- a/vsprojects/vcxproj/qps/qps.vcxproj.filters +++ b/vsprojects/vcxproj/qps/qps.vcxproj.filters @@ -28,6 +28,9 @@ <ClCompile Include="$(SolutionDir)\..\test\cpp\qps\limit_cores.cc"> <Filter>test\cpp\qps</Filter> </ClCompile> + <ClCompile Include="$(SolutionDir)\..\test\cpp\qps\parse_json.cc"> + <Filter>test\cpp\qps</Filter> + </ClCompile> <ClCompile Include="$(SolutionDir)\..\test\cpp\qps\qps_worker.cc"> <Filter>test\cpp\qps</Filter> </ClCompile> @@ -63,6 +66,9 @@ <ClInclude Include="$(SolutionDir)\..\test\cpp\qps\limit_cores.h"> <Filter>test\cpp\qps</Filter> </ClInclude> + <ClInclude Include="$(SolutionDir)\..\test\cpp\qps\parse_json.h"> + <Filter>test\cpp\qps</Filter> + </ClInclude> <ClInclude Include="$(SolutionDir)\..\test\cpp\qps\qps_worker.h"> <Filter>test\cpp\qps</Filter> </ClInclude> diff --git a/vsprojects/vcxproj/test/qps_json_driver/qps_json_driver.vcxproj b/vsprojects/vcxproj/test/qps_json_driver/qps_json_driver.vcxproj index 3884c10236..d1dea3ec4a 100644 --- a/vsprojects/vcxproj/test/qps_json_driver/qps_json_driver.vcxproj +++ b/vsprojects/vcxproj/test/qps_json_driver/qps_json_driver.vcxproj @@ -160,11 +160,6 @@ </ItemDefinitionGroup> <ItemGroup> - <ClInclude Include="$(SolutionDir)\..\test\cpp\qps\parse_json.h" /> - </ItemGroup> - <ItemGroup> - <ClCompile Include="$(SolutionDir)\..\test\cpp\qps\parse_json.cc"> - </ClCompile> <ClCompile Include="$(SolutionDir)\..\test\cpp\qps\qps_json_driver.cc"> </ClCompile> </ItemGroup> diff --git a/vsprojects/vcxproj/test/qps_json_driver/qps_json_driver.vcxproj.filters b/vsprojects/vcxproj/test/qps_json_driver/qps_json_driver.vcxproj.filters index cde967fc27..62b9be85cc 100644 --- a/vsprojects/vcxproj/test/qps_json_driver/qps_json_driver.vcxproj.filters +++ b/vsprojects/vcxproj/test/qps_json_driver/qps_json_driver.vcxproj.filters @@ -1,18 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> - <ClCompile Include="$(SolutionDir)\..\test\cpp\qps\parse_json.cc"> - <Filter>test\cpp\qps</Filter> - </ClCompile> <ClCompile Include="$(SolutionDir)\..\test\cpp\qps\qps_json_driver.cc"> <Filter>test\cpp\qps</Filter> </ClCompile> </ItemGroup> - <ItemGroup> - <ClInclude Include="$(SolutionDir)\..\test\cpp\qps\parse_json.h"> - <Filter>test\cpp\qps</Filter> - </ClInclude> - </ItemGroup> <ItemGroup> <Filter Include="test"> |