Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exit with status 1 if grpcping -health isn't SERVING. #589

Merged
merged 7 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ You can install from source:
The [releases](https://github.com/fortio/fortio/releases) page has binaries for many OS/architecture combinations (see assets).

```shell
curl -L https://github.com/fortio/fortio/releases/download/v1.32.3/fortio-linux_amd64-1.32.3.tgz \
curl -L https://github.com/fortio/fortio/releases/download/v1.33.0/fortio-linux_amd64-1.33.0.tgz \
| sudo tar -C / -xvzpf -
# or the debian package
wget https://github.com/fortio/fortio/releases/download/v1.32.3/fortio_1.32.3_amd64.deb
dpkg -i fortio_1.32.3_amd64.deb
wget https://github.com/fortio/fortio/releases/download/v1.33.0/fortio_1.33.0_amd64.deb
dpkg -i fortio_1.33.0_amd64.deb
# or the rpm
rpm -i https://github.com/fortio/fortio/releases/download/v1.32.3/fortio-1.32.3-1.x86_64.rpm
rpm -i https://github.com/fortio/fortio/releases/download/v1.33.0/fortio-1.33.0-1.x86_64.rpm
# and more, see assets in release page
```

Expand All @@ -67,7 +67,7 @@ On a MacOS you can also install Fortio using [Homebrew](https://brew.sh/):
brew install fortio
```

On Windows, download https://github.com/fortio/fortio/releases/download/v1.32.3/fortio_win_1.32.3.zip and extract `fortio.exe` to any location, then using the Windows Command Prompt:
On Windows, download https://github.com/fortio/fortio/releases/download/v1.33.0/fortio_win_1.33.0.zip and extract `fortio.exe` to any location, then using the Windows Command Prompt:
```
fortio.exe server
```
Expand Down Expand Up @@ -115,7 +115,7 @@ Full list of command line flags (`fortio help`):
<details>
<!-- use release/updateFlags.sh to update this section -->
<pre>
Φορτίο 1.32.3 usage:
Φορτίο 1.33.0 usage:
where command is one of: load (load testing), server (starts ui, http-echo,
redirect, proxies, tcp-echo and grpc ping servers), tcp-echo (only the tcp-echo
server), report (report only UI server), redirect (only the redirect server),
Expand Down
15 changes: 10 additions & 5 deletions Webtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,19 @@ docker exec $DOCKERNAME $FORTIO_BIN_PATH load -H Foo:Bar -H Blah:Blah -qps 1 -t
# Do a grpcping
docker exec $DOCKERNAME $FORTIO_BIN_PATH grpcping localhost
# Do a grpcping to a scheme-prefixed destination. Fortio should append port number
# re-enable once we get https://grpc.fortio.org:/ fully working with https too
# docker exec $DOCKERNAME $FORTIO_BIN_PATH grpcping https://grpc.fortio.org
# Do a TLS grpcping. Fortio.org should use valid cert.
docker exec $DOCKERNAME $FORTIO_BIN_PATH grpcping https://grpc.fortio.org
docker exec $DOCKERNAME $FORTIO_BIN_PATH grpcping grpc.fortio.org # uses default non tls 8079
# Do a grpcping with -cert flag. Fortio should use valid cert.
# docker exec $DOCKERNAME $FORTIO_BIN_PATH grpcping -cacert $CERT grpc.fortio.org:443
# docker exec $DOCKERNAME $FORTIO_BIN_PATH grpcping -cacert $CERT https://grpc.fortio.org
# Do a local grpcping. Fortio should append default grpc port number to destination
docker exec $DOCKERNAME $FORTIO_BIN_PATH grpcping localhost
# Do a local health ping
docker exec $DOCKERNAME $FORTIO_BIN_PATH grpcping -health localhost
docker exec $DOCKERNAME $FORTIO_BIN_PATH grpcping -health -healthservice ping localhost
# Do a failing on purpose check
if [ !docker exec $DOCKERNAME $FORTIO_BIN_PATH grpcping -health -healthservice ping_down localhost ]; then
ldemailly marked this conversation as resolved.
Show resolved Hide resolved
ldemailly marked this conversation as resolved.
Show resolved Hide resolved
ldemailly marked this conversation as resolved.
Show resolved Hide resolved
ldemailly marked this conversation as resolved.
Show resolved Hide resolved
echo "*** grpcping -health to ping_down have exit with error/non zero status"
exit 1
fi
# pprof should be there, no 404/error
PPROF_URL="$BASE_URL/debug/pprof/heap?debug=1"
$CURL "$PPROF_URL" | grep -i TotalAlloc # should find this in memory profile
Expand Down
1 change: 1 addition & 0 deletions fgrpc/pingsrv.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func PingServer(port, cert, key, healthServiceName string, maxConcurrentStreams
reflection.Register(grpcServer)
healthServer := health.NewServer()
healthServer.SetServingStatus(healthServiceName, grpc_health_v1.HealthCheckResponse_SERVING)
healthServer.SetServingStatus(healthServiceName+"_down", grpc_health_v1.HealthCheckResponse_NOT_SERVING)
grpc_health_v1.RegisterHealthServer(grpcServer, healthServer)
RegisterPingServerServer(grpcServer, &pingSrv{})
go func() {
Expand Down
3 changes: 3 additions & 0 deletions fgrpc/pingsrv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ func TestPingServer(t *testing.T) {
if r, err := GrpcHealthCheck(sAddr, "foo", 3, TLSSecure); err != nil || (*r)[serving] != 3 {
t.Errorf("Unexpected result %+v, %v with health check for same service as started (foo)", r, err)
}
if r, err := GrpcHealthCheck(sAddr, "foo_down", 3, TLSSecure); err != nil || (*r)["NOT_SERVING"] != 3 {
t.Errorf("Unexpected result %+v, %v with health check for _down variant of same service as started (foo/foo_down)", r, err)
}
if r, err := GrpcHealthCheck(iAddr, "willfail", 1, TLSInsecure); err == nil || r != nil {
t.Errorf("Was expecting error when using unknown service, didn't get one, got %+v", r)
}
Expand Down
15 changes: 11 additions & 4 deletions fortio_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,19 @@ func grpcClient() {
count = 1
}
httpOpts := bincommon.SharedHTTPOptions()
var err error
if *doHealthFlag {
_, err = fgrpc.GrpcHealthCheck(host, *healthSvcFlag, count, &httpOpts.TLSOptions)
} else {
_, err = fgrpc.PingClientCall(host, count, httpOpts.PayloadString(), *pingDelayFlag, &httpOpts.TLSOptions)
status, err := fgrpc.GrpcHealthCheck(host, *healthSvcFlag, count, &httpOpts.TLSOptions)
if err != nil {
// already logged
os.Exit(1)
}
if (*status)["SERVING"] != int64(count) {
log.Errf("Unexpected SERVING count %d vs %d", (*status)["SERVING"], count)
os.Exit(1)
}
return
}
_, err := fgrpc.PingClientCall(host, count, httpOpts.PayloadString(), *pingDelayFlag, &httpOpts.TLSOptions)
if err != nil {
// already logged
os.Exit(1)
Expand Down