aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php/tests
diff options
context:
space:
mode:
authorGravatar Stanley Cheung <stanleycheung@google.com>2016-06-17 11:20:19 -0700
committerGravatar Stanley Cheung <stanleycheung@google.com>2016-06-17 11:52:51 -0700
commit89391406cddd8f0ff89992835d89baa716465447 (patch)
tree85074704c414381e201fd6fe639b5249094f3cb2 /src/php/tests
parente2e08735e5226195ed3706bc10a9d297dd88bdf0 (diff)
php: implement 2 more interop tests
Diffstat (limited to 'src/php/tests')
-rwxr-xr-xsrc/php/tests/interop/interop_client.php45
-rw-r--r--src/php/tests/interop/messages.proto38
-rw-r--r--src/php/tests/interop/test.proto3
3 files changed, 82 insertions, 4 deletions
diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php
index e3c234e869..92a27d17aa 100755
--- a/src/php/tests/interop/interop_client.php
+++ b/src/php/tests/interop/interop_client.php
@@ -446,6 +446,45 @@ function customMetadata($stub)
$ECHO_TRAILING_VALUE, 'Incorrect trailing metadata value');
}
+function statusCodeAndMessage($stub)
+{
+ $echo_status = new grpc\testing\EchoStatus();
+ $echo_status->setCode(2);
+ $echo_status->setMessage("test status message");
+
+ $request = new grpc\testing\SimpleRequest();
+ $request->setResponseStatus($echo_status);
+
+ $call = $stub->UnaryCall($request);
+ list($result, $status) = $call->wait();
+
+ hardAssert($status->code === 2,
+ 'Received unexpected status code');
+ hardAssert($status->details === "test status message",
+ 'Received unexpected status details');
+
+ $streaming_call = $stub->FullDuplexCall();
+
+ $streaming_request = new grpc\testing\StreamingOutputCallRequest();
+ $streaming_request->setResponseStatus($echo_status);
+ $streaming_call->write($streaming_request);
+ $streaming_call->writesDone();
+
+ $status = $streaming_call->getStatus();
+ hardAssert($status->code === 2,
+ 'Received unexpected status code');
+ hardAssert($status->details === "test status message",
+ 'Received unexpected status details');
+}
+
+function unimplementedMethod($stub)
+{
+ $call = $stub->UnimplementedCall(new grpc\testing\EmptyMessage());
+ list($result, $status) = $call->wait();
+ hardAssert($status->code === Grpc\STATUS_UNIMPLEMENTED,
+ 'Received unexpected status code');
+}
+
function _makeStub($args)
{
if (!array_key_exists('server_host', $args)) {
@@ -575,6 +614,12 @@ function interop_main($args, $stub = false)
case 'custom_metadata':
customMetadata($stub);
break;
+ case 'status_code_and_message':
+ statusCodeAndMessage($stub);
+ break;
+ case 'unimplemented_method':
+ unimplementedMethod($stub);
+ break;
case 'service_account_creds':
serviceAccountCreds($stub, $args);
break;
diff --git a/src/php/tests/interop/messages.proto b/src/php/tests/interop/messages.proto
index de0b1a2320..44e3c3b8f9 100644
--- a/src/php/tests/interop/messages.proto
+++ b/src/php/tests/interop/messages.proto
@@ -1,5 +1,5 @@
-// Copyright 2015, Google Inc.
+// Copyright 2015-2016, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -41,9 +41,6 @@ enum PayloadType {
// Uncompressable binary format.
UNCOMPRESSABLE = 1;
-
- // Randomly chosen from all other formats defined in this enum.
- RANDOM = 2;
}
// A block of data, to simply increase gRPC message size.
@@ -54,6 +51,13 @@ message Payload {
optional bytes body = 2;
}
+// A protobuf representation for grpc status. This is used by test
+// clients to specify a status that the server should attempt to return.
+message EchoStatus {
+ optional int32 code = 1;
+ optional string message = 2;
+}
+
// Unary request.
message SimpleRequest {
// Desired payload type in the response from the server.
@@ -72,6 +76,12 @@ message SimpleRequest {
// Whether SimpleResponse should include OAuth scope.
optional bool fill_oauth_scope = 5;
+
+ // Whether to request the server to compress the response.
+ optional bool request_compressed_response = 6;
+
+ // Whether server should return a given status
+ optional EchoStatus response_status = 7;
}
// Unary response, as configured by the request.
@@ -123,6 +133,12 @@ message StreamingOutputCallRequest {
// Optional input payload sent along with the request.
optional Payload payload = 3;
+
+ // Whether to request the server to compress the response.
+ optional bool request_compressed_response = 6;
+
+ // Whether server should return a given status
+ optional EchoStatus response_status = 7;
}
// Server-streaming response, as configured by the request and parameters.
@@ -130,3 +146,17 @@ message StreamingOutputCallResponse {
// Payload to increase response size.
optional Payload payload = 1;
}
+
+// For reconnect interop test only.
+// Client tells server what reconnection parameters it used.
+message ReconnectParams {
+ optional int32 max_reconnect_backoff_ms = 1;
+}
+
+// For reconnect interop test only.
+// Server tells client whether its reconnects are following the spec and the
+// reconnect backoffs it saw.
+message ReconnectInfo {
+ optional bool passed = 1;
+ repeated int32 backoff_ms = 2;
+}
diff --git a/src/php/tests/interop/test.proto b/src/php/tests/interop/test.proto
index 0d169e7f64..da03237a93 100644
--- a/src/php/tests/interop/test.proto
+++ b/src/php/tests/interop/test.proto
@@ -68,4 +68,7 @@ service TestService {
// first request.
rpc HalfDuplexCall(stream StreamingOutputCallRequest)
returns (stream StreamingOutputCallResponse);
+
+ // An unimplemented method on the server
+ rpc UnimplementedCall(grpc.testing.EmptyMessage) returns (grpc.testing.EmptyMessage);
}