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 <signal.h>
20
21 #include <chrono>
22 #include <thread>
23 #include <vector>
24
25 #include <gflags/gflags.h>
26 #include <grpc/grpc.h>
27 #include <grpc/support/time.h>
28
29 #include "test/cpp/qps/qps_worker.h"
30 #include "test/cpp/util/test_config.h"
31 #include "test/cpp/util/test_credentials_provider.h"
32
33 DEFINE_int32(driver_port, 0, "Port for communication with driver");
34 DEFINE_int32(server_port, 0, "Port for operation as a server");
35 DEFINE_string(credential_type, grpc::testing::kInsecureCredentialsType,
36 "Credential type for communication with driver");
37
38 static bool got_sigint = false;
39
sigint_handler(int)40 static void sigint_handler(int /*x*/) { got_sigint = true; }
41
42 namespace grpc {
43 namespace testing {
44
45 std::vector<grpc::testing::Server*>* g_inproc_servers = nullptr;
46
RunServer()47 static void RunServer() {
48 QpsWorker worker(FLAGS_driver_port, FLAGS_server_port, FLAGS_credential_type);
49
50 while (!got_sigint && !worker.Done()) {
51 gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
52 gpr_time_from_seconds(5, GPR_TIMESPAN)));
53 }
54 }
55
56 } // namespace testing
57 } // namespace grpc
58
main(int argc,char ** argv)59 int main(int argc, char** argv) {
60 grpc::testing::InitTest(&argc, &argv, true);
61
62 signal(SIGINT, sigint_handler);
63
64 grpc::testing::RunServer();
65
66 return 0;
67 }
68