JSON/Http1.x for testing Java based gRPC services

36 views
Skip to first unread message

regu...@gmail.com

unread,
Nov 12, 2018, 3:14:45 AM11/12/18
to grpc.io
We are moving our services from REST JSON/H1 to gRPC. Teams are very comfortable with tools like Postman and Swagger for integration testing for two reasons:
  • No compilation needed to invoke a service
  • Text based data definition format i.e. JSON
Our services are implemented using grpc-java and therefore am looking for libraries/approaches to make this work on the JVM. Has anything been done in Java similar to what is described here for go : https://github.com/jnewmano/grpc-json-proxy?

Carl Mastrangelo

unread,
Nov 14, 2018, 11:50:07 AM11/14/18
to grpc.io
Not a complete answer, but we typically use grpc_cli (located somewhere on the github.com/grpc/grpc repo, but I don't recall where) which allows you to poke at services.  The server needs to expose the reflection service, which Java exposes in the grpc-services maven library.   

As for plaintext, you can use plaintext proto  (in Java this class class is called TextFormat).  I personally like the proto text format better (no trailing commas, repeated fields don't require list syntax, compilable).    If you want all your data to be passed as plaintext, rather than just for debugging, you can swap out the Marshaller to be any format.   I have a blog post and working example of how to use JSON in gRPC with no Proto dependency at all:   https://grpc.io/blog/grpc-with-json

If you just want it for debugging, you'll have to use a tool that can decode it.   That said, with server reflection turned on, using a tool is not so bad.   (and you need a tool anyways to de-minify your JSON!).

HTH

Carl,

Regunath Balasubramanian

unread,
Nov 15, 2018, 1:21:34 AM11/15/18
to not...@google.com, grp...@googlegroups.com
Carl,

Thanks for responding and the pointers.
By CLI, maybe you were referring to polyglot?

polyglot allows to specify a local location for the .proto files and therefore the gRPC server did not have to enable Reflection.
For Http, we found a go proxy (polyman) that uses polyglot under the hood. This appears to work (some early tests) and meets our requirements as documented here on our project wiki : GRPC Testing

Thanks again for your help.

Regu

--
You received this message because you are subscribed to a topic in the Google Groups "grpc.io" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/grpc-io/u8mOn0G8FBI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/63e8a0fe-0c44-4bc6-a11d-c5cbf66946f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages