end2end tests: fix test service impl to apply test slowdown factor (#30750)

* end2end tests: fix test service impl to apply test slowdown factor

* fix build
pull/30594/head
Mark D. Roth 2 years ago committed by GitHub
parent 807e93f250
commit 143c852d2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      test/cpp/end2end/BUILD
  2. 6
      test/cpp/end2end/test_service_impl.cc
  3. 14
      test/cpp/end2end/test_service_impl.h

@ -32,6 +32,7 @@ grpc_cc_library(
], ],
deps = [ deps = [
"//src/proto/grpc/testing:echo_proto", "//src/proto/grpc/testing:echo_proto",
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util", "//test/cpp/util:test_util",
], ],
) )

@ -163,7 +163,8 @@ ServerUnaryReactor* CallbackTestServiceImpl::Echo(
// Set an alarm for that much time // Set an alarm for that much time
alarm_.Set( alarm_.Set(
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_micros(req_->param().server_sleep_us(), gpr_time_from_micros(req_->param().server_sleep_us() *
grpc_test_slowdown_factor(),
GPR_TIMESPAN)), GPR_TIMESPAN)),
[this](bool ok) { NonDelayed(ok); }); [this](bool ok) { NonDelayed(ok); });
return; return;
@ -250,7 +251,8 @@ ServerUnaryReactor* CallbackTestServiceImpl::Echo(
} else if (req_->has_param() && req_->param().server_cancel_after_us()) { } else if (req_->has_param() && req_->param().server_cancel_after_us()) {
alarm_.Set(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), alarm_.Set(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros( gpr_time_from_micros(
req_->param().server_cancel_after_us(), req_->param().server_cancel_after_us() *
grpc_test_slowdown_factor(),
GPR_TIMESPAN)), GPR_TIMESPAN)),
[this](bool) { Finish(Status::CANCELLED); }); [this](bool) { Finish(Status::CANCELLED); });
return; return;

@ -34,6 +34,7 @@
#include <grpcpp/server_context.h> #include <grpcpp/server_context.h>
#include "src/proto/grpc/testing/echo.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/test_config.h"
#include "test/cpp/util/string_ref_helper.h" #include "test/cpp/util/string_ref_helper.h"
namespace grpc { namespace grpc {
@ -131,9 +132,10 @@ class TestMultipleServiceImpl : public RpcService {
// A bit of sleep to make sure that short deadline tests fail // A bit of sleep to make sure that short deadline tests fail
if (request->has_param() && request->param().server_sleep_us() > 0) { if (request->has_param() && request->param().server_sleep_us() > 0) {
gpr_sleep_until( gpr_sleep_until(gpr_time_add(
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_micros(request->param().server_sleep_us(), gpr_time_from_micros(
request->param().server_sleep_us() * grpc_test_slowdown_factor(),
GPR_TIMESPAN))); GPR_TIMESPAN)));
} }
@ -176,7 +178,8 @@ class TestMultipleServiceImpl : public RpcService {
while (!context->IsCancelled()) { while (!context->IsCancelled()) {
gpr_sleep_until(gpr_time_add( gpr_sleep_until(gpr_time_add(
gpr_now(GPR_CLOCK_REALTIME), 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() *
grpc_test_slowdown_factor(),
GPR_TIMESPAN))); GPR_TIMESPAN)));
} }
{ {
@ -188,7 +191,8 @@ class TestMultipleServiceImpl : public RpcService {
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_CLOCK_REALTIME), 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() *
grpc_test_slowdown_factor(),
GPR_TIMESPAN))); GPR_TIMESPAN)));
return Status::CANCELLED; return Status::CANCELLED;
} else if (!request->has_param() || } else if (!request->has_param() ||

Loading…
Cancel
Save