secure_sync_unary_ping_pong_test.cc 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. *
  3. * Copyright 2015 gRPC authors.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. #include <set>
  19. #include <grpc/support/log.h>
  20. #include "test/core/util/test_config.h"
  21. #include "test/cpp/qps/benchmark_config.h"
  22. #include "test/cpp/qps/driver.h"
  23. #include "test/cpp/qps/report.h"
  24. #include "test/cpp/qps/server.h"
  25. #include "test/cpp/util/test_config.h"
  26. #include "test/cpp/util/test_credentials_provider.h"
  27. namespace grpc {
  28. namespace testing {
  29. static const int WARMUP = 1;
  30. static const int BENCHMARK = 3;
  31. static void RunSynchronousUnaryPingPong() {
  32. gpr_log(GPR_INFO, "Running Synchronous Unary Ping Pong");
  33. ClientConfig client_config;
  34. client_config.set_client_type(SYNC_CLIENT);
  35. client_config.set_outstanding_rpcs_per_channel(1);
  36. client_config.set_client_channels(1);
  37. client_config.set_rpc_type(UNARY);
  38. client_config.mutable_load_params()->mutable_closed_loop();
  39. ServerConfig server_config;
  40. server_config.set_server_type(SYNC_SERVER);
  41. // Set up security params
  42. SecurityParams security;
  43. security.set_use_test_ca(true);
  44. security.set_server_host_override("foo.test.google.fr");
  45. client_config.mutable_security_params()->CopyFrom(security);
  46. server_config.mutable_security_params()->CopyFrom(security);
  47. const auto result =
  48. RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2, "",
  49. kInsecureCredentialsType, {}, false, 0);
  50. GetReporter()->ReportQPS(*result);
  51. GetReporter()->ReportLatency(*result);
  52. }
  53. } // namespace testing
  54. } // namespace grpc
  55. int main(int argc, char** argv) {
  56. grpc::testing::TestEnvironment env(argc, argv);
  57. grpc::testing::InitTest(&argc, &argv, true);
  58. grpc::testing::RunSynchronousUnaryPingPong();
  59. return 0;
  60. }