Home | History | Annotate | Download | only in qps
      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 
     19 #include <set>
     20 
     21 #include <grpc/support/log.h>
     22 
     23 #include "test/cpp/qps/benchmark_config.h"
     24 #include "test/cpp/qps/driver.h"
     25 #include "test/cpp/qps/report.h"
     26 #include "test/cpp/qps/server.h"
     27 #include "test/cpp/util/test_config.h"
     28 #include "test/cpp/util/test_credentials_provider.h"
     29 
     30 namespace grpc {
     31 namespace testing {
     32 
     33 static const int WARMUP = 5;
     34 static const int BENCHMARK = 5;
     35 
     36 static void RunSynchronousUnaryPingPong() {
     37   gpr_log(GPR_INFO, "Running Synchronous Unary Ping Pong");
     38 
     39   ClientConfig client_config;
     40   client_config.set_client_type(SYNC_CLIENT);
     41   client_config.set_outstanding_rpcs_per_channel(1);
     42   client_config.set_client_channels(1);
     43   client_config.set_rpc_type(UNARY);
     44   client_config.mutable_load_params()->mutable_closed_loop();
     45 
     46   ServerConfig server_config;
     47   server_config.set_server_type(SYNC_SERVER);
     48 
     49   // Set up security params
     50   SecurityParams security;
     51   security.set_use_test_ca(true);
     52   security.set_server_host_override("foo.test.google.fr");
     53   client_config.mutable_security_params()->CopyFrom(security);
     54   server_config.mutable_security_params()->CopyFrom(security);
     55 
     56   const auto result =
     57       RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2, "",
     58                   kInsecureCredentialsType, false, 0);
     59 
     60   GetReporter()->ReportQPS(*result);
     61   GetReporter()->ReportLatency(*result);
     62 }
     63 
     64 }  // namespace testing
     65 }  // namespace grpc
     66 
     67 int main(int argc, char** argv) {
     68   grpc::testing::InitTest(&argc, &argv, true);
     69 
     70   grpc::testing::RunSynchronousUnaryPingPong();
     71 
     72   return 0;
     73 }
     74