Skip to content
Latchkey

How to Test a gRPC Service in CI

grpcurl calls gRPC methods from the shell and ghz drives a load smoke, both over server reflection.

Use grpcurl to invoke a method and assert on the JSON reply, then optionally run ghz for a small load smoke against the same service.

Steps

  • Enable server reflection or mount the .proto files.
  • Call a method with grpcurl -d and assert on the reply.
  • Run ghz for a short load smoke and check the error rate.

Workflow

.github/workflows/ci.yml
jobs:
  grpc:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: |
          ./server &
          npx wait-on tcp:50051
      - run: |
          grpcurl -plaintext -d '{"id":"1"}' \
            localhost:50051 users.UserService/GetUser | jq -e '.name'
      - run: |
          ghz --insecure --proto users.proto \
            --call users.UserService/GetUser \
            -d '{"id":"1"}' -n 200 -c 10 localhost:50051

Gotchas

  • Use -plaintext only against a local test server, never against a TLS production endpoint.
  • Wait on tcp:50051 because gRPC has no HTTP health path to poll by default.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →