GithubHelp home page GithubHelp logo

adven27 / grpc-wiremock Goto Github PK

View Code? Open in Web Editor NEW
91.0 91.0 40.0 234 KB

gRPC Mock Server

License: MIT License

Dockerfile 3.14% Java 96.86%
apis docker-container docker-image grpc grpc-mock grpc-server grpc-wiremock mock mock-server mocking mocking-server stub stub-backend stub-server stubbing testing testing-tools wiremock

grpc-wiremock's People

Contributors

adven27 avatar deepu-james avatar dosroblox avatar krmahadevan avatar linouk23 avatar marzocchi avatar nikolai-toropanov avatar nwholloway avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

grpc-wiremock's Issues

header subscription not matched to metadata

I have tried all the case variations but header matches seem to not work

 grpcurl -v -H 'requestId: 3735ab65-43eb-4115-a720-c6641d8e1eab' -plaintext -d '{"PolicyId": "1"}' localhost:50000 Payment.PaymentService/GetLatestPaidInvoiceByPolicyId
 
 Resolved method descriptor:
rpc GetLatestPaidInvoiceByPolicyId ( .Payment.GetLatestPaidInvoiceByPolicyIdRequest ) returns ( .Payment.GetLatestPaidInvoiceByPolicyIdResponse );

Request metadata to send:
requestid: 3735ab65-43eb-4115-a720-c6641d8e1eab

Response headers received:
(empty)

Response trailers received:
content-type: application/grpc
requestid: 3735ab65-43eb-4115-a720-c6641d8e1eab
Sent 1 request and received 0 responses
ERROR:
  Code: NotFound
  Message:
                                               Request was not matched
                                               =======================

-----------------------------------------------------------------------------------------------------------------------
| Closest stub                                             | Request                                                  |
-----------------------------------------------------------------------------------------------------------------------
                                                           |
ANY                                                        | POST
/PaymentService/getLatestPaidInvoiceByPolicyId             | /PaymentService/getLatestPaidInvoiceByPolicyId
                                                           |
RequestId: 3735ab65-43eb-4115-a720-c6641d8e1eab            |                                                     <<<<< Header is not present
                                                           |
                                                           |
-----------------------------------------------------------------------------------------------------------------------

Build multiarch image for Mac M1 support

Hi there,

We've been using this image for some months already to execute our tests using Testcontainers. However we've experienced some performance issues when trying to run it on a mac m1.

We tried rebuilding the image using buildx as described here for linux/arm64/v8 architecture and the performance issue is gone now.

Do you think it would be possible for you to publish to DockerHub the image built for other architectures?

Please, let me know if you need further details.

Thanks in advance.

Response<->Protobuf version matching based on protobuf package name /descriptor?

Is your feature request related to a problem? Please describe.

We're versioning our protobuf files based on the package name, e.g.

package userquery.protobuf.grpc;
package userquery.protobuf.grpc.v1_0_0;
package userquery.protobuf.grpc.v1_1_0;

The server seems to register them properly:

grpc_wiremock | Registered services:
grpc_wiremock | * grpc.reflection.v1alpha.ServerReflection
grpc_wiremock | * userquery.protobuf.grpc.v1_0_1.UserQuery
grpc_wiremock | * userquery.protobuf.grpc.v1_0_0.UserQuery
grpc_wiremock | * userquery.protobuf.grpc.UserQuery

But so far I have not yet found a way to serve JSON responses based on matching the protobufs package.

Is it possible to match the appropriate packages response with a corresponding JSON template?

Describe the solution you'd like

A way to match the JSON response with the package descriptor

Describe alternatives you've considered

body matching, url patch matching, header matching

Getting proto error at compile time.

My proto file.

syntax = "proto3";

package supplier_invoice_module.v1.deliveryreceiptpb;
option go_package = "packages/supplier_invoice_module/v1/deliveryreceiptpb";
option java_outer_classname = "DeliveryReceiptProto";
option java_package = "packages/deliveryreceipt";

We are getting this error on starting wiremock server.

Parsed package = [purchase_orders.v1] and service = [Returns]
Found :generateJava: 
Parsed package = [settings.v1] and service = [Flags]
Found :generateJava: 
Parsed package = [supplier_portal.v1.productpb] and service = [ProductService]
Found :generateJava: 
Parsed package = [supplier_portal.v1.supplierpb] and service = [SupplierService]
Found :generateJava: 
Parsed package = [wac.v1] and service = [Wac]
:generateJava (Thread[Daemon worker,5,main]) completed. Took 0.3 secs.
:compileJava (Thread[Daemon worker,5,main]) started.

> Task :compileJava FAILED
Excluding []
Caching disabled for task ':compileJava' because:
/usr/src/java-code/src/main/java/packages/deliveryreceipt/DeliveryReceiptServiceGrpc.java:1: error: ';' expected
package packages/deliveryreceipt;
                ^
/usr/src/java-code/src/main/java/packages/deliveryreceipt/DeliveryReceiptServiceGrpc.java:30: error: > expected
  private static volatile io.grpc.MethodDescriptor<packages/deliveryreceipt.DeliveryReceiptProto.Void,
                                                           ^
/usr/src/java-code/src/main/java/packages/deliveryreceipt/DeliveryReceiptServiceGrpc.java:30: error: <identifier> expected
  private static volatile io.grpc.MethodDescriptor<packages/deliveryreceipt.DeliveryReceiptProto.Void,
                                                                                                     ^
/usr/src/java-code/src/main/java/packages/deliveryreceipt/DeliveryReceiptServiceGrpc.java:31: error: ';' expected
      packages/deliveryreceipt.DeliveryReceiptProto.Suppliers> getListSuppliersDropDownMethod;

Need help.

stubs to return 404s always error used to work

Describe the bug
Whe i setup a return { status = 404, jsonBody = "" } it always gives a http error no matter for what i do

grpcmock_1 | io.adven.grpc.wiremock.BadHttpResponseException:
grpcmock_1 | at io.adven.grpc.wiremock.HttpMock$Response.getMessage(HttpMock.java:113) ~[main/:na]
grpcmock_1 | at io.adven.grpc.wiremock.Translator$WireMockTranslator.redirect(Translator.java:49) ~[main/:na]

Expected behavior
404s return bodies should not conform to the grpc call

Suggestion: mention that you can precompile proto files for faster startup?

Hi!

We are using this for automated tests and would like it to start a bit faster.
I found out that doing my own image based on thismade it start a good deal faster, as long as I didn't update the .proto files:

FROM adven27/grpc-wiremock
# copy our own proto files
COPY ./proto/*.proto /proto/
# Start image faster by compiling everything when we build the image
RUN gradle compileJava

# copy wiremock mappings and files - could also be mounted
COPY ./wiremock/mappings/* /wiremock/mappings/
COPY ./wiremock/__files/* /wiremock/__files/

Perhaps this would be worth mentioning in the readme file?

Adding versions on docker hub

What

@Adven27 thanks for creating such an amazing project!

I've got a small request: could you please add tags to Docker Hub (i.e., currently there's only latest tag that I can pin for my tests and I guess it could cause weird issues later).

Enable support for generated code as jars

Is your feature request related to a problem? Please describe.

One of the biggest challenges with having .proto files as part of the codebase and including it in the build phase is the elongated build times. I have seen that the build time goes substantially high because of the protoc code generation.

The easiest way for this to be by passed is by housing the .proto files in a separate maven/gradle repository and defining the build process on that repository.

So a grpc service project would now contain two components.

  1. grpc-proto-dependencies - which contains all the generated code and also the relevant jars needed by the generated code.
  2. grpc-service - which has grpc-proto-dependencies as a dependency and thus does away with code generation every time.

This has a lot of benefits, because now the code generation happens ONLY on a need basis rather than happening every single time (I guess we can circumvent and benefit from the incremental build nature of gradle, but not sure if its true with maven)

Describe the solution you'd like
Assuming that a project basically takes the above route of having the proto generated code available as a dependency, how can we get grpc-wiremock to work in this model ?

Currently this project works in two models:

  1. Directly consume the docker image and provide it with the directory that contains the .proto files
  2. Follow the approach of building a custom docker image wherein the code generation has already happened and use that image for the tests (As detailed in this docker file https://github.com/Adven27/grpc-wiremock/blob/master/example/Dockerfile)

The problem with (2) is that it now means that one needs to have access to some sort of a docker registry to be able to benefit from this. This is not necessarily true with everyone or may not be an option too.

Open to figuring out how this can be done and willing to contribute to make this a reality as well.

Describe alternatives you've considered

Nothing comes to my mind yet which can be an alternative for this enhancement.

Additional context
Add any other context or screenshots about the feature request here.

Headers propagation causes errors for some clients

For clients like BloomRPC the mock server fails (because of the encoding I would assume) like this:

2021-10-07 12:25:21.056  INFO 101 --- [ault-executor-2] io.adven.grpc.wiremock.HttpMock          : Grpc request BalanceService/getUserBalance:
Headers: {grpc-accept-encoding=identity,deflate,gzip, content-type=application/grpc, accept-encoding=identity,gzip, user-agent=grpc-node/1.24.2 grpc-c/8.0.0 (windows; chttp2; ganges)}
Message:
id: 100
currency: "Hello"

2021-10-07 12:25:21.070  INFO 101 --- [ault-executor-2] io.adven.grpc.wiremock.HttpMock          : Converting to class api.wallet.UserBalanceResponse json:
▼��RPPJJ�I�KNU�R�♠r�☻����y%p>P�,1�4§I(�������♥¶T2�3P�J��h�/(J-N♣�URT�ʅ�D)���(5/�↕�=J�~�J8�JK�)���♣µI;(��
2021-10-07 12:25:21.072 ERROR 101 --- [ault-executor-2] io.grpc.internal.SerializingExecutor     : Exception while executing runnable io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed@6d5ba219

java.lang.IllegalArgumentException: Failed to convert ▼��RPPJJ�I�KNU�R�♠r�☻����y%p>P�,1�4§I(�������♥¶T2�3P�J��h�/(J-N♣�URT�ʅ�D)���(5/�↕�=J�~�J8�JK�)���♣µI;(�� to class api.wallet.UserBalanceResponse
        at io.adven.grpc.wiremock.HttpMock$ProtoJsonUtil.fromJson(HttpMock.java:117) ~[main/:na]
        at io.adven.grpc.wiremock.HttpMock.send(HttpMock.java:79) ~[main/:na]
        at io.adven.grpc.wiremock.Translator$WireMockTranslator.redirect(Translator.java:31) ~[main/:na]
        at io.adven.grpc.wiremock.Translator$WireMockTranslator.redirectApiWalletBalanceService(Translator.java:39) ~[main/:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634) ~[spring-aop-5.3.10.jar:5.3.10]
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:624) ~[spring-aop-5.3.10.jar:5.3.10]
        at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:72) ~[spring-aop-5.3.10.jar:5.3.10]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.10.jar:5.3.10]
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750) ~[spring-aop-5.3.10.jar:5.3.10]
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.10.jar:5.3.10]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.10.jar:5.3.10]
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750) ~[spring-aop-5.3.10.jar:5.3.10]
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:692) ~[spring-aop-5.3.10.jar:5.3.10]
        at io.adven.grpc.wiremock.Translator$ApiWalletBalanceService$$EnhancerBySpringCGLIB$$11421f8f.getUserBalance(<generated>) ~[main/:na]
        at api.wallet.BalanceServiceGrpc$MethodHandlers.invoke(BalanceServiceGrpc.java:205) ~[main/:na]
        at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:182) ~[grpc-stub-1.41.0.jar:1.41.0]
        at io.grpc.PartialForwardingServerCallListener.onHalfClose(PartialForwardingServerCallListener.java:35) ~[grpc-api-1.41.0.jar:1.41.0]
        at io.grpc.ForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:23) ~[grpc-api-1.41.0.jar:1.41.0]
        at io.grpc.ForwardingServerCallListener$SimpleForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:40) ~[grpc-api-1.41.0.jar:1.41.0]
        at io.grpc.Contexts$ContextualizedServerCallListener.onHalfClose(Contexts.java:86) ~[grpc-api-1.41.0.jar:1.41.0]
        at io.grpc.PartialForwardingServerCallListener.onHalfClose(PartialForwardingServerCallListener.java:35) ~[grpc-api-1.41.0.jar:1.41.0]
        at io.grpc.ForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:23) ~[grpc-api-1.41.0.jar:1.41.0]
        at io.grpc.ForwardingServerCallListener$SimpleForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:40) ~[grpc-api-1.41.0.jar:1.41.0]
        at io.adven.grpc.wiremock.ExceptionHandler$ExceptionHandlingServerCallListener.onHalfClose(ExceptionHandler.java:42) ~[main/:na]
        at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:335) ~[grpc-core-1.41.0.jar:1.41.0]
        at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:866) ~[grpc-core-1.41.0.jar:1.41.0]
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) ~[grpc-core-1.41.0.jar:1.41.0]
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133) ~[grpc-core-1.41.0.jar:1.41.0]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
        at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]
Caused by: com.google.protobuf.InvalidProtocolBufferException: Expect message object but got: "\u001f�\b\u0000\u0000\u0000\u0000\u0000\u0000\u0000��RPPJJ�I�KNU�R�\u0006r�\u0002����y%p>P�"
        at com.google.protobuf.util.JsonFormat$ParserImpl.mergeMessage(JsonFormat.java:1481) ~[protobuf-java-util-3.17.2.jar:na]
        at com.google.protobuf.util.JsonFormat$ParserImpl.merge(JsonFormat.java:1458) ~[protobuf-java-util-3.17.2.jar:na]
        at com.google.protobuf.util.JsonFormat$ParserImpl.merge(JsonFormat.java:1340) ~[protobuf-java-util-3.17.2.jar:na]
        at com.google.protobuf.util.JsonFormat$Parser.merge(JsonFormat.java:476) ~[protobuf-java-util-3.17.2.jar:na]
        at io.adven.grpc.wiremock.HttpMock$ProtoJsonUtil.fromJson(HttpMock.java:112) ~[main/:na]
        ... 34 common frames omitted

gRPC restricted header name: "content-length"

Describe the bug
I appreciate your efforts on this project. It's really simple to use for my needs. I was doing gRPC tests through APISIX gateway. I set up grpc-wiremock as backend service to respond gRPC requests coming from APISIX gRPC-transcoder (transforms http to gRPC).
To Reproduce
Request flow is like curl -> APISIX gateway ( gRPC transcoder )-> grpc-wiremock
Steps to reproduce the behavior:

  1. Set up APISIX gateway and push proto descriptor binary to the gateway using the sample proto files
  2. Create an upstream entry that points a grpc-wiremock instance (make sure they are in the same network for simplicity)
  3. Create route in the gateway(127.0.0.1:9080) similar to below
curl http://127.0.0.1:9080/apisix/admin/routes/111 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
    "methods": ["GET"],
    "uri": "/userBalance",
    "plugins": {
        "grpc-transcode": {
            "proto_id": "1",
            "service": "api.wallet.BalanceService",
            "method": "getUserBalance"
        }
    },
}'
  1. Send curl json request to the gateway(127.0.0.1:9080) which will be converted to gRPC message and will be passed to grpc-wiremock
curl -i http://127.0.0.1:9080/userBalance\?user_id\=1\&currency\=EUR
  1. See error in the grpc-wiremock logs
2022-03-25 14:13:17.637  INFO 306 --- [ault-executor-7] io.adven.grpc.wiremock.HttpMock          : Grpc request BalanceService/getUserBalance:
Headers: {x-grpc-full-method-name=api.wallet.BalanceService/getUserBalance, withamount=100.0, content-length=12, content-type=application/grpc, user-agent=curl/7.81.0, accept=*/*}
Message:
user_id: 1
currency: "EUR"

2022-03-25 14:13:17.638 ERROR 306 --- [ault-executor-7] io.grpc.internal.SerializingExecutor     : Exception while executing runnable io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed@5b32676d

java.lang.IllegalArgumentException: restricted header name: "content-length"
        at java.net.http/jdk.internal.net.http.common.Utils.newIAE(Utils.java:286) ~[java.net.http:na]
        at java.net.http/jdk.internal.net.http.HttpRequestBuilderImpl.checkNameAndValue(HttpRequestBuilderImpl.java:110) ~[java.net.http:na]
        at java.net.http/jdk.internal.net.http.HttpRequestBuilderImpl.header(HttpRequestBuilderImpl.java:126) ~[java.net.http:na]
        at java.net.http/jdk.internal.net.http.HttpRequestBuilderImpl.headers(HttpRequestBuilderImpl.java:140) ~[java.net.http:na]
        at java.net.http/jdk.internal.net.http.HttpRequestBuilderImpl.headers(HttpRequestBuilderImpl.java:43) ~[java.net.http:na]
        at io.adven.grpc.wiremock.HttpMock.request(HttpMock.java:88) ~[main/:na]
        at io.adven.grpc.wiremock.HttpMock.request(HttpMock.java:97) ~[main/:na]
        at io.adven.grpc.wiremock.Translator$WireMockTranslator.redirect(Translator.java:44) ~[main/:na]
        at io.adven.grpc.wiremock.Translator$WireMockTranslator.redirectApiWalletBalanceService(Translator.java:56) ~[main/:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634) ~[spring-aop-5.3.14.jar:5.3.14]
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:624) ~[spring-aop-5.3.14.jar:5.3.14]
        at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:72) ~[spring-aop-5.3.14.jar:5.3.14]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.14.jar:5.3.14]
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753) ~[spring-aop-5.3.14.jar:5.3.14]
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.14.jar:5.3.14]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.14.jar:5.3.14]
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753) ~[spring-aop-5.3.14.jar:5.3.14]
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698) ~[spring-aop-5.3.14.jar:5.3.14]
        at io.adven.grpc.wiremock.Translator$ApiWalletBalanceService$$EnhancerBySpringCGLIB$$26d39afa.getUserBalance(<generated>) ~[main/:na]
        at api.wallet.BalanceServiceGrpc$MethodHandlers.invoke(BalanceServiceGrpc.java:205) ~[main/:na]
        at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:182) ~[grpc-stub-1.43.2.jar:1.43.2]
        at io.grpc.PartialForwardingServerCallListener.onHalfClose(PartialForwardingServerCallListener.java:35) ~[grpc-api-1.43.2.jar:1.43.2]
        at io.grpc.ForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:23) ~[grpc-api-1.43.2.jar:1.43.2]
        at io.grpc.ForwardingServerCallListener$SimpleForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:40) ~[grpc-api-1.43.2.jar:1.43.2]
        at io.grpc.Contexts$ContextualizedServerCallListener.onHalfClose(Contexts.java:86) ~[grpc-api-1.43.2.jar:1.43.2]
        at io.grpc.PartialForwardingServerCallListener.onHalfClose(PartialForwardingServerCallListener.java:35) ~[grpc-api-1.43.2.jar:1.43.2]
        at io.grpc.ForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:23) ~[grpc-api-1.43.2.jar:1.43.2]
        at io.grpc.ForwardingServerCallListener$SimpleForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:40) ~[grpc-api-1.43.2.jar:1.43.2]
        at io.adven.grpc.wiremock.ExceptionHandler$ExceptionHandlingServerCallListener.onHalfClose(ExceptionHandler.java:42) ~[main/:na]
        at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:340) ~[grpc-core-1.43.2.jar:1.43.2]
        at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:866) ~[grpc-core-1.43.2.jar:1.43.2]
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) ~[grpc-core-1.43.2.jar:1.43.2]
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133) ~[grpc-core-1.43.2.jar:1.43.2]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
        at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]

Expected behavior
grpc-wiremock should not throw an exception if content-length field set in the request header.

Additional context
APISIX plugin gRPC-transcoder translates http json request to gRPC proto messages. It sets content-length after the conversion, so it triggers the exception.

Allow to configure http and grpc ports

Hey team!

Nice work on this one! A nice detail would be to allow the http and grpc ports to be configured from the env/command. The standard wiremock allows to override the command passing in the ports:

command: "--https-port 443 --port 9002"

Is this something we could look into?

Thanks!

Frail implementation of WireMock commandline parameters

Describe the bug

When running grpc-wiremock in kubernetes, certain environment variables will be added to the VM running gprc-wiremock. If a kubernetes service is defined with a name starting with wiremock, there will be a few env. variables passed through to the Wiremock HttpMock. (link) This results in the Wiremock HttpMock being unable to start - because of these invalid commandline parameters.

Is there a better way to handle the passing of wiremock commandline parameters?

To Reproduce
Steps to reproduce the behavior:

  1. Set up grpc-wiremock to run in kuberenetes, create a kubernetes service with name wiremock-x-y in the same namespace.
  2. Run kubernetes deployment of grpc-wiremock
  3. See error:
2022-02-21 07:47:14.202  INFO 88 --- [           main] io.adven.grpc.wiremock.HttpMock          : Starting WireMock server with options:
--x_y_internal_port_8080_tcp=tcp://127.0.0.1:8080
--x_y_internal_port=tcp://127.0.0.1:8080
--x_y_internal_port_8080_tcp_addr=127.0.0.1
--x_y_internal_port_8080_tcp_port=8080
--x_y_internal_service_host=127.0.0.1
--x_y_internal_port_8080_tcp_proto=tcp
--x_y_internal_service_port=8080
--global-response-templating
--root-dir=/wiremock
--port=8888
2022-02-21 07:47:14.223  INFO 88 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-02-21 07:47:14.316 ERROR 88 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalStateException: Failed to execute CommandLineRunner
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:770) ~[spring-boot-2.6.2.jar:2.6.2]
        at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:751) ~[spring-boot-2.6.2.jar:2.6.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:309) ~[spring-boot-2.6.2.jar:2.6.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.2.jar:2.6.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[spring-boot-2.6.2.jar:2.6.2]
        at io.adven.grpc.wiremock.GrpcWiremock.main(GrpcWiremock.java:132) ~[main/:na]
Caused by: joptsimple.UnrecognizedOptionException: psd2_sandbox_internal_port_8080_tcp is not a recognized option
        at joptsimple.OptionException.unrecognizedOption(OptionException.java:108) ~[wiremock-jre8-standalone-2.32.0.jar:na]
        at joptsimple.OptionParser.handleLongOptionToken(OptionParser.java:510) ~[wiremock-jre8-standalone-2.32.0.jar:na]
        at joptsimple.OptionParserState$2.handleArgument(OptionParserState.java:56) ~[wiremock-jre8-standalone-2.32.0.jar:na]
        at joptsimple.OptionParser.parse(OptionParser.java:396) ~[wiremock-jre8-standalone-2.32.0.jar:na]
        at com.github.tomakehurst.wiremock.standalone.CommandLineOptions.<init>(CommandLineOptions.java:342) ~[wiremock-jre8-standalone-2.32.0.jar:na]
        at io.adven.grpc.wiremock.HttpMock.start(HttpMock.java:44) ~[main/:na]
        at io.adven.grpc.wiremock.GrpcWiremock.run(GrpcWiremock.java:39) ~[main/:na]
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:767) ~[spring-boot-2.6.2.jar:2.6.2]
        ... 5 common frames omitted

2022-02-21 07:47:14.318  WARN 88 --- [           main] .s.c.a.CommonAnnotationBeanPostProcessor : Destroy method on bean with name 'httpMock' threw an exception: java.lang.NullPointerException: Cannot invoke "com.github.tomakehurst.wiremock.WireMockServer.stop()" because "this.server" is null


FAILURE: Build failed with an exception.

Expected behavior

grpc-wiremock should run.

Streaming multiple object as array

The example indicates that streaming is possible: but stream SearchTransactionResponse contains repeated TransactionResponse transactions in its response. And could contain at once - TransactionResponse stream. Is such an application possible? How?
For example proto:

service WalletService {
  rpc searchTransaction (SearchTransactionRequest) returns (stream TransactionResponse) {}
}
message TransactionResponse {
  uint64 id = 1;
  uint64 userId = 2;
  string currency = 3;
  common.proto.ProtoBigDecimal amount = 4;
  common.proto.ProtoTimestamp transaction_date = 5;
}

Json stub file may looks like:

"jsonBody": [
     {"id": 1, userId: "1", "currency":1}, 
     {"id": 2, userId: "2", "currency":2}
]

Why was the repository unavailable for a few days?

👋 Hi, I just wanted to inquire about the reason the repository was unavailable for a few days recently? My team was starting to use the image and ran into a couple of issues which we hoped to discuss the potential for PRs, but GH was responding with 404 for a few days...

We wanted to check whether that was by some accident and if we should consider contributing here, or working off our fork?

p.s. Thank you for making your work freely available. 🙏

INVALID_ARGUMENT: Failed to convert to class

Sample proto snapshot

package test.v1
import "google/protobuf/timestamp.proto";

option java_multiple_files = true;
option go_package = "testv1";
option java_package = "com.test.v1";
option java_outer_classname = "V1Proto";

message Employee {
string name = 1;
string id = 2;
google.protobuf.Timestamp time_stamp = 3;
}

Wiremock STUB - JSON body:
{"name":"test", "id":"test123", "time_stamp" : { "seconds":"1616782696" , "nanos":0 } }

Error in bloomRPC:
{
"error": "3 INVALID_ARGUMENT: Failed to convert { //////. to class something something
}

Build container with no tag or :latest is failed ( exec format error )

Cleaned all related images before building by

docker images --no-trunc|grep grpc-wiremock | awk '{ print $3 }' | xargs -r docker rmi

If I use in docker-compose

image: adven27/grpc-wiremock:latest

or

image: adven27/grpc-wiremock

it causes problem with starting container

Short log:

docker-compose -f dockerfiles/qa/docker-compose.yml up checker-mock
Pulling checker-mock (adven27/grpc-wiremock:)...
latest: Pulling from adven27/grpc-wiremock
80bc30679ac1: Pull complete
9bf18fab4cfb: Pull complete
5979309c983a: Pull complete
b6482171366c: Pull complete
7ff99fec0284: Pull complete
b87bb7d9adf8: Pull complete
743b23f2e08f: Pull complete
0822b81f3d07: Pull complete
0baa3d5c279a: Pull complete
2c6cc17784c8: Pull complete
4f4fb700ef54: Pull complete
Digest: sha256:4f6cb6aefe6abf458c686970cad7c7b78fe3057773f6a1c63b5a2557ca3bec3a
Status: Downloaded newer image for adven27/grpc-wiremock:latest
Recreating checker-mock ... done
Attaching to checker-mock
checker-mock                                     | standard_init_linux.go:228: exec user process caused: exec format error

Verbose log:

docker-compose --verbose -f dockerfiles/qa/docker-compose.yml up checker-mock
compose.config.config.find: Using configuration files: ./dockerfiles/qa/docker-compose.yml
docker.utils.config.find_config_file: Trying paths: ['/home/kgrushin/.docker/config.json', '/home/kgrushin/.dockercfg']
docker.utils.config.find_config_file: Found file at path: /home/kgrushin/.docker/config.json
docker.auth.load_config: Found 'auths' section
docker.auth.parse_auth: Auth data for registry.rtty.in is absent. Client might be using a credentials store instead.
docker.auth.load_config: Found 'credsStore' section
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.24/version HTTP/1.1" 200 829
compose.cli.command.get_client: docker-compose version 1.21.0, build unknown
docker-py version: 3.4.1
CPython version: 3.7.3
OpenSSL version: OpenSSL 1.1.1d  10 Sep 2019
compose.cli.command.get_client: Docker base_url: http+docker://localhost
compose.cli.command.get_client: Docker version: Platform={'Name': 'Docker Engine - Community'}, Components=[{'Name': 'Engine', 'Version': '20.10.8', 'Details': {'ApiVersion': '1.41', 'Arch': 'amd64', 'BuildTime': '2021-07-30T19:52:10.000000000+00:00', 'Experimental': 'false', 'GitCommit': '75249d8', 'GoVersion': 'go1.16.6', 'KernelVersion': '5.10.0-0.bpo.8-amd64', 'MinAPIVersion': '1.12', 'Os': 'linux'}}, {'Name': 'containerd', 'Version': '1.4.9', 'Details': {'GitCommit': 'e25210fe30a0a703442421b0f60afac609f950a3'}}, {'Name': 'runc', 'Version': '1.0.1', 'Details': {'GitCommit': 'v1.0.1-0-g4144b63'}}, {'Name': 'docker-init', 'Version': '0.19.0', 'Details': {'GitCommit': 'de40ad0'}}], Version=20.10.8, ApiVersion=1.41, MinAPIVersion=1.12, GitCommit=75249d8, GoVersion=go1.16.6, Os=linux, Arch=amd64, KernelVersion=5.10.0-0.bpo.8-amd64, BuildTime=2021-07-30T19:52:10.000000000+00:00
compose.cli.verbose_proxy.proxy_callable: docker info <- ()
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.24/info HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker info -> {'Architecture': 'x86_64',
 'BridgeNfIp6tables': True,
 'BridgeNfIptables': True,
 'CPUSet': True,
 'CPUShares': True,
 'CgroupDriver': 'cgroupfs',
 'CgroupVersion': '1',
 'ContainerdCommit': {'Expected': 'e25210fe30a0a703442421b0f60afac609f950a3',
                      'ID': 'e25210fe30a0a703442421b0f60afac609f950a3'},
 'Containers': 1,
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_network <- ('qa_pusher-test-network')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.24/networks/qa_pusher-test-network HTTP/1.1" 200 512
compose.cli.verbose_proxy.proxy_callable: docker inspect_network -> {'Attachable': True,
 'ConfigFrom': {'Network': ''},
 'ConfigOnly': False,
 'Containers': {},
 'Created': '2021-08-10T10:11:13.473870393+03:00',
 'Driver': 'bridge',
 'EnableIPv6': False,
 'IPAM': {'Config': [{'Subnet': '192.168.0.1/24'}],
          'Driver': 'default',
          'Options': None},
...
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=False, filters={'label': ['com.docker.compose.project=qa', 'com.docker.compose.oneoff=False']})
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.24/containers/json?limit=-1&all=0&size=0&trunc_cmd=0&filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dqa%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 3
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters={'label': ['com.docker.compose.project=qa', 'com.docker.compose.service=checker-mock', 'com.docker.compose.oneoff=False']})
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.24/containers/json?limit=-1&all=1&size=0&trunc_cmd=0&filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dqa%22%2C+%22com.docker.compose.service%3Dchecker-mock%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 1704
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 1 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('b26307e47287d1780ed2e0aa69ba6f3f7296e9850fff24f4e2990ddcedb913b7')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.24/containers/b26307e47287d1780ed2e0aa69ba6f3f7296e9850fff24f4e2990ddcedb913b7/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': 'docker-default',
 'Args': ['bootRun', '-i'],
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': None,
            'Domainname': '',
            'Entrypoint': ['gradle', 'bootRun', '-i'],
            'Env': ['affinity:container==cca8062ad98efe2563f5f35b2f10e9b20e85bed5763bad2a0e544885334d89be',
                    'PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('adven27/grpc-wiremock:latest')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.24/images/adven27/grpc-wiremock:latest/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {'Architecture': 'arm64',
 'Author': '',
 'Comment': 'buildkit.dockerfile.v0',
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': None,
            'Domainname': '',
            'Entrypoint': ['gradle', 'bootRun', '-i'],
            'Env': ['PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
...
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters={'label': ['com.docker.compose.project=qa', 'com.docker.compose.service=checker-mock', 'com.docker.compose.oneoff=False']})
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.24/containers/json?limit=-1&all=1&size=0&trunc_cmd=0&filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dqa%22%2C+%22com.docker.compose.service%3Dchecker-mock%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 1704
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 1 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('adven27/grpc-wiremock:latest')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.24/images/adven27/grpc-wiremock:latest/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {'Architecture': 'arm64',
 'Author': '',
 'Comment': 'buildkit.dockerfile.v0',
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': None,
            'Domainname': '',
            'Entrypoint': ['gradle', 'bootRun', '-i'],
            'Env': ['PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('b26307e47287d1780ed2e0aa69ba6f3f7296e9850fff24f4e2990ddcedb913b7')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.24/containers/b26307e47287d1780ed2e0aa69ba6f3f7296e9850fff24f4e2990ddcedb913b7/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': 'docker-default',
 'Args': ['bootRun', '-i'],
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': None,
            'Domainname': '',
            'Entrypoint': ['gradle', 'bootRun', '-i'],
            'Env': ['affinity:container==cca8062ad98efe2563f5f35b2f10e9b20e85bed5763bad2a0e544885334d89be',
                    'PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
...
compose.parallel.feed_queue: Pending: {<Service: checker-mock>}
compose.parallel.feed_queue: Starting producer thread for <Service: checker-mock>
Starting checker-mock ... 
compose.parallel.feed_queue: Pending: {<Container: checker-mock (b26307)>}
compose.parallel.feed_queue: Starting producer thread for <Container: checker-mock (b26307)>
compose.cli.verbose_proxy.proxy_callable: docker attach <- ('b26307e47287d1780ed2e0aa69ba6f3f7296e9850fff24f4e2990ddcedb913b7', stdout=True, stderr=True, stream=True)
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.24/containers/b26307e47287d1780ed2e0aa69ba6f3f7296e9850fff24f4e2990ddcedb913b7/attach?logs=0&stdout=1&stderr=1&stream=1 HTTP/1.1" 101 0
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.24/containers/b26307e47287d1780ed2e0aa69ba6f3f7296e9850fff24f4e2990ddcedb913b7/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker attach -> <docker.types.daemon.CancellableStream object at 0x7ff85560f470>
compose.cli.verbose_proxy.proxy_callable: docker start <- ('b26307e47287d1780ed2e0aa69ba6f3f7296e9850fff24f4e2990ddcedb913b7')
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.24/containers/b26307e47287d1780ed2e0aa69ba6f3f7296e9850fff24f4e2990ddcedb913b7/start HTTP/1.1" 204 0
compose.cli.verbose_proxy.proxy_callable: docker start -> None
Starting checker-mock ... done
compose.parallel.feed_queue: Pending: set()
compose.parallel.parallel_execute_iter: Finished processing: <Service: checker-mock>
compose.parallel.feed_queue: Pending: set()
Attaching to checker-mock
compose.cli.verbose_proxy.proxy_callable: docker events <- (filters={'label': ['com.docker.compose.project=qa', 'com.docker.compose.oneoff=False']}, decode=True)
checker-mock                                     | standard_init_linux.go:228: exec user process caused: exec format error
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.24/events?filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dqa%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker events -> <docker.types.daemon.CancellableStream object at 0x7ff85560cf98>
compose.cli.verbose_proxy.proxy_callable: docker wait <- ('b26307e47287d1780ed2e0aa69ba6f3f7296e9850fff24f4e2990ddcedb913b7')
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('b26307e47287d1780ed2e0aa69ba6f3f7296e9850fff24f4e2990ddcedb913b7')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.24/containers/b26307e47287d1780ed2e0aa69ba6f3f7296e9850fff24f4e2990ddcedb913b7/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': 'docker-default',
 'Args': ['bootRun', '-i'],
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': None,
            'Domainname': '',
            'Entrypoint': ['gradle', 'bootRun', '-i'],
            'Env': ['affinity:container==cca8062ad98efe2563f5f35b2f10e9b20e85bed5763bad2a0e544885334d89be',
                    'PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
...
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.24/containers/b26307e47287d1780ed2e0aa69ba6f3f7296e9850fff24f4e2990ddcedb913b7/wait HTTP/1.1" 200 30
compose.cli.verbose_proxy.proxy_callable: docker wait -> {'Error': None, 'StatusCode': 1}
checker-mock exited with code 1
uname -a
Linux debian 5.10.0-0.bpo.8-amd64 #1 SMP Debian 5.10.46-2~bpo10+1 (2021-07-22) x86_64 GNU/Linux
docker version
Client: Docker Engine - Community
 Version:           20.10.8
 API version:       1.41
 Go version:        go1.16.6
 Git commit:        3967b7d
 Built:             Fri Jul 30 19:54:02 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.8
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.6
  Git commit:       75249d8
  Built:            Fri Jul 30 19:52:10 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.9
  GitCommit:        e25210fe30a0a703442421b0f60afac609f950a3
 runc:
  Version:          1.0.1
  GitCommit:        v1.0.1-0-g4144b63
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker-compose

  checker-mock:
    image: adven27/grpc-wiremock:latest
    container_name: checker-mock
    ports:
      - "3333:50000" # grpc
      - "3336:8888" # http
    volumes:
      - ./volumes/proto/checker:/proto
      - ./volumes/wiremock/checker:/wiremock
    dns_search: .
    networks:
      - pusher-test-network

Mac M1 Chip

Error on build:

wiremock_1 | Watching 85 directories to track changes
wiremock_1 | Found grpc/health/v1/HealthGrpc.java:
wiremock_1 | Parsed package = [grpc.health.v1], serviceName = [Health] and fullServiceName = [GrpcHealthV1Health]
wiremock_1 | Found io/deliveryhero/proto/supplier_invoice_module/deliveryreceipt/v4/DeliveryReceiptServiceGrpc.java:
wiremock_1 | Parsed package = [io.deliveryhero.proto.supplier_invoice_module.deliveryreceipt.v4], serviceName = [DeliveryReceiptService] and fullServiceName = [IoDeliveryheroProtoSupplierInvoiceModuleDeliveryreceiptV4DeliveryReceiptService]
wiremock_1 | Found purchase_orders/v1/PurchaseOrdersGrpc.java:
wiremock_1 | Parsed package = [purchase_orders.v1], serviceName = [PurchaseOrdersGrpc.java] and fullServiceName = [PurchaseOrdersV1PurchaseOrdersGrpc.java]
wiremock_1 | Found purchase_orders/v1/ReturnsGrpc.java:
wiremock_1 | Parsed package = [purchase_orders.v1], serviceName = [Returns] and fullServiceName = [PurchaseOrdersV1Returns]
wiremock_1 | Found settings/v1/FlagsGrpc.java:
wiremock_1 | Parsed package = [settings.v1], serviceName = [Flags] and fullServiceName = [SettingsV1Flags]
wiremock_1 | Found supplier_portal/supplier/v2/SupplierServiceGrpc.java:
wiremock_1 | Parsed package = [supplier_portal.supplier.v2], serviceName = [SupplierServiceGrpc.java] and fullServiceName = [SupplierPortalSupplierV2SupplierServiceGrpc.java]
wiremock_1 | Found supplier_portal/v1/productpb/ProductServiceGrpc.java:
wiremock_1 | Parsed package = [supplier_portal.v1.productpb], serviceName = [ProductServiceGrpc.java] and fullServiceName = [SupplierPortalV1ProductpbProductServiceGrpc.java]
wiremock_1 | Found supplier_portal/v1/supplierpb/SupplierServiceGrpc.java:
wiremock_1 | Parsed package = [supplier_portal.v1.supplierpb], serviceName = [SupplierServiceGrpc.java] and fullServiceName = [SupplierPortalV1SupplierpbSupplierServiceGrpc.java]
wiremock_1 | Found wac/v1/WacGrpc.java:
wiremock_1 | Parsed package = [wac.v1], serviceName = [Wac] and fullServiceName = [WacV1Wac]
wiremock_1 | Found wac/v2/WacGrpc.java:
wiremock_1 | Parsed package = [wac.v2], serviceName = [Wac] and fullServiceName = [WacV2Wac]
wiremock_1 | Watching 89 directories to track changes
wiremock_1 | :generateJava (Thread[Execution worker for ':' Thread 3,5,main]) completed. Took 1.122 secs.
wiremock_1 | :compileJava (Thread[Execution worker for ':',5,main]) started.
wiremock_1 |
wiremock_1 | > Task :compileJava
wiremock_1 | Excluding []
wiremock_1 | Watching 90 directories to track changes
wiremock_1 | Watching 90 directories to track changes
wiremock_1 | Watching 90 directories to track changes
wiremock_1 | Watching 91 directories to track changes
wiremock_1 | Caching disabled for task ':compileJava' because:
wiremock_1 | Build cache is disabled
wiremock_1 | Task ':compileJava' is not up-to-date because:
wiremock_1 | No history is available.
wiremock_1 | Watching 91 directories to track changes
wiremock_1 | Watching 91 directories to track changes
wiremock_1 | Watching 90 directories to track changes
wiremock_1 | The input changes require a full rebuild for incremental task ':compileJava'.
wiremock_1 | Full recompilation is required because no incremental change information is available. This is usually caused by clean builds or changing compiler arguments.
wiremock_1 | Compiling with toolchain '/opt/java/openjdk'.
wiremock_1 | Compiling with JDK Java compiler API.
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:15: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:15: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:15: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:15: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:15: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:15: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:16: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.DeliveryReceiptServiceGrpc.DeliveryReceiptServiceImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:16: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.DeliveryReceiptServiceGrpc.DeliveryReceiptServiceImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:16: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @package@.DeliveryReceiptServiceGrpc.DeliveryReceiptServiceImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:16: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.DeliveryReceiptServiceGrpc.DeliveryReceiptServiceImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:16: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.DeliveryReceiptServiceGrpc.DeliveryReceiptServiceImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:16: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @package@.DeliveryReceiptServiceGrpc.DeliveryReceiptServiceImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:17: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.PurchaseOrdersGrpc.javaGrpc.PurchaseOrdersGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:17: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.PurchaseOrdersGrpc.javaGrpc.PurchaseOrdersGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:17: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @package@.PurchaseOrdersGrpc.javaGrpc.PurchaseOrdersGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:17: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.PurchaseOrdersGrpc.javaGrpc.PurchaseOrdersGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:17: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.PurchaseOrdersGrpc.javaGrpc.PurchaseOrdersGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:17: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @package@.PurchaseOrdersGrpc.javaGrpc.PurchaseOrdersGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:18: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:18: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:18: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:18: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:18: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:18: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:19: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:19: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:19: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:19: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:19: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:19: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:20: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.SupplierServiceGrpc.javaGrpc.SupplierServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:20: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.SupplierServiceGrpc.javaGrpc.SupplierServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:20: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @package@.SupplierServiceGrpc.javaGrpc.SupplierServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:20: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.SupplierServiceGrpc.javaGrpc.SupplierServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:20: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.SupplierServiceGrpc.javaGrpc.SupplierServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:20: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @package@.SupplierServiceGrpc.javaGrpc.SupplierServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:21: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.ProductServiceGrpc.javaGrpc.ProductServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:21: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.ProductServiceGrpc.javaGrpc.ProductServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:21: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @package@.ProductServiceGrpc.javaGrpc.ProductServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:21: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.ProductServiceGrpc.javaGrpc.ProductServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:21: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.ProductServiceGrpc.javaGrpc.ProductServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:21: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @package@.ProductServiceGrpc.javaGrpc.ProductServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:22: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.SupplierServiceGrpc.javaGrpc.SupplierServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:22: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.SupplierServiceGrpc.javaGrpc.SupplierServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:22: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @package@.SupplierServiceGrpc.javaGrpc.SupplierServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:22: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.SupplierServiceGrpc.javaGrpc.SupplierServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:22: error: expected
wiremock_1 | @service class @fullServiceName@ extends @package@.SupplierServiceGrpc.javaGrpc.SupplierServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:22: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @package@.SupplierServiceGrpc.javaGrpc.SupplierServiceGrpc.javaImplBase {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:23: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:23: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:23: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:23: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:23: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:23: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:24: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:24: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:24: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:24: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:24: error: expected
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:24: error: illegal start of type
wiremock_1 | @service class @fullServiceName@ extends @[email protected] {}
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:42: error: expected
wiremock_1 | @decorate_services@
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:43: error: illegal start of type
wiremock_1 | }
wiremock_1 | ^
wiremock_1 | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:44: error: reached end of file while parsing
wiremock_1 | }
wiremock_1 | ^
wiremock_1 | 63 errors
wiremock_1 | Watching 92 directories to track changes
wiremock_1 | Watching 94 directories to track changes
wiremock_1 | Watching 96 directories to track changes
wiremock_1 |
wiremock_1 | > Task :compileJava FAILED
wiremock_1 | :compileJava (Thread[Execution worker for ':',5,main]) completed. Took 6.333 secs.
wiremock_1 |
wiremock_1 | FAILURE: Build failed with an exception.
wiremock_1 |
wiremock_1 | * What went wrong:
wiremock_1 | Execution failed for task ':compileJava'.
wiremock_1 | > Compilation failed; see the compiler error output for details.
wiremock_1 |
wiremock_1 | * Try:
wiremock_1 | Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.
wiremock_1 |
wiremock_1 | * Get more help at https://help.gradle.org
wiremock_1 |
wiremock_1 | BUILD FAILED in 53s
wiremock_1 | 5 actionable tasks: 5 executed
wiremock_1 | Not watching anything anymore
wiremock_1 | Watching 0 directories to track changes
wiremock_1 | Some of the file system contents retained in the virtual file system are on file systems that Gradle doesn't support watching. The relevant state was discarded to ensure changes to these locations are properly detected. You can override this by explicitly enabling file system watching.
wiremock_1 | Watching 0 directories to track changes
wiremock_1 exited with code 1

package not found.

Suddenly I am getting this error

wiremock_1  | Task ':generateJava' is not up-to-date because:
wiremock_1  |   No history is available.
wiremock_1  | Found :generateJava: 
wiremock_1  | Parsed package = [grpc.health.v1] and service = [Health]
wiremock_1  | Found :generateJava: 
.
.
.
wiremock_1                | Compiling with JDK Java compiler API.
wiremock_1                | /usr/src/java-code/src/main/java/io/adven/grpc/wiremock/Translator.java:12: error: package grpc.health.v1 does not exist
wiremock_1                | import grpc.health.v1.HealthGrpc;

Did any new change went live?

'Cannot find type for url' error for items of google.protobuf.Any type

Description

How Any type is handled, as I have issues to get it working.
I have offer_item, that is defined as

message OfferItem {
  google.protobuf.Any offer_item = 1;
}

But got errors related to finding class referenced from that item.

Message being sent:

grpcurl -plaintext -import-path ./protos -proto stub/offer/proto/OfferSvc.proto -d '
{
  "offer_id": "newoffer001",
  "ttl": { "seconds": 900 },
  "offer_to_add": {
    "offer_items": [
      {
        "offer_item": {
          "value": "newoffer001",
          "@type": "type.googleapis.com/google.protobuf.StringValue"
        }
      }
    ]
  }
}' localhost:50000 stub.offer.proto.OfferSvc/addOffer

From logs I got:

Message:
offer_id: "newoffer001"
ttl {
  seconds: 900
}
offer_to_add {
  offer_items {
    offer_item {
      type_url: "type.googleapis.com/google.protobuf.StringValue"
      value: "\n\032newoffer001"
    }
  }
}

And exception stack:

Caused by: com.google.protobuf.InvalidProtocolBufferException: Cannot find type for url: type.googleapis.com/google.protobuf.StringValue
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printAny(JsonFormat.java:886) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.access$1000(JsonFormat.java:714) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl$1.print(JsonFormat.java:787) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:766) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printSingleFieldValue(JsonFormat.java:1263) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printSingleFieldValue(JsonFormat.java:1128) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printField(JsonFormat.java:1052) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:1030) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:769) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printSingleFieldValue(JsonFormat.java:1263) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printSingleFieldValue(JsonFormat.java:1128) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printRepeatedFieldValue(JsonFormat.java:1066) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printField(JsonFormat.java:1050) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:1030) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:769) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printSingleFieldValue(JsonFormat.java:1263) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printSingleFieldValue(JsonFormat.java:1128) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.printField(JsonFormat.java:1052) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:1030) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:769) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$Printer.appendTo(JsonFormat.java:372) ~[protobuf-java-util-3.19.2.jar:na]
        at com.google.protobuf.util.JsonFormat$Printer.print(JsonFormat.java:382) ~[protobuf-java-util-3.19.2.jar:na]

Though, when on container, it looks like StringValue is there:

/usr/src/java-code/build/classes# find . | grep String
./java/main/com/google/protobuf/StringValueOrBuilder.class
./java/main/com/google/protobuf/StringValue$1.class
./java/main/com/google/protobuf/StringValue$Builder.class
./java/main/com/google/protobuf/StringValue.class

Is this code issue, or I need to make corrections in test set or mock configuration to make it working?

Handle compilation errors when protobuf message ends with Grpc

Describe the bug
A clear and concise description of what the bug is.

The grpc-wiremock tool assumes that in the generated code from the protobuf messages, only service classes would have its name end with Grpc.java. But a user can still end up defining a message which ends with Grpc. So when a message ends with Grpc, the tool ends up assuming that the message class is a service class and ends up adding a reference to the abstract ImplBase for it which does not exist.

To Reproduce
Steps to reproduce the behavior:

  1. Use the below .proto file
syntax="proto3";
package com.rationaleemotions;

option java_multiple_files=true;

message InputGrpc {
    string name = 1;
}

message OutputGrpc {
    string message = 1;
}

service HelloWorld {
    rpc greetUser (InputGrpc) returns (OutputGrpc);
}
  1. Add a reference to the above proto file directory in the build.gradle and then run ./gradlew clean generateJava
  2. Now from within the IDE, open up the generated Java class src/main/java/io/adven/grpc/wiremock/Translator.java
  3. You will see the below mentioned problematic lines
@Service class ComRationaleemotionsHelloWorld extends com.rationaleemotions.HelloWorldGrpc.HelloWorldImplBase {}
@Service class ComRationaleemotionsInput extends com.rationaleemotions.InputGrpc.InputImplBase {}
@Service class ComRationaleemotionsOutput extends com.rationaleemotions.OutputGrpc.OutputImplBase {}

In the above generated code, only HelloWorldGrpc is a valid service class and so HelloWorldImplBase exists inside it. But this is not the case with InputGrpc and OutputGrpc

Expected behavior

The tool should not just rely on file names to distinguish service classes from message classes but it should be able to skip such ambiguous message classes that look like a service class based on file name.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Allow preserving proto field names before checking mappings

Is your feature request related to a problem? Please describe.

Using grpc-wiremock we have noticed that mappings must have request in lowerCamlCase. This is due to the following code:

static String toJson(MessageOrBuilder messageOrBuilder) throws IOException {
return JsonFormat.printer().print(messageOrBuilder);
}

There, JsonFormat default printer is used, which by default convert names to lowerCamelCase.

Describe the solution you'd like

To allow preserving proto field names

JsonFormat.preservingProtoFieldNames().printer()

should be called instead of

JsonFormat.printer()

So the solution proposed is to leave the current behavior as it is and, depending on an environment variable that could be set in the container, use the "preservingProtoFieldNames" printer. This way, both approaches could be used.

Describe alternatives you've considered
Nothing. If not done we must define requests in lowerCamlCase

Additional context

No further actions needed in the response, because no matter the mapping is lowerCamlCase or snake_case, it is converted right into snake_case for protos:

try {
LOG.info("Converting to {} json:\n{}", clazz, json);
AbstractMessage.Builder builder = (AbstractMessage.Builder) clazz.getMethod("newBuilder").invoke(null);
JsonFormat.parser().merge(json, builder);
T result = (T) builder.build();
LOG.info("Grpc response:\n{}", result);
return result;
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | InvalidProtocolBufferException e) {
throw new IllegalArgumentException("Failed to convert " + json + " to " + clazz, e);
}

GRPC -bin header unmarshalling

Error processing request headers


ERROR 124 --- [ault-executor-0] io.grpc.internal.SerializingExecutor     : Exception while executing runnable io.grpc.internal.ServerImpl$ServerTransportListenerImpl$1HandleServerCall@494a7ef5

java.lang.IllegalStateException: java.lang.IllegalArgumentException: ASCII header is named grpc-tags-bin.  Only binary headers may end with -bin
	at io.grpc.internal.ServerImpl$ServerTransportListenerImpl$1HandleServerCall.runInternal(ServerImpl.java:619) ~[grpc-core-1.41.0.jar:1.41.0]
	at io.grpc.internal.ServerImpl$ServerTransportListenerImpl$1HandleServerCall.runInContext(ServerImpl.java:603) ~[grpc-core-1.41.0.jar:1.41.0]
	at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) ~[grpc-core-1.41.0.jar:1.41.0]
	at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133) ~[grpc-core-1.41.0.jar:1.41.0]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
	at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]
Caused by: java.lang.IllegalArgumentException: ASCII header is named grpc-tags-bin.  Only binary headers may end with -bin
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:444) ~[guava-30.1-android.jar:na]
	at io.grpc.Metadata$AsciiKey.<init>(Metadata.java:960) ~[grpc-api-1.41.0.jar:1.41.0]
	at io.grpc.Metadata$AsciiKey.<init>(Metadata.java:954) ~[grpc-api-1.41.0.jar:1.41.0]
	at io.grpc.Metadata$Key.of(Metadata.java:705) ~[grpc-api-1.41.0.jar:1.41.0]
	at io.grpc.Metadata$Key.of(Metadata.java:701) ~[grpc-api-1.41.0.jar:1.41.0]
	at io.adven.grpc.wiremock.HeaderPropagationInterceptor.lambda$asMap$0(HeaderPropagationInterceptor.java:31) ~[main/:na]
	at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:178) ~[na:na]
	at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169) ~[na:na]
	at java.base/java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1603) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
	at io.adven.grpc.wiremock.HeaderPropagationInterceptor.asMap(HeaderPropagationInterceptor.java:31) ~[main/:na]
	at io.adven.grpc.wiremock.HeaderPropagationInterceptor.interceptCall(HeaderPropagationInterceptor.java:23) ~[main/:na]
	at io.grpc.ServerInterceptors$InterceptCallHandler.startCall(ServerInterceptors.java:244) ~[grpc-api-1.41.0.jar:1.41.0]
	at io.adven.grpc.wiremock.ExceptionHandler.interceptCall(ExceptionHandler.java:22) ~[main/:na]
	at io.grpc.ServerInterceptors$InterceptCallHandler.startCall(ServerInterceptors.java:244) ~[grpc-api-1.41.0.jar:1.41.0]
	at io.grpc.internal.ServerImpl$ServerTransportListenerImpl.startWrappedCall(ServerImpl.java:703) ~[grpc-core-1.41.0.jar:1.41.0]
	at io.grpc.internal.ServerImpl$ServerTransportListenerImpl.access$2200(ServerImpl.java:406) ~[grpc-core-1.41.0.jar:1.41.0]
	at io.grpc.internal.ServerImpl$ServerTransportListenerImpl$1HandleServerCall.runInternal(ServerImpl.java:615) ~[grpc-core-1.41.0.jar:1.41.0]
	... 6 common frames omitted

Steps to reproduce the behavior:

  1. Reproduced on release including and after 1.2.1
  2. GRPC microservice send request with commonly used header grpc-tags-bin
  3. Error in logs grpc-wiremock: ASCII header is named grpc-tags-bin. Only binary headers may end with -bin

Expected behavior
Processing request including headers like grpc-tags-bin

Add license

Hi there! Can you clarify the licensing of this project, possibly by adding a LICENSE file in the repository? Without it, nobody can use it or contribute to it.

For reference: https://choosealicense.com/no-permission/

When you make a creative work (which includes code), the work is under exclusive copyright by default. Unless you include a license that specifies otherwise, nobody else can copy, distribute, or modify your work without being at risk of take-downs, shake-downs, or litigation. Once the work has other contributors (each a copyright holder), “nobody” starts including you.

How to connect to wiremock server instance to add mappings?

Hi,
let's say I don't want to add mappings on start of the docker container by using "-v $(pwd)/example/wiremock:/wiremock" but i would rather add mappings dynamically from code.

I have a wiremock server running on localhost:8888, if I hit http://localhost:8888/__admin/mappings from my browser I can see there are no mappings

{ "mappings" : [ ], "meta" : { "total" : 0 } }

I would like to add some mappings now so I am using the following code (first I am trying to fetch existing mappings expecting an empty list)

[Test]
        public async Task Test1()
        {
            // Create an implementation of the IWireMockAdminApi and pass in the base URL for the API.
            var api = RestClient.For<IWireMockAdminApi>("http://localhost:8888");

            var mappings = await api.GetMappingsAsync();
            Console.WriteLine($"mappings = {JsonConvert.SerializeObject(mappings)}");
        }

The above code fails on

Newtonsoft.Json.JsonSerializationException : Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.IList`1[WireMock.Admin.Mappings.MappingModel]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'mappings', line 2, position 14.

   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at RestEase.JsonResponseDeserializer.Deserialize[T](String content, HttpResponseMessage response, ResponseDeserializerInfo info)
   at RestEase.Implementation.Requester.Deserialize[T](String content, HttpResponseMessage response, IRequestInfo requestInfo)
   at RestEase.Implementation.Requester.RequestAsync[T](IRequestInfo requestInfo)
   at WireMockTest.Tests.Setup() in /Users/martinco/Work/WireMockTest/WireMockTest/WireMockTest/UnitTest1.cs:line 26
   at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
   at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaitable)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, MethodInfo method)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUp(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.SetUpTearDownCommand.<>c__DisplayClass0_0.<.ctor>b__0(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeAndAfterTestCommand.<>c__DisplayClass1_0.<Execute>b__0()
   at NUnit.Framework.Internal.Commands.BeforeAndAfterTestCommand.RunTestMethodInThreadAbortSafeZone(TestExecutionContext context, Action action)

csproj details

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NUnit" Version="3.12.0" />
    <PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
    <PackageReference Include="WireMock.Net.RestClient" Version="1.4.5" />
    <PackageReference Include="WireMock.Net.Abstractions" Version="1.4.5" />
  </ItemGroup>

</Project>

I tried other methods such as GetSettingsAsync() with the same result.
What I am missing here please? The documentation says, it uses wrapper around Wiremock server so I assume WireMock.Net.RestClient should work?

Thanks for clarification in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.