Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tsloughter authored Nov 11, 2023
2 parents e9e14ed + 1d044a3 commit 0aefc23
Show file tree
Hide file tree
Showing 40 changed files with 8,928 additions and 2,415 deletions.
47 changes: 38 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,58 @@ jobs:
build:
name: Test on OTP ${{ matrix.otp_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
matrix:
otp_version: ['23.1']
os: [ubuntu-18.04]
otp_version: ['26.0', '25.2.3', '24.1.2']
rebar3_version: ['3.20.0']
os: [ubuntu-20.04]
env:
OTP_VERSION: ${{ matrix.otp_version }}

steps:
- uses: actions/checkout@v2

- uses: erlef/setup-elixir@v1
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp_version }}
elixir-version: '1.11.1'
rebar3-version: ${{ matrix.rebar3_version }}

- name: Compile
run: rebar3 compile
- name: Tests
run: rebar3 ct --cover
- name: Dialyzer
run: rebar3 dialyzer
- name: Covertool
run: rebar3 covertool generate

- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v2
if: ${{ always() }}
with:
file: _build/test/covertool/grpcbox.covertool.xml
env_vars: OTP_VERSION

dialyzer:
name: Dialyze on OTP ${{ matrix.otp_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
otp_version: ['26.0']
rebar3_version: ['3.22.1']
os: [ubuntu-20.04]
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp_version }}
rebar3-version: ${{ matrix.rebar3_version }}
version-type: 'strict'
- uses: actions/cache@v2
name: Cache
with:
path: |
_build
key: ${{ runner.os }}-build-${{ matrix.otp_version }}-${{ hashFiles('rebar.lock') }}-5
restore-keys: |
${{ runner.os }}-dialyzer-${{ matrix.otp_version }}-5-
- name: Compile
run: rebar3 compile
- name: Dialyzer
run: rebar3 as dialyzer dialyzer
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ Metadata is sent in headers and trailers.
Using a Service Client
----
For each service in the protos passed to `rebar3 gprc gen` it will genrate a `<service>_client` module containing a function for each method in the service.
For each service in the protos passed to `rebar3 gprc gen` it will generate a `<service>_client` module containing a function for each method in the service.
#### Defining Channels
Expand Down
46 changes: 46 additions & 0 deletions benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Benchmark
=========
Utilities for benchmarking grpcbox. The used protocol is compatible with the one defined in [grpc](https://github.com/grpc/grpc/blob/master/src/proto/grpc/testing/benchmark_service.proto) and for example the Go benchmark client and server can be used against grpcbox.

Grpcbox benchmark server
------------------------
To run the grpcbox benchmark server:

```
$ rebar3 as benchmark shell
```

Server options can be changed in `benchmark/config/sys.config`

Grpcbox benchmark client
------------------------
The benchmark client is implemented as a Common Test. First set test parameters in `benchmark/config/test.config`. The available parameters are described in the file. Also the chatterbox client options can be set. After setting test parameters and starting a server to test against, run the grpcbox benchmark client:

```
$ rebar3 as benchmark ct --verbose
```

The --verbose option needs to be set for the measurements to be printed out.

Go benchmark client and server
------------------------------
Grpcbox benchmark is compatible with the Go benchmark client and server.

To build the Go client and server:

```
$ go build -o $GOPATH/bin/go-grpc-benchmark-client <path-to-grpc-go>/benchmark/client
$ go build -o $GOPATH/bin/go-grpc-benchmark-server <path-to-grpc-go>/benchmark/server
```

Example of running the Go benchmark server:

```
$ go-grpc-benchmark-server -port 8080 -test_name mytest
```

Example of running the Go benchmark client:

```
$ go-grpc-benchmark-client -port 8080 -test_name mytest -d 10 -w 1 -r 100 -c 1 -rpc_type unary -req 1 -resp 1
```
37 changes: 37 additions & 0 deletions benchmark/config/sys.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[
{grpcbox, [%% {client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}},
{servers,
[#{grpc_opts => #{service_protos => [benchmark_service_pb],
services => #{'grpc.testing.BenchmarkService' => grpc_testing_benchmark_service},
client_cert_dir => "test/grpcbox_SUITE_data/certificates/"},

transport_opts => #{ssl => false,
keyfile => "test/grpcbox_SUITE_data/certificates/server1.key",
certfile => "test/grpcbox_SUITE_data/certificates/server1.pem",
cacertfile => "test/grpcbox_SUITE_data/certificates/ca.pem"},

listen_opts => #{port => 8080,
ip => {0,0,0,0}},

pool_opts => #{size => 10},

server_opts => #{server_header_table_size => 4096,
server_enable_push => 1,
server_max_concurrent_streams => unlimited,
server_initial_window_size => 100000000,
server_max_frame_size => 16384,
server_max_header_list_size => unlimited}}]}]},

{opencensus, [{sampler, {oc_sampler_always, []}},
{reporters, [{oc_reporter_stdout, []}]},

{stat, [{exporters, [{oc_stat_exporter_stdout, []}]}]}]},

{kernel,
[
{logger,
[
{handler, default, logger_std_h,
#{filters => [{progress, {fun logger_filters:progress/2, stop}}],
formatter => {logger_formatter, #{single_line => true}}}}]}]}
].
23 changes: 23 additions & 0 deletions benchmark/config/test.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
%% Test options
{server_addr, "localhost"}. %% Server address to connect to
{server_port, 8080}. %% Server port to connect to
{num_rpc, 100}. %% The number of concurrent RPCs on each connection
{num_conn, 1}. %% The number of parallel connections
{warmup_dur, 1}. %% Warm-up duration in seconds
{duration, 10}. %% Benchmark duration in seconds
{rq_size, 1}. %% Request message size in bytes
{rsp_size, 1}. %% Response message size in bytes
{rpc_type, unary}. %% RPC type, unary or streaming

%% Client options
{chatterbox,
[
{client_header_table_size,4096},
{client_enable_push,1},
{client_max_concurrent_streams,unlimited},
{client_initial_window_size,100000000},
{client_max_frame_size,16384},
{client_max_header_list_size,unlimited},
{client_flow_control,auto}
]
}.
44 changes: 44 additions & 0 deletions benchmark/proto/benchmark_service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// An integration test service that covers all the method signature permutations
// of unary/streaming requests/responses.
syntax = "proto3";

import "interop/proto/messages.proto";

package grpc.testing;

service BenchmarkService {
// One request followed by one response.
// The server returns the client payload as-is.
rpc UnaryCall(SimpleRequest) returns (SimpleResponse);

// Repeated sequence of one request followed by one response.
// Should be called streaming ping-pong
// The server returns the client payload as-is on each response
rpc StreamingCall(stream SimpleRequest) returns (stream SimpleResponse);

// Single-sided unbounded streaming from client to server
// The server returns the client payload as-is once the client does WritesDone
rpc StreamingFromClient(stream SimpleRequest) returns (SimpleResponse);

// Single-sided unbounded streaming from server to client
// The server repeatedly returns the client payload as-is
rpc StreamingFromServer(SimpleRequest) returns (stream SimpleResponse);

// Two-sided unbounded streaming between server to client
// Both sides send the content of their own choice to the other
rpc StreamingBothWays(stream SimpleRequest) returns (stream SimpleResponse);
}
Loading

0 comments on commit 0aefc23

Please sign in to comment.