blob: a1e73e9abe921a8ce197e866b6643c77342fa510 [file] [log] [blame]
Craig Tiller26598a32015-03-02 16:16:00 -08001/*
2 *
vjpai2c42bb12016-01-19 13:02:42 -08003 * Copyright 2015-2016, Google Inc.
Craig Tiller26598a32015-03-02 16:16:00 -08004 * 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
Craig Tiller26598a32015-03-02 16:16:00 -080034#include <sys/signal.h>
35
Craig Tillere9a6eb72015-04-09 15:51:41 -070036#include <chrono>
37#include <thread>
38
yang-g9e2f90c2015-08-21 15:35:03 -070039#include <gflags/gflags.h>
Craig Tiller26598a32015-03-02 16:16:00 -080040#include <grpc/grpc.h>
David Garcia Quintasfeb67f62015-05-20 19:23:25 -070041#include <grpc/support/time.h>
Craig Tillere9a6eb72015-04-09 15:51:41 -070042
Craig Tillerf75fc122015-06-25 06:58:00 -070043#include "test/cpp/qps/qps_worker.h"
Yang Gao103837e2015-04-15 15:23:54 -070044#include "test/cpp/util/test_config.h"
Craig Tiller26598a32015-03-02 16:16:00 -080045
vjpai72a63322015-10-29 02:23:11 -070046DEFINE_int32(driver_port, 0, "Port for communication with driver");
Vijay Paid3ea2702016-01-19 10:59:42 -080047DEFINE_int32(server_port, 0, "Port for operation as a server");
Craig Tiller26598a32015-03-02 16:16:00 -080048
Craig Tiller26598a32015-03-02 16:16:00 -080049static bool got_sigint = false;
50
Craig Tiller5c8737d2015-05-21 11:42:17 -070051static void sigint_handler(int x) { got_sigint = true; }
Vijay Paif2554d02015-04-02 13:58:27 -070052
Craig Tiller26598a32015-03-02 16:16:00 -080053namespace grpc {
54namespace testing {
55
Craig Tiller26598a32015-03-02 16:16:00 -080056static void RunServer() {
Vijay Paid3ea2702016-01-19 10:59:42 -080057 QpsWorker worker(FLAGS_driver_port, FLAGS_server_port);
Craig Tiller26598a32015-03-02 16:16:00 -080058
59 while (!got_sigint) {
Craig Tiller677c50c2015-07-13 10:49:06 -070060 gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
61 gpr_time_from_seconds(5, GPR_TIMESPAN)));
Craig Tiller26598a32015-03-02 16:16:00 -080062 }
63}
64
Craig Tiller10923c22015-03-03 14:24:49 -080065} // namespace testing
66} // namespace grpc
Craig Tiller26598a32015-03-02 16:16:00 -080067
Craig Tiller10923c22015-03-03 14:24:49 -080068int main(int argc, char** argv) {
Yang Gao103837e2015-04-15 15:23:54 -070069 grpc::testing::InitTest(&argc, &argv, true);
Craig Tiller26598a32015-03-02 16:16:00 -080070
Vijay Paif2554d02015-04-02 13:58:27 -070071 signal(SIGINT, sigint_handler);
72
Craig Tiller26598a32015-03-02 16:16:00 -080073 grpc::testing::RunServer();
Craig Tiller5c8737d2015-05-21 11:42:17 -070074
Craig Tiller26598a32015-03-02 16:16:00 -080075 return 0;
76}