pull/2289/head
Craig Tiller 10 years ago
parent f3756c1e0d
commit 20b5fe9282
  1. 9
      test/cpp/end2end/end2end_test.cc
  2. 12
      test/cpp/end2end/server_crash_test.cc
  3. 4
      test/cpp/end2end/thread_stress_test.cc
  4. 2
      test/cpp/qps/driver.cc
  5. 2
      test/cpp/qps/timer.cc
  6. 3
      test/cpp/qps/worker.cc

@ -100,15 +100,15 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service {
} }
while (!context->IsCancelled()) { while (!context->IsCancelled()) {
gpr_sleep_until(gpr_time_add( gpr_sleep_until(gpr_time_add(
gpr_now(), gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(request->param().client_cancel_after_us()))); gpr_time_from_micros(request->param().client_cancel_after_us())));
} }
return Status::CANCELLED; return Status::CANCELLED;
} else if (request->has_param() && } else if (request->has_param() &&
request->param().server_cancel_after_us()) { request->param().server_cancel_after_us()) {
gpr_sleep_until(gpr_time_add( gpr_sleep_until(gpr_time_add(
gpr_now(), gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(request->param().server_cancel_after_us()))); gpr_time_from_micros(request->param().server_cancel_after_us())));
return Status::CANCELLED; return Status::CANCELLED;
} else { } else {
EXPECT_FALSE(context->IsCancelled()); EXPECT_FALSE(context->IsCancelled());
@ -490,7 +490,8 @@ TEST_F(End2endTest, BadCredentials) {
} }
void CancelRpc(ClientContext* context, int delay_us, TestServiceImpl* service) { void CancelRpc(ClientContext* context, int delay_us, TestServiceImpl* service) {
gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_micros(delay_us))); gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(delay_us)));
while (!service->signal_client()) { while (!service->signal_client()) {
} }
context->TryCancel(); context->TryCancel();

@ -84,7 +84,8 @@ class ServiceImpl GRPC_FINAL
gpr_log(GPR_INFO, "recv msg %s", request.message().c_str()); gpr_log(GPR_INFO, "recv msg %s", request.message().c_str());
response.set_message(request.message()); response.set_message(request.message());
stream->Write(response); stream->Write(response);
gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_seconds(1))); gpr_sleep_until(
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(1)));
} }
return Status::OK; return Status::OK;
} }
@ -98,7 +99,8 @@ class ServiceImpl GRPC_FINAL
msg << "Hello " << i; msg << "Hello " << i;
response.set_message(msg.str()); response.set_message(msg.str());
if (!writer->Write(response)) break; if (!writer->Write(response)) break;
gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_seconds(1))); gpr_sleep_until(
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(1)));
} }
return Status::OK; return Status::OK;
} }
@ -145,7 +147,8 @@ class CrashTest : public ::testing::Test {
TEST_F(CrashTest, ResponseStream) { TEST_F(CrashTest, ResponseStream) {
auto server = CreateServerAndClient("response"); auto server = CreateServerAndClient("response");
gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_seconds(5))); gpr_sleep_until(
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(5)));
KillClient(); KillClient();
server->Shutdown(); server->Shutdown();
GPR_ASSERT(HadOneResponseStream()); GPR_ASSERT(HadOneResponseStream());
@ -154,7 +157,8 @@ TEST_F(CrashTest, ResponseStream) {
TEST_F(CrashTest, BidiStream) { TEST_F(CrashTest, BidiStream) {
auto server = CreateServerAndClient("bidi"); auto server = CreateServerAndClient("bidi");
gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_seconds(5))); gpr_sleep_until(
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(5)));
KillClient(); KillClient();
server->Shutdown(); server->Shutdown();
GPR_ASSERT(HadOneBidiStream()); GPR_ASSERT(HadOneBidiStream());

@ -96,14 +96,14 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service {
} }
while (!context->IsCancelled()) { while (!context->IsCancelled()) {
gpr_sleep_until(gpr_time_add( gpr_sleep_until(gpr_time_add(
gpr_now(), gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(request->param().client_cancel_after_us()))); gpr_time_from_micros(request->param().client_cancel_after_us())));
} }
return Status::CANCELLED; return Status::CANCELLED;
} else if (request->has_param() && } else if (request->has_param() &&
request->param().server_cancel_after_us()) { request->param().server_cancel_after_us()) {
gpr_sleep_until(gpr_time_add( gpr_sleep_until(gpr_time_add(
gpr_now(), gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(request->param().server_cancel_after_us()))); gpr_time_from_micros(request->param().server_cancel_after_us())));
return Status::CANCELLED; return Status::CANCELLED;
} else { } else {

@ -185,7 +185,7 @@ std::unique_ptr<ScenarioResult> RunScenario(
// Let everything warmup // Let everything warmup
gpr_log(GPR_INFO, "Warming up"); gpr_log(GPR_INFO, "Warming up");
gpr_timespec start = gpr_now(); gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME);
gpr_sleep_until(gpr_time_add(start, gpr_time_from_seconds(warmup_seconds))); gpr_sleep_until(gpr_time_add(start, gpr_time_from_seconds(warmup_seconds)));
// Start a run // Start a run

@ -41,7 +41,7 @@
Timer::Timer() : start_(Sample()) {} Timer::Timer() : start_(Sample()) {}
double Timer::Now() { double Timer::Now() {
auto ts = gpr_now(); auto ts = gpr_now(GPR_CLOCK_REALTIME);
return ts.tv_sec + 1e-9 * ts.tv_nsec; return ts.tv_sec + 1e-9 * ts.tv_nsec;
} }

@ -57,7 +57,8 @@ static void RunServer() {
QpsWorker worker(FLAGS_driver_port, FLAGS_server_port); QpsWorker worker(FLAGS_driver_port, FLAGS_server_port);
while (!got_sigint) { while (!got_sigint) {
gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_seconds(5))); gpr_sleep_until(
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(5)));
} }
} }

Loading…
Cancel
Save