aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--test/cpp/end2end/end2end_test.cc12
-rw-r--r--test/cpp/end2end/thread_stress_test.cc10
-rw-r--r--test/cpp/qps/worker.cc3
3 files changed, 15 insertions, 10 deletions
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index 76271c3e1d..7a15591b44 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -96,14 +96,16 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service {
signal_client_ = true;
}
while (!context->IsCancelled()) {
- std::this_thread::sleep_for(std::chrono::microseconds(
- request->param().client_cancel_after_us()));
+ gpr_sleep_until(gpr_time_add(
+ gpr_now(),
+ gpr_time_from_micros(request->param().client_cancel_after_us())));
}
return Status::Cancelled;
} else if (request->has_param() &&
request->param().server_cancel_after_us()) {
- std::this_thread::sleep_for(
- std::chrono::microseconds(request->param().server_cancel_after_us()));
+ gpr_sleep_until(gpr_time_add(
+ gpr_now(),
+ gpr_time_from_micros(request->param().server_cancel_after_us())));
return Status::Cancelled;
} else {
EXPECT_FALSE(context->IsCancelled());
@@ -469,7 +471,7 @@ TEST_F(End2endTest, BadCredentials) {
}
void CancelRpc(ClientContext* context, int delay_us, TestServiceImpl* service) {
- std::this_thread::sleep_for(std::chrono::microseconds(delay_us));
+ gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_micros(delay_us)));
while (!service->signal_client()) {
}
context->TryCancel();
diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc
index 12656128c0..310227a29c 100644
--- a/test/cpp/end2end/thread_stress_test.cc
+++ b/test/cpp/end2end/thread_stress_test.cc
@@ -94,14 +94,16 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service {
signal_client_ = true;
}
while (!context->IsCancelled()) {
- std::this_thread::sleep_for(std::chrono::microseconds(
- request->param().client_cancel_after_us()));
+ gpr_sleep_until(gpr_time_add(
+ gpr_now(),
+ gpr_time_from_micros(request->param().client_cancel_after_us())));
}
return Status::Cancelled;
} else if (request->has_param() &&
request->param().server_cancel_after_us()) {
- std::this_thread::sleep_for(
- std::chrono::microseconds(request->param().server_cancel_after_us()));
+ gpr_sleep_until(gpr_time_add(
+ gpr_now(),
+ gpr_time_from_micros(request->param().server_cancel_after_us())));
return Status::Cancelled;
} else {
EXPECT_FALSE(context->IsCancelled());
diff --git a/test/cpp/qps/worker.cc b/test/cpp/qps/worker.cc
index 281c617382..8c82bce8f2 100644
--- a/test/cpp/qps/worker.cc
+++ b/test/cpp/qps/worker.cc
@@ -37,6 +37,7 @@
#include <thread>
#include <grpc/grpc.h>
+#include <grpc/support/time.h>
#include <gflags/gflags.h>
#include "qps_worker.h"
@@ -56,7 +57,7 @@ static void RunServer() {
QpsWorker worker(FLAGS_driver_port, FLAGS_server_port);
while (!got_sigint) {
- std::this_thread::sleep_for(std::chrono::seconds(5));
+ gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_seconds(5)));
}
}