| 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 "absl/flags/flag.h" |
| 26 |
|
| 27 |
#include <grpc/grpc.h> |
| 28 |
#include <grpc/support/time.h> |
| 29 |
|
| 30 |
#include "test/core/util/test_config.h" |
| 31 |
#include "test/cpp/qps/qps_worker.h" |
| 32 |
#include "test/cpp/util/test_config.h" |
| 33 |
#include "test/cpp/util/test_credentials_provider.h" |
| 34 |
|
| 35 |
ABSL_FLAG(int32_t, driver_port, 0, "Port for communication with driver"); |
| 36 |
ABSL_FLAG(int32_t, server_port, 0, |
| 37 |
"Port for operation as a server, if not specified by the server " |
| 38 |
"config message"); |
| 39 |
ABSL_FLAG(std::string, credential_type, grpc::testing::kInsecureCredentialsType, |
| 40 |
"Credential type for communication with driver"); |
| 41 |
|
| 42 |
static bool got_sigint = false; |
| 43 |
|
| 44 |
static void sigint_handler(int /*x*/) { got_sigint = true; } |
| 45 |
|
| 46 |
namespace grpc { |
| 47 |
namespace testing { |
| 48 |
|
| 49 |
std::vector<grpc::testing::Server*>* g_inproc_servers = nullptr; |
| 50 |
|
| 51 |
static void RunServer() { |
| 52 |
QpsWorker worker(absl::GetFlag(FLAGS_driver_port), |
| 53 |
absl::GetFlag(FLAGS_server_port), |
| 54 |
absl::GetFlag(FLAGS_credential_type)); |
| 55 |
|
| 56 |
while (!got_sigint && !worker.Done()) { |
| 57 |
gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), |
| 58 |
gpr_time_from_millis(500, GPR_TIMESPAN))); |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
} // namespace testing |
| 63 |
} // namespace grpc |
| 64 |
|
| 65 |
int main(int argc, char** argv) { |
| 66 |
grpc::testing::TestEnvironment env(&argc, argv); |
| 67 |
grpc::testing::InitTest(&argc, &argv, true); |
| 68 |
|
| 69 |
signal(SIGINT, sigint_handler); |
| 70 |
|
| 71 |
grpc::testing::RunServer(); |
| 72 |
|
| 73 |
return 0; |
| 74 |
} |