Craig Tiller | e486019 | 2015-02-23 17:10:41 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright 2015, Google Inc. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are |
| 8 | * met: |
| 9 | * |
| 10 | * * Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * * Redistributions in binary form must reproduce the above |
| 13 | * copyright notice, this list of conditions and the following disclaimer |
| 14 | * in the documentation and/or other materials provided with the |
| 15 | * distribution. |
| 16 | * * Neither the name of Google Inc. nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived from |
| 18 | * this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | * |
| 32 | */ |
| 33 | |
| 34 | #include <gflags/gflags.h> |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 35 | #include <grpc/support/log.h> |
Craig Tiller | e486019 | 2015-02-23 17:10:41 -0800 | [diff] [blame] | 36 | |
| 37 | #include "test/cpp/qps/driver.h" |
| 38 | |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 39 | DEFINE_int32(num_clients, 1, "Number of client binaries"); |
| 40 | DEFINE_int32(num_servers, 1, "Number of server binaries"); |
Craig Tiller | e486019 | 2015-02-23 17:10:41 -0800 | [diff] [blame] | 41 | |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 42 | // Common config |
| 43 | DEFINE_bool(enable_ssl, false, "Use SSL"); |
| 44 | |
| 45 | // Server config |
| 46 | DEFINE_int32(server_threads, 1, "Number of server threads"); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 47 | DEFINE_string(server_type, "SYNCHRONOUS_SERVER", "Server type"); |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 48 | |
| 49 | // Client config |
Craig Tiller | 10923c2 | 2015-03-03 14:24:49 -0800 | [diff] [blame^] | 50 | DEFINE_int32(outstanding_rpcs_per_channel, 1, |
| 51 | "Number of outstanding rpcs per channel"); |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 52 | DEFINE_int32(client_channels, 1, "Number of client channels"); |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 53 | DEFINE_int32(payload_size, 1, "Payload size"); |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 54 | DEFINE_string(client_type, "SYNCHRONOUS_CLIENT", "Client type"); |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 55 | |
| 56 | using grpc::testing::ClientConfig; |
| 57 | using grpc::testing::ServerConfig; |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 58 | using grpc::testing::ClientType; |
| 59 | using grpc::testing::ServerType; |
Craig Tiller | e486019 | 2015-02-23 17:10:41 -0800 | [diff] [blame] | 60 | |
| 61 | // In some distros, gflags is in the namespace google, and in some others, |
| 62 | // in gflags. This hack is enabling us to find both. |
Craig Tiller | 10923c2 | 2015-03-03 14:24:49 -0800 | [diff] [blame^] | 63 | namespace google {} |
| 64 | namespace gflags {} |
Craig Tiller | e486019 | 2015-02-23 17:10:41 -0800 | [diff] [blame] | 65 | using namespace google; |
| 66 | using namespace gflags; |
| 67 | |
| 68 | int main(int argc, char **argv) { |
| 69 | grpc_init(); |
| 70 | ParseCommandLineFlags(&argc, &argv, true); |
| 71 | |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 72 | ClientType client_type; |
| 73 | ServerType server_type; |
| 74 | GPR_ASSERT(ClientType_Parse(FLAGS_client_type, &client_type)); |
| 75 | GPR_ASSERT(ServerType_Parse(FLAGS_server_type, &server_type)); |
| 76 | |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 77 | ClientConfig client_config; |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 78 | client_config.set_client_type(client_type); |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 79 | client_config.set_enable_ssl(FLAGS_enable_ssl); |
Craig Tiller | 10923c2 | 2015-03-03 14:24:49 -0800 | [diff] [blame^] | 80 | client_config.set_outstanding_rpcs_per_channel( |
| 81 | FLAGS_outstanding_rpcs_per_channel); |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 82 | client_config.set_client_channels(FLAGS_client_channels); |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 83 | client_config.set_payload_size(FLAGS_payload_size); |
Craig Tiller | e486019 | 2015-02-23 17:10:41 -0800 | [diff] [blame] | 84 | |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 85 | ServerConfig server_config; |
Craig Tiller | 6af9ed0 | 2015-03-02 22:42:10 -0800 | [diff] [blame] | 86 | server_config.set_server_type(server_type); |
Craig Tiller | 2d0f36c | 2015-02-23 23:16:17 -0800 | [diff] [blame] | 87 | server_config.set_threads(FLAGS_server_threads); |
| 88 | server_config.set_enable_ssl(FLAGS_enable_ssl); |
| 89 | |
Craig Tiller | 10923c2 | 2015-03-03 14:24:49 -0800 | [diff] [blame^] | 90 | RunScenario(client_config, FLAGS_num_clients, server_config, |
| 91 | FLAGS_num_servers); |
Craig Tiller | e486019 | 2015-02-23 17:10:41 -0800 | [diff] [blame] | 92 | |
| 93 | grpc_shutdown(); |
| 94 | return 0; |
| 95 | } |