Add debug info to xds test

pull/23139/head
Stanley Cheung 5 years ago
parent 9163bb39b1
commit bd061ecf47
  1. 15
      src/php/tests/interop/xds_client.php
  2. 10
      src/ruby/pb/test/xds_client.rb

@ -103,18 +103,23 @@ class ClientThread extends Thread {
'credentials' => Grpc\ChannelCredentials::createInsecure() 'credentials' => Grpc\ChannelCredentials::createInsecure()
]); ]);
$request = new Grpc\Testing\SimpleRequest(); $request = new Grpc\Testing\SimpleRequest();
$target_next_start_us = hrtime(true) / 1000; $target_next_start_us = hrtime(true) / 1000; # hrtime returns nanoseconds
while (true) { while (true) {
$now_us = hrtime(true) / 1000; $now_us = hrtime(true) / 1000;
$sleep_us = $target_next_start_us - $now_us; $sleep_us = $target_next_start_us - $now_us;
if ($sleep_us < 0) { if ($sleep_us < 0) {
echo "php xds: warning, rpc takes too long to finish. " $target_next_start_us =
. "If you consistently see this, the qps is too high.\n"; $now_us + ($this->target_seconds_between_rpcs_ * 1e6);
echo sprintf(
"php xds: warning, rpc takes too long to finish. "
. "Deficit %fms."
. "If you consistently see this, the qps is too high.\n",
round(abs($sleep_us / 1000), 1));
} else { } else {
$target_next_start_us +=
($this->target_seconds_between_rpcs_ * 1e6);
usleep($sleep_us); usleep($sleep_us);
} }
$target_next_start_us
+= ($this->target_seconds_between_rpcs_ * 1000000);
list($response, $status) list($response, $status)
= $stub->UnaryCall($request)->wait(); = $stub->UnaryCall($request)->wait();
if ($status->code == Grpc\STATUS_OK) { if ($status->code == Grpc\STATUS_OK) {

@ -111,12 +111,16 @@ def run_test_loop(stub, target_seconds_between_rpcs, fail_on_failed_rpcs)
now = Process.clock_gettime(Process::CLOCK_MONOTONIC) now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
sleep_seconds = target_next_start - now sleep_seconds = target_next_start - now
if sleep_seconds < 0 if sleep_seconds < 0
GRPC.logger.info("ruby xds: warning, rpc takes too long to finish. " \ target_next_start = now + target_seconds_between_rpcs
"If you consistently see this, the qps is too high.") GRPC.logger.info(
"ruby xds: warning, rpc takes too long to finish. " \
"Deficit = %fms. " \
"If you consistently see this, the qps is too high."
% [(sleep_seconds * 1000).abs().round(1)])
else else
target_next_start += target_seconds_between_rpcs
sleep(sleep_seconds) sleep(sleep_seconds)
end end
target_next_start += target_seconds_between_rpcs
begin begin
resp = stub.unary_call(req) resp = stub.unary_call(req)
remote_peer = resp.hostname remote_peer = resp.hostname

Loading…
Cancel
Save