PHP: enable fault_injection xds interop test case (#25943)

* PHP: enable fault_injection xds interop test case

* sanity check yaph_code.sh

* some mysterious SIGTERM is being observed

* Remove adhoc test cfg
pull/25956/head
Stanley Cheung 4 years ago committed by GitHub
parent d017ce5f25
commit e8a904368b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/php/bin/xds_manager.py
  2. 5
      src/php/ext/grpc/call.c
  3. 13
      src/php/tests/interop/xds_client.php
  4. 6
      src/php/tests/interop/xds_empty_call.php
  5. 6
      src/php/tests/interop/xds_unary_call.php
  6. 4
      tools/internal_ci/linux/grpc_xds_php_test_in_docker.sh

@ -54,7 +54,7 @@ if __name__ == '__main__':
# src/php/tests/interop/xds_client.php
items = key.split('|')
num = items[0]
rpc_behavior = items[2]
metadata = items[2]
timeout_sec = items[3]
if items[1] == 'UnaryCall':
p = subprocess.Popen([
@ -62,8 +62,7 @@ if __name__ == '__main__':
'extension=pthreads.so',
'src/php/tests/interop/xds_unary_call.php',
'--server=' + server_address, '--num=' + str(num),
'--rpc_behavior=' + rpc_behavior,
'--timeout_sec=' + timeout_sec
'--metadata=' + metadata, '--timeout_sec=' + timeout_sec
],
env=client_env)
elif items[1] == 'EmptyCall':
@ -72,8 +71,7 @@ if __name__ == '__main__':
'extension=pthreads.so',
'src/php/tests/interop/xds_empty_call.php',
'--server=' + server_address, '--num=' + str(num),
'--rpc_behavior=' + rpc_behavior,
'--timeout=' + timeout_sec
'--metadata=' + metadata, '--timeout=' + timeout_sec
],
env=client_env)
else:

@ -314,6 +314,11 @@ PHP_METHOD(Call, startBatch) {
goto cleanup;
}
// c-core may call rand(). If we don't call srand() here, all the
// random numbers being returned would be the same.
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
srand(now.tv_nsec);
array_hash = Z_ARRVAL_P(array);
char *key = NULL;

@ -334,14 +334,14 @@ class ClientThread extends Thread {
}
}
public function execute_rpc_in_child_process($rpc, $rpc_behavior) {
public function execute_rpc_in_child_process($rpc, $metadata_serialized) {
// tmp_file1 contains the list of RPCs (and their
// specs) we want executed. This will be picked up
// by src/php/bin/xds_manager.py
$f1 = fopen($this->rpc_config->tmp_file1, 'a');
$key = implode('|', [$this->num_results,
$rpc,
$rpc_behavior,
$metadata_serialized,
$this->rpc_config->timeout_sec]);
flock($f1, LOCK_EX);
fwrite($f1, $key."\n");
@ -386,17 +386,14 @@ class ClientThread extends Thread {
// $this->metadata_to_send[$rpc] somehow becomes a
// Volatile object, instead of an associative array.
$metadata_array = [];
$rpc_behavior = false;
foreach ($metadata as $key => $value) {
$metadata_array[$key] = [$value];
if ($key == 'rpc-behavior') {
$rpc_behavior = $value;
}
}
if ($rpc_behavior && $this->rpc_config->tmp_file1) {
if ($metadata_array && $this->rpc_config->tmp_file1) {
// if 'rpc-behavior' is set, we need to pawn off
// the execution to some other child PHP processes
$this->execute_rpc_in_child_process($rpc, $rpc_behavior);
$this->execute_rpc_in_child_process(
$rpc, serialize($metadata_array));
continue;
}
// Execute RPC within this script

@ -29,7 +29,7 @@ require_once $autoload_path;
// from there.
$args = getopt('', ['server:', 'num:',
'rpc_behavior:', 'timeout_sec:']);
'metadata:', 'timeout_sec:']);
$TIMEOUT_US = 30 * 1e6; // 30 seconds
$server_address = $args['server'];
@ -43,8 +43,8 @@ $empty_request = new Grpc\Testing\EmptyMessage();
$timeout = $args['timeout_sec'] ? $args['timeout_sec'] * 1e6 : $TIMEOUT_US;
$metadata = [];
if ($args['rpc_behavior']) {
$metadata['rpc_behavior'] = [$args['rpc_behavior']];
if ($args['metadata']) {
$metadata = unserialize($args['metadata']);
}
$call = $stub->EmptyCall($empty_request,

@ -29,7 +29,7 @@ require_once $autoload_path;
// from there.
$args = getopt('', ['server:', 'num:',
'rpc_behavior:', 'timeout_sec:']);
'metadata:', 'timeout_sec:']);
$TIMEOUT_US = 30 * 1e6; // 30 seconds
$server_address = $args['server'];
@ -43,8 +43,8 @@ $simple_request = new Grpc\Testing\SimpleRequest();
$timeout = $args['timeout_sec'] ? $args['timeout_sec'] * 1e6 : $TIMEOUT_US;
$metadata = [];
if ($args['rpc_behavior']) {
$metadata['rpc-behavior'] = [$args['rpc_behavior']];
if ($args['metadata']) {
$metadata = unserialize($args['metadata']);
}
$call = $stub->UnaryCall($simple_request,

@ -72,7 +72,7 @@ export CC=/usr/bin/gcc
GRPC_VERBOSITY=debug GRPC_TRACE=xds_client,xds_resolver,xds_cluster_manager_lb,cds_lb,xds_cluster_resolver_lb,priority_lb,xds_cluster_impl_lb,weighted_target_lb "$PYTHON" \
tools/run_tests/run_xds_tests.py \
--test_case="timeout" \
--test_case="timeout,fault_injection" \
--project_id=grpc-testing \
--project_num=830293263384 \
--source_image=projects/grpc-testing/global/images/xds-test-server-4 \
@ -93,4 +93,4 @@ GRPC_VERBOSITY=debug GRPC_TRACE=xds_client,xds_resolver,xds_cluster_manager_lb,c
--gcp_suffix=$(date '+%s') \
--verbose \
${XDS_V3_OPT-} \
--client_cmd='./src/php/bin/run_xds_client.sh --server=xds:///{server_uri} --stats_port={stats_port} --qps={qps} {fail_on_failed_rpc} {rpcs_to_send} {metadata_to_send}'
--client_cmd='php -d extension=grpc.so -d extension=pthreads.so src/php/tests/interop/xds_client.php --server=xds:///{server_uri} --stats_port={stats_port} --qps={qps} {fail_on_failed_rpc} {rpcs_to_send} {metadata_to_send}'

Loading…
Cancel
Save