PHP Proto3: update tests and README
This commit is contained in:
parent
857a130493
commit
39b2e5bec6
|
|
@ -7,7 +7,7 @@
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.5.0",
|
"php": ">=5.5.0",
|
||||||
"stanley-cheung/protobuf-php": "v0.6"
|
"google/protobuf": "v3.1.0-alpha-1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"google/auth": "v0.9"
|
"google/auth": "v0.9"
|
||||||
|
|
|
||||||
|
|
@ -20,3 +20,6 @@ mkinstalldirs
|
||||||
ext/grpc/ltmain.sh
|
ext/grpc/ltmain.sh
|
||||||
composer.lock
|
composer.lock
|
||||||
vendor/
|
vendor/
|
||||||
|
|
||||||
|
*.pb.php
|
||||||
|
*_grpc_pb.php
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
|
|
||||||
#Overview
|
#Overview
|
||||||
|
|
||||||
This directory contains source code for PHP implementation of gRPC layered on shared C library.
|
This directory contains source code for PHP implementation of gRPC layered on
|
||||||
|
shared C library.
|
||||||
|
|
||||||
#Status
|
#Status
|
||||||
|
|
||||||
|
|
@ -9,17 +10,29 @@ GA
|
||||||
|
|
||||||
## Environment
|
## Environment
|
||||||
|
|
||||||
Prerequisite:
|
**Prerequisite:**
|
||||||
* `php` 5.5 or above, 7.0 or above
|
* `php` 5.5 or above, 7.0 or above
|
||||||
* `pear` and `pecl`
|
* `pecl`
|
||||||
* `phpunit`
|
* `composer`
|
||||||
|
* `phpunit` (optional)
|
||||||
|
|
||||||
**PEAR:**
|
**Ubuntu/Debian:**
|
||||||
|
```sh
|
||||||
|
$ sudo apt-get install php5 php5-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
**PEAR/PECL:**
|
||||||
```sh
|
```sh
|
||||||
$ curl -O http://pear.php.net/go-pear.phar
|
$ curl -O http://pear.php.net/go-pear.phar
|
||||||
$ sudo php -d detect_unicode=0 go-pear.phar
|
$ sudo php -d detect_unicode=0 go-pear.phar
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Composer:**
|
||||||
|
```sh
|
||||||
|
$ curl -sS https://getcomposer.org/installer | php
|
||||||
|
$ sudo mv composer.phar /usr/local/bin/composer
|
||||||
|
```
|
||||||
|
|
||||||
**PHPUnit:**
|
**PHPUnit:**
|
||||||
```sh
|
```sh
|
||||||
$ wget https://phar.phpunit.de/phpunit-old.phar
|
$ wget https://phar.phpunit.de/phpunit-old.phar
|
||||||
|
|
@ -29,15 +42,32 @@ $ sudo mv phpunit-old.phar /usr/bin/phpunit
|
||||||
|
|
||||||
## Quick Install
|
## Quick Install
|
||||||
|
|
||||||
Install the gRPC PHP extension
|
**Install the gRPC PHP extension**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo pecl install grpc
|
sudo pecl install grpc
|
||||||
```
|
```
|
||||||
|
|
||||||
This will compile and install the gRPC PHP extension into the standard PHP extension directory. You should be able to run the [unit tests](#unit-tests), with the PHP extension installed.
|
This will compile and install the gRPC PHP extension into the standard PHP
|
||||||
|
extension directory. You should be able to run the [unit tests](#unit-tests),
|
||||||
|
with the PHP extension installed.
|
||||||
|
|
||||||
|
|
||||||
|
**Add the gRPC PHP library as a Composer dependency**
|
||||||
|
|
||||||
|
You need to add this to your project's `composer.json` file.
|
||||||
|
|
||||||
|
```
|
||||||
|
"require": {
|
||||||
|
"grpc/grpc": "v1.0.0"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
To run tests with generated stub code from `.proto` files, you will also need
|
||||||
|
the `composer` and `protoc` binaries. You can find out how to get these
|
||||||
|
[below](#generated-code-tests).
|
||||||
|
|
||||||
|
|
||||||
To run tests with generated stub code from `.proto` files, you will also need the `composer`, `protoc` and `protoc-gen-php` binaries. You can find out how to get these [below](#generated-code-tests).
|
|
||||||
|
|
||||||
## Build from Source
|
## Build from Source
|
||||||
|
|
||||||
|
|
@ -98,45 +128,46 @@ $ ./bin/run_tests.sh
|
||||||
|
|
||||||
## Generated Code Tests
|
## Generated Code Tests
|
||||||
|
|
||||||
This section specifies the prerequisites for running the generated code tests, as well as how to run the tests themselves.
|
This section specifies the prerequisites for running the generated code tests,
|
||||||
|
as well as how to run the tests themselves.
|
||||||
|
|
||||||
### Composer
|
### Composer
|
||||||
|
|
||||||
If you don't have it already, install `composer` to pull in some runtime dependencies based on the `composer.json` file.
|
Install the runtime dependencies via `composer install`.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ curl -sS https://getcomposer.org/installer | php
|
|
||||||
$ sudo mv composer.phar /usr/local/bin/composer
|
|
||||||
|
|
||||||
$ cd grpc/src/php
|
$ cd grpc/src/php
|
||||||
$ composer install
|
$ composer install
|
||||||
```
|
```
|
||||||
|
|
||||||
### Protobuf compiler
|
### Protobuf compiler
|
||||||
|
|
||||||
Again if you don't have it already, you need to install the protobuf compiler `protoc`, version 3.0.0+.
|
Again if you don't have it already, you need to install the protobuf compiler
|
||||||
|
`protoc`, version 3.1.0+.
|
||||||
|
|
||||||
If you compiled the gRPC C core library from source above, the `protoc` binary should have been installed as well. If it hasn't been installed, you can run the following commands to install it.
|
If `protoc` hasn't been installed, you can download the `protoc` binaries from
|
||||||
|
[the protocol buffers Github repository](https://github.com/google/protobuf/releases).
|
||||||
|
|
||||||
|
If you really must compile `protoc` from source, you can run the following
|
||||||
|
commands, but this is risky because there is no easy way to uninstall /
|
||||||
|
upgrade to a newer release.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ cd grpc/third_party/protobuf
|
$ cd grpc/third_party/protobuf
|
||||||
$ sudo make install # 'make' should have been run by core grpc
|
$ ./autogen.sh && ./configure && make
|
||||||
|
$ sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternatively, you can download `protoc` binaries from [the protocol buffers Github repository](https://github.com/google/protobuf/releases).
|
|
||||||
|
|
||||||
|
### PHP Protoc Plugin
|
||||||
|
|
||||||
### PHP protobuf compiler
|
You need the gRPC PHP protoc plugin to generate the client stub classes.
|
||||||
|
|
||||||
You need to install `protoc-gen-php` to generate stub class `.php` files from service definition `.proto` files.
|
It should already been compiled when you run `make` from the root directory
|
||||||
|
of this repo. The plugin can be found in the `bins/opt` directory. We are
|
||||||
|
planning to provide a better way to download and install the plugin
|
||||||
|
in the future.
|
||||||
|
|
||||||
```sh
|
|
||||||
$ git clone https://github.com/stanley-cheung/Protobuf-PHP
|
|
||||||
$ cd Protobuf-PHP
|
|
||||||
$ gem install rake ronn
|
|
||||||
$ rake pear:package version=1.0
|
|
||||||
$ sudo pear install Protobuf-1.0.tgz
|
|
||||||
```
|
|
||||||
|
|
||||||
### Client Stub
|
### Client Stub
|
||||||
|
|
||||||
|
|
@ -149,7 +180,8 @@ $ ./bin/generate_proto_php.sh
|
||||||
|
|
||||||
### Run test server
|
### Run test server
|
||||||
|
|
||||||
Run a local server serving the math services. Please see [Node][] for how to run an example server.
|
Run a local server serving the math services. Please see [Node][] for how to
|
||||||
|
run an example server.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ cd grpc
|
$ cd grpc
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ default_extension_dir=$(php-config --extension-dir)
|
||||||
if [ ! -e $default_extension_dir/grpc.so ]; then
|
if [ ! -e $default_extension_dir/grpc.so ]; then
|
||||||
# the grpc extension is not found in the default PHP extension dir
|
# the grpc extension is not found in the default PHP extension dir
|
||||||
# try the source modules directory
|
# try the source modules directory
|
||||||
module_dir=../ext/grpc/modules
|
module_dir=$(pwd)/../ext/grpc/modules
|
||||||
if [ ! -e $module_dir/grpc.so ]; then
|
if [ ! -e $module_dir/grpc.so ]; then
|
||||||
echo "Please run 'phpize && ./configure && make' from ext/grpc first"
|
echo "Please run 'phpize && ./configure && make' from ext/grpc first"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,32 @@
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
cd $(dirname $0)
|
cd $(dirname $0)/../../..
|
||||||
|
|
||||||
gen_code='../tests/generated_code'
|
protoc --proto_path=src/proto/math \
|
||||||
interop='../tests/interop'
|
--php_out=src/php/tests/generated_code \
|
||||||
|
--grpc_out=src/php/tests/generated_code \
|
||||||
|
--plugin=protoc-gen-grpc=bins/opt/grpc_php_plugin \
|
||||||
|
src/proto/math/math.proto
|
||||||
|
|
||||||
protoc-gen-php -i $gen_code -o $gen_code $gen_code/math.proto
|
# replace the Empty message with EmptyMessage
|
||||||
|
# because Empty is a PHP reserved word
|
||||||
|
sed -i 's/message Empty/message EmptyMessage/g' \
|
||||||
|
src/proto/grpc/testing/empty.proto
|
||||||
|
sed -i 's/grpc\.testing\.Empty/grpc\.testing\.EmptyMessage/g' \
|
||||||
|
src/proto/grpc/testing/test.proto
|
||||||
|
|
||||||
protoc-gen-php -i $interop -o $interop $interop/test.proto
|
protoc --proto_path=. \
|
||||||
|
--php_out=src/php/tests/interop \
|
||||||
|
--grpc_out=src/php/tests/interop \
|
||||||
|
--plugin=protoc-gen-grpc=bins/opt/grpc_php_plugin \
|
||||||
|
src/proto/grpc/testing/messages.proto \
|
||||||
|
src/proto/grpc/testing/empty.proto \
|
||||||
|
src/proto/grpc/testing/test.proto
|
||||||
|
|
||||||
|
# change it back
|
||||||
|
sed -i 's/message EmptyMessage/message Empty/g' \
|
||||||
|
src/proto/grpc/testing/empty.proto
|
||||||
|
sed -i 's/grpc\.testing\.EmptyMessage/grpc\.testing\.Empty/g' \
|
||||||
|
src/proto/grpc/testing/test.proto
|
||||||
|
|
|
||||||
|
|
@ -31,5 +31,6 @@
|
||||||
set -e
|
set -e
|
||||||
cd $(dirname $0)
|
cd $(dirname $0)
|
||||||
source ./determine_extension_dir.sh
|
source ./determine_extension_dir.sh
|
||||||
|
cd ../tests/interop
|
||||||
php $extension_dir -d max_execution_time=300 \
|
php $extension_dir -d max_execution_time=300 \
|
||||||
../tests/interop/interop_client.php $@ 1>&2
|
interop_client.php $@ 1>&2
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.5.0",
|
"php": ">=5.5.0",
|
||||||
"stanley-cheung/protobuf-php": "v0.6"
|
"google/protobuf": "v3.1.0-alpha-1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"google/auth": "v0.9"
|
"google/auth": "v0.9"
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
require_once realpath(dirname(__FILE__).'/../../vendor/autoload.php');
|
require_once realpath(dirname(__FILE__).'/../../vendor/autoload.php');
|
||||||
require_once dirname(__FILE__).'/math.php';
|
require_once dirname(__FILE__).'/math.pb.php';
|
||||||
|
require_once dirname(__FILE__).'/math_grpc_pb.php';
|
||||||
|
|
||||||
abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
|
abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
|
@ -92,7 +93,7 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase
|
||||||
public function testTimeout()
|
public function testTimeout()
|
||||||
{
|
{
|
||||||
$div_arg = new math\DivArgs();
|
$div_arg = new math\DivArgs();
|
||||||
$call = self::$client->Div($div_arg, [], ['timeout' => 100]);
|
$call = self::$client->Div($div_arg, [], ['timeout' => 1]);
|
||||||
list($response, $status) = $call->wait();
|
list($response, $status) = $call->wait();
|
||||||
$this->assertSame(\Grpc\STATUS_DEADLINE_EXCEEDED, $status->code);
|
$this->assertSame(\Grpc\STATUS_DEADLINE_EXCEEDED, $status->code);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,83 +0,0 @@
|
||||||
|
|
||||||
// Copyright 2015, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// TODO: start using src/proto/math/math.proto and remove this file once
|
|
||||||
// PHP supports proto3.
|
|
||||||
|
|
||||||
syntax = "proto2";
|
|
||||||
|
|
||||||
package math;
|
|
||||||
|
|
||||||
message DivArgs {
|
|
||||||
optional int64 dividend = 1 [default = 0];
|
|
||||||
optional int64 divisor = 2 [default = 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
message DivReply {
|
|
||||||
optional int64 quotient = 1 [default = 0];
|
|
||||||
optional int64 remainder = 2 [default = 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
message FibArgs {
|
|
||||||
optional int64 limit = 1 [default = 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
message Num {
|
|
||||||
optional int64 num = 1 [default = 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
message FibReply {
|
|
||||||
optional int64 count = 1 [default = 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
service Math {
|
|
||||||
// Div divides args.dividend by args.divisor and returns the quotient and
|
|
||||||
// remainder.
|
|
||||||
rpc Div (DivArgs) returns (DivReply) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// DivMany accepts an arbitrary number of division args from the client stream
|
|
||||||
// and sends back the results in the reply stream. The stream continues until
|
|
||||||
// the client closes its end; the server does the same after sending all the
|
|
||||||
// replies. The stream ends immediately if either end aborts.
|
|
||||||
rpc DivMany (stream DivArgs) returns (stream DivReply) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fib generates numbers in the Fibonacci sequence. If args.limit > 0, Fib
|
|
||||||
// generates up to limit numbers; otherwise it continues until the call is
|
|
||||||
// canceled. Unlike Fib above, Fib has no final FibReply.
|
|
||||||
rpc Fib (FibArgs) returns (stream Num) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sum sums a stream of numbers, returning the final result once the stream
|
|
||||||
// is closed.
|
|
||||||
rpc Sum (stream Num) returns (Num) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
|
|
||||||
// Copyright 2015, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
syntax = "proto2";
|
|
||||||
|
|
||||||
package grpc.testing;
|
|
||||||
|
|
||||||
// An empty message that you can re-use to avoid defining duplicated empty
|
|
||||||
// messages in your project. A typical example is to use it as argument or the
|
|
||||||
// return value of a service API. For instance:
|
|
||||||
//
|
|
||||||
// service Foo {
|
|
||||||
// rpc Bar (grpc.testing.EmptyMessage) returns (grpc.testing.EmptyMessage) { };
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
message EmptyMessage {}
|
|
||||||
|
|
@ -32,9 +32,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
require_once realpath(dirname(__FILE__).'/../../vendor/autoload.php');
|
require_once realpath(dirname(__FILE__).'/../../vendor/autoload.php');
|
||||||
require 'empty.php';
|
require 'src/proto/grpc/testing/test.pb.php';
|
||||||
require 'messages.php';
|
require 'src/proto/grpc/testing/test_grpc_pb.php';
|
||||||
require 'test.php';
|
|
||||||
use Google\Auth\CredentialsLoader;
|
use Google\Auth\CredentialsLoader;
|
||||||
use Google\Auth\ApplicationDefaultCredentials;
|
use Google\Auth\ApplicationDefaultCredentials;
|
||||||
use GuzzleHttp\ClientInterface;
|
use GuzzleHttp\ClientInterface;
|
||||||
|
|
@ -282,7 +281,7 @@ function serverStreaming($stub)
|
||||||
foreach ($sizes as $size) {
|
foreach ($sizes as $size) {
|
||||||
$response_parameters = new grpc\testing\ResponseParameters();
|
$response_parameters = new grpc\testing\ResponseParameters();
|
||||||
$response_parameters->setSize($size);
|
$response_parameters->setSize($size);
|
||||||
$request->addResponseParameters($response_parameters);
|
$request->getResponseParameters()[] = $response_parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
$call = $stub->StreamingOutputCall($request);
|
$call = $stub->StreamingOutputCall($request);
|
||||||
|
|
@ -316,7 +315,7 @@ function pingPong($stub)
|
||||||
$request->setResponseType(grpc\testing\PayloadType::COMPRESSABLE);
|
$request->setResponseType(grpc\testing\PayloadType::COMPRESSABLE);
|
||||||
$response_parameters = new grpc\testing\ResponseParameters();
|
$response_parameters = new grpc\testing\ResponseParameters();
|
||||||
$response_parameters->setSize($response_lengths[$i]);
|
$response_parameters->setSize($response_lengths[$i]);
|
||||||
$request->addResponseParameters($response_parameters);
|
$request->getResponseParameters()[] = $response_parameters;
|
||||||
$payload = new grpc\testing\Payload();
|
$payload = new grpc\testing\Payload();
|
||||||
$payload->setBody(str_repeat("\0", $request_lengths[$i]));
|
$payload->setBody(str_repeat("\0", $request_lengths[$i]));
|
||||||
$request->setPayload($payload);
|
$request->setPayload($payload);
|
||||||
|
|
@ -376,7 +375,7 @@ function cancelAfterFirstResponse($stub)
|
||||||
$request->setResponseType(grpc\testing\PayloadType::COMPRESSABLE);
|
$request->setResponseType(grpc\testing\PayloadType::COMPRESSABLE);
|
||||||
$response_parameters = new grpc\testing\ResponseParameters();
|
$response_parameters = new grpc\testing\ResponseParameters();
|
||||||
$response_parameters->setSize(31415);
|
$response_parameters->setSize(31415);
|
||||||
$request->addResponseParameters($response_parameters);
|
$request->getResponseParameters()[] = $response_parameters;
|
||||||
$payload = new grpc\testing\Payload();
|
$payload = new grpc\testing\Payload();
|
||||||
$payload->setBody(str_repeat("\0", 27182));
|
$payload->setBody(str_repeat("\0", 27182));
|
||||||
$request->setPayload($payload);
|
$request->setPayload($payload);
|
||||||
|
|
@ -396,7 +395,7 @@ function timeoutOnSleepingServer($stub)
|
||||||
$request->setResponseType(grpc\testing\PayloadType::COMPRESSABLE);
|
$request->setResponseType(grpc\testing\PayloadType::COMPRESSABLE);
|
||||||
$response_parameters = new grpc\testing\ResponseParameters();
|
$response_parameters = new grpc\testing\ResponseParameters();
|
||||||
$response_parameters->setSize(8);
|
$response_parameters->setSize(8);
|
||||||
$request->addResponseParameters($response_parameters);
|
$request->getResponseParameters()[] = $response_parameters;
|
||||||
$payload = new grpc\testing\Payload();
|
$payload = new grpc\testing\Payload();
|
||||||
$payload->setBody(str_repeat("\0", 9));
|
$payload->setBody(str_repeat("\0", 9));
|
||||||
$request->setPayload($payload);
|
$request->setPayload($payload);
|
||||||
|
|
|
||||||
|
|
@ -1,162 +0,0 @@
|
||||||
|
|
||||||
// Copyright 2015-2016, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// Message definitions to be used by integration test service definitions.
|
|
||||||
|
|
||||||
syntax = "proto2";
|
|
||||||
|
|
||||||
package grpc.testing;
|
|
||||||
|
|
||||||
// The type of payload that should be returned.
|
|
||||||
enum PayloadType {
|
|
||||||
// Compressable text format.
|
|
||||||
COMPRESSABLE = 0;
|
|
||||||
|
|
||||||
// Uncompressable binary format.
|
|
||||||
UNCOMPRESSABLE = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// A block of data, to simply increase gRPC message size.
|
|
||||||
message Payload {
|
|
||||||
// The type of data in body.
|
|
||||||
optional PayloadType type = 1 [default = COMPRESSABLE];
|
|
||||||
// Primary contents of 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.
|
|
||||||
// If response_type is RANDOM, server randomly chooses one from other formats.
|
|
||||||
optional PayloadType response_type = 1 [default = COMPRESSABLE];
|
|
||||||
|
|
||||||
// Desired payload size in the response from the server.
|
|
||||||
// If response_type is COMPRESSABLE, this denotes the size before compression.
|
|
||||||
optional int32 response_size = 2;
|
|
||||||
|
|
||||||
// Optional input payload sent along with the request.
|
|
||||||
optional Payload payload = 3;
|
|
||||||
|
|
||||||
// Whether SimpleResponse should include username.
|
|
||||||
optional bool fill_username = 4;
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
message SimpleResponse {
|
|
||||||
// Payload to increase message size.
|
|
||||||
optional Payload payload = 1;
|
|
||||||
// The user the request came from, for verifying authentication was
|
|
||||||
// successful when the client expected it.
|
|
||||||
optional string username = 2;
|
|
||||||
// OAuth scope.
|
|
||||||
optional string oauth_scope = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Client-streaming request.
|
|
||||||
message StreamingInputCallRequest {
|
|
||||||
// Optional input payload sent along with the request.
|
|
||||||
optional Payload payload = 1;
|
|
||||||
|
|
||||||
// Not expecting any payload from the response.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Client-streaming response.
|
|
||||||
message StreamingInputCallResponse {
|
|
||||||
// Aggregated size of payloads received from the client.
|
|
||||||
optional int32 aggregated_payload_size = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configuration for a particular response.
|
|
||||||
message ResponseParameters {
|
|
||||||
// Desired payload sizes in responses from the server.
|
|
||||||
// If response_type is COMPRESSABLE, this denotes the size before compression.
|
|
||||||
optional int32 size = 1;
|
|
||||||
|
|
||||||
// Desired interval between consecutive responses in the response stream in
|
|
||||||
// microseconds.
|
|
||||||
optional int32 interval_us = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Server-streaming request.
|
|
||||||
message StreamingOutputCallRequest {
|
|
||||||
// Desired payload type in the response from the server.
|
|
||||||
// If response_type is RANDOM, the payload from each response in the stream
|
|
||||||
// might be of different types. This is to simulate a mixed type of payload
|
|
||||||
// stream.
|
|
||||||
optional PayloadType response_type = 1 [default = COMPRESSABLE];
|
|
||||||
|
|
||||||
// Configuration for each expected response message.
|
|
||||||
repeated ResponseParameters response_parameters = 2;
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,78 +0,0 @@
|
||||||
|
|
||||||
// Copyright 2015-2016, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// An integration test service that covers all the method signature permutations
|
|
||||||
// of unary/streaming requests/responses.
|
|
||||||
syntax = "proto2";
|
|
||||||
|
|
||||||
import "empty.proto";
|
|
||||||
import "messages.proto";
|
|
||||||
|
|
||||||
package grpc.testing;
|
|
||||||
|
|
||||||
// A simple service to test the various types of RPCs and experiment with
|
|
||||||
// performance with various types of payload.
|
|
||||||
service TestService {
|
|
||||||
// One empty request followed by one empty response.
|
|
||||||
rpc EmptyCall(grpc.testing.EmptyMessage) returns (grpc.testing.EmptyMessage);
|
|
||||||
|
|
||||||
// One request followed by one response.
|
|
||||||
rpc UnaryCall(SimpleRequest) returns (SimpleResponse);
|
|
||||||
|
|
||||||
// One request followed by a sequence of responses (streamed download).
|
|
||||||
// The server returns the payload with client desired type and sizes.
|
|
||||||
rpc StreamingOutputCall(StreamingOutputCallRequest)
|
|
||||||
returns (stream StreamingOutputCallResponse);
|
|
||||||
|
|
||||||
// A sequence of requests followed by one response (streamed upload).
|
|
||||||
// The server returns the aggregated size of client payload as the result.
|
|
||||||
rpc StreamingInputCall(stream StreamingInputCallRequest)
|
|
||||||
returns (StreamingInputCallResponse);
|
|
||||||
|
|
||||||
// A sequence of requests with each request served by the server immediately.
|
|
||||||
// As one request could lead to multiple responses, this interface
|
|
||||||
// demonstrates the idea of full duplexing.
|
|
||||||
rpc FullDuplexCall(stream StreamingOutputCallRequest)
|
|
||||||
returns (stream StreamingOutputCallResponse);
|
|
||||||
|
|
||||||
// A sequence of requests followed by a sequence of responses.
|
|
||||||
// The server buffers all the client requests and then serves them in order. A
|
|
||||||
// stream of responses are returned to the client when the server starts with
|
|
||||||
// first request.
|
|
||||||
rpc HalfDuplexCall(stream StreamingOutputCallRequest)
|
|
||||||
returns (stream StreamingOutputCallResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
// A simple service NOT implemented at servers so clients can test for
|
|
||||||
// that case.
|
|
||||||
service UnimplementedService {
|
|
||||||
// A call that no server should implement
|
|
||||||
rpc UnimplementedCall(grpc.testing.EmptyMessage) returns (grpc.testing.EmptyMessage);
|
|
||||||
}
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.5.0",
|
"php": ">=5.5.0",
|
||||||
"stanley-cheung/protobuf-php": "v0.6"
|
"google/protobuf": "v3.1.0-alpha-1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"google/auth": "v0.9"
|
"google/auth": "v0.9"
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
"version": "${settings.php_version.php_composer()}",
|
"version": "${settings.php_version.php_composer()}",
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.5.0",
|
"php": ">=5.5.0",
|
||||||
"stanley-cheung/protobuf-php": "v0.6"
|
"google/protobuf": "v3.1.0-alpha-1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"google/auth": "v0.9"
|
"google/auth": "v0.9"
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ git clone --recursive /var/local/jenkins/grpc /var/local/git/grpc
|
||||||
cp -r /var/local/jenkins/service_account $HOME || true
|
cp -r /var/local/jenkins/service_account $HOME || true
|
||||||
|
|
||||||
cd /var/local/git/grpc
|
cd /var/local/git/grpc
|
||||||
rvm --default use ruby-2.1
|
|
||||||
|
|
||||||
# gRPC core and protobuf need to be installed
|
# gRPC core and protobuf need to be installed
|
||||||
make install
|
make install
|
||||||
|
|
@ -49,4 +48,4 @@ make install
|
||||||
|
|
||||||
(cd src/php && composer install)
|
(cd src/php && composer install)
|
||||||
|
|
||||||
(cd src/php && protoc-gen-php -i tests/interop/ -o tests/interop/ tests/interop/test.proto)
|
(cd src/php && ./bin/generate_proto_php.sh)
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ git clone --recursive /var/local/jenkins/grpc /var/local/git/grpc
|
||||||
cp -r /var/local/jenkins/service_account $HOME || true
|
cp -r /var/local/jenkins/service_account $HOME || true
|
||||||
|
|
||||||
cd /var/local/git/grpc
|
cd /var/local/git/grpc
|
||||||
rvm --default use ruby-2.1
|
|
||||||
|
|
||||||
# gRPC core and protobuf need to be installed
|
# gRPC core and protobuf need to be installed
|
||||||
make install
|
make install
|
||||||
|
|
@ -49,4 +48,4 @@ make install
|
||||||
|
|
||||||
(cd src/php && composer install)
|
(cd src/php && composer install)
|
||||||
|
|
||||||
(cd src/php && protoc-gen-php -i tests/interop/ -o tests/interop/ tests/interop/test.proto)
|
(cd src/php && ./bin/generate_proto_php.sh)
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ git clone --recursive /var/local/jenkins/grpc /var/local/git/grpc
|
||||||
cp -r /var/local/jenkins/service_account $HOME || true
|
cp -r /var/local/jenkins/service_account $HOME || true
|
||||||
|
|
||||||
cd /var/local/git/grpc
|
cd /var/local/git/grpc
|
||||||
rvm --default use ruby-2.1
|
|
||||||
|
|
||||||
make install-certs
|
make install-certs
|
||||||
|
|
||||||
|
|
@ -51,4 +50,4 @@ make install
|
||||||
|
|
||||||
(cd src/php && composer install)
|
(cd src/php && composer install)
|
||||||
|
|
||||||
(cd src/php && protoc-gen-php -i tests/interop/ -o tests/interop/ tests/interop/test.proto)
|
(cd src/php && ./bin/generate_proto_php.sh)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue