Hello, team! I am working in an enterprise environ...
# protobufs
k
Hello, team! I am working in an enterprise environment with many teams, communicating over Kafka, using extensive and deeply nested protobufs and am trying to evaluate how difficult it would be to get Pact working with the existing stack. So I installed the pact-protobuf-plugin using the pact-plugin-cli, and can confirm that the plugin
protobuf-0.1.17
was added to my
.pact/plugins
folder. However, running the example consumer tests from the
pact-plugins
repo results in the following error (for the test consumeInitPluginMessage):
Copy code
Failed to resolve parameter [au.com.dius.pact.core.model.V4Interaction$AsynchronousMessage arg0] in method [void io.pact.example.protobuf.provider.PactConsumerTest.consumeInitPluginMessage(au.com.dius.pact.core.model.V4Interaction$AsynchronousMessage) throws com.google.protobuf.InvalidProtocolBufferException]: Plugin protobuf with version any was not found
Is the protobuf plugin from pactflow incompatible with the tests in the pact-foundation pact-plugins examples? The Readme in pact-protobuf-plugin lists it as its JVM example. Apologies in advance if I’ve missed some critical setup step. Any help is appreciated.
y
Hey @Krishna Mohan Elluru, It should work fine with the examples in the pact-plugin repo, there are some tests there, which are tested cross platform. Which OS are you running? is there any more logs from your consumer test, if you set it to debug level, as to the directory the plugins are expected to be loaded from. I assume they were installed to your home folder, when installed with the pact-plugin-cli
It is probably something simple, or something we need to fix, probably the former, so no need to apologise 🙂
k
I am using MAC with Intellij
I am just using the example script given in pact-protobuf-plugin to test if I can integrate my tests yet Yousaf.
[INFO] [INFO] Results: [INFO] [ERROR] Failures: [ERROR] MessageTransformerProducerPactProtoCTest The following methods annotated with @Pact were not executed during the test: MessageTransformerProducerPactProtoCTest.initPluginMessage If these are currently a work in progress, add a @Disabled annotation to the method [ERROR] Errors: [ERROR] MessageTransformerProducerPactProtoCTest.consumeConfigureInteractionResponseMessage:101 » InvalidWireType Protocol message tag had invalid wire type. [ERROR] MessageTransformerProducerPactProtoCTest.consumeInitPluginMessage(V4Interaction$AsynchronousMessage) » ParameterResolution Failed to resolve parameter [au.com.dius.pact.core.model.V4Interaction$AsynchronousMessage arg0] in method [void com.hpe.gravity.cx.ctests.MessageTransformerProducerPactProtoCTest.consumeInitPluginMessage(au.com.dius.pact.core.model.V4Interaction$AsynchronousMessage) throws com.google.protobuf.InvalidProtocolBufferException]: Plugin protobuf with version any was not found
y
np, I am running on a mac m1 too, I didn't use an editor to run the tests, just ran the example with
./gradle check
k
I am using maven, FYI.
y
are you able to run this example on your machine ? https://github.com/pact-foundation/pact-plugins/tree/main/examples/protobuf it uses gradle, just to confirm that the plugin can load, and run the example on your machine. If that does, then we narrow down to maven and look at the setup
k
have added
Copy code
<plugin>
    <groupId>au.com.dius.pact.provider</groupId>
    <artifactId>maven</artifactId>
    <version>4.1.11</version>
</plugin>
as per the steps mentioned in the link and using it
y
Can you check if the repo works as is though
k
installing gradle now. i didn’t had it till now.
y
no worries buddy! I am not sure how to convert from a gradle to a maven project, been so long since I have created java apps from scratch, but happy to help get a maven example rocking for you and others benefit. At least this will hopefully rule out communicating with the plugin as per the example with gradle, and then we can look at creating a maven example in the repo to test out. If you could share a fork with the changes to the project too, I can happily pull it down and take a look 🙂
k
Thanks for considering the same Yousaf. I am quickly checking with gradle compilation now. Will upload changes tomorrow as it is already 11PM for me 🙂.
🙌 1
krishnamohanelluru@Krishnas-MacBook-Pro protobuf-consumer-jvm % ./gradlew check
FAILURE: Build failed with an exception. * Where: Settings file ‘/Users/krishnamohanelluru/pact/pact-plugins/examples/protobuf/protobuf-consumer-jvm/settings.gradle’ * What went wrong: Could not compile settings file ‘/Users/krishnamohanelluru/pact/pact-plugins/examples/protobuf/protobuf-consumer-jvm/settings.gradle’.
startup failed:
General error during semantic analysis: Unsupported class file major version 62 java.lang.IllegalArgumentException: Unsupported class file major version 62 at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:196) at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:177) at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:163) at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:284) at org.codehaus.groovy.ast.decompiled.AsmDecompiler.parseClass(AsmDecompiler.java:81) at org.codehaus.groovy.control.ClassNodeResolver.findDecompiled(ClassNodeResolver.java:251)
gradle --version ------------------------------------------------------------ Gradle 7.5.1 ------------------------------------------------------------ Build time: 2022-08-05 211756 UTC Revision: d1daa0cbf1a0103000b71484e1dbfe096e095918 Kotlin: 1.6.21 Groovy: 3.0.10 Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021 JVM: 17.0.5 (Homebrew 17.0.5+0) OS: Mac OS X 12.6.1 x86_64 krishnamohanelluru@Krishnas-MacBook-Pro protobuf-consumer-jvm %
@Yousaf Nabi (pactflow.io) are these settings okay? Am I missing any element here to compile?
y
I get that if I am on the wrong java version, believe that example runs with java 11, which I am running on my machine, and it pulls down in CI https://github.com/pact-foundation/pact-plugins/blob/main/.github/workflows/examples.yml#L82
1
No problem, has a great night Krishna. I think setting Java 11 will cure your gradle issue. We will see if we can sort you out a maven example. And check if we are hard restricted to Java 11 or if you can run later versions. What version is the app you wish to target using?
k
we are planning to use java17 or java18 Yousaf.
Thank you Uglyog., Will there be any hard dependency on java version? I will check anyways.
u
Should work with any Java version 11+
k
Copy code
Getting the same error like before Uglyog. 

trace_id= span_id= 2022-11-24 02:20:00.744 GMT-08:00 [main] [ERROR] i.p.p.jvm.core.DefaultPluginManager [PluginManager.kt:525] [] - Init call to plugin protobuf failed
java.lang.RuntimeException: java.lang.NoClassDefFoundError: io/netty/channel/ChannelFactory
	at io.pact.plugins.jvm.core.Utils.handleWith(Util.kt:46)
	at io.pact.plugins.jvm.core.DefaultPluginManager.initialisePlugin(PluginManager.kt:513)
	at io.pact.plugins.jvm.core.DefaultPluginManager.loadPlugin(PluginManager.kt:290)
	at au.com.dius.pact.consumer.dsl.PactBuilder.usingPlugin(PactBuilder.kt:96)
	at au.com.dius.pact.consumer.dsl.PactBuilder.usingPlugin$default(PactBuilder.kt:93)
	at au.com.dius.pact.consumer.dsl.PactBuilder.usingPlugin(PactBuilder.kt)
	at com.hpe.gravity.cx.ctests.MessageTransformerConsumerPactProtoCTest.initPluginMessage(MessageTransformerConsumerPactProtoCTest.java:30)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)


trace_id= span_id= 2022-11-24 02:20:00.747 GMT-08:00 [main] [ERROR] a.c.d.pact.consumer.dsl.PactBuilder [PactBuilder.kt:99] [] - Init call to plugin protobuf failed: java.lang.RuntimeException: java.lang.NoClassDefFoundError: io/netty/channel/ChannelFactory
trace_id= span_id= 2022-11-24 02:20:00.753 GMT-08:00 [Thread-4] [WARN] a.com.dius.pact.core.support.Metrics [Metrics.kt:88] [] - 
            Please note: we are tracking events anonymously to gather important usage statistics like JVM version
            and operating system. To disable tracking, set the 'pact_do_not_track' system property or environment
            variable to 'true'.
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
	at org.junit.platform.commons.support.ReflectionSupport.invokeMethod(ReflectionSupport.java:198)
	at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.lookupPact(PactConsumerTestExt.kt:387)
if I run using mvn test is passing. I think the issue is with intellij app from my MAC..
HI @uglyog @Yousaf Nabi (pactflow.io) tried creating a fresh project with the settings given in maven example, facing the error with java17.. consumeConfigureInteractionResponseMessage{AsynchronousMessage} Time elapsed: 0.124 s <<< ERROR! org.junit.jupiter.api.extension.ParameterResolutionException: Failed to resolve parameter [au.com.dius.pact.core.model.V4Interaction$AsynchronousMessage message] in method [void com.pact.maven.MavenContractTests.consumeConfigureInteractionResponseMessage(au.com.dius.pact.core.model.V4Interaction$AsynchronousMessage) throws com.google.protobuf.InvalidProtocolBufferException]: Failed to set the interaction: Failed to process protobuf: Failed to invoke protoc binary: exit code exit status: 1 at com.pact.maven.MavenContractTests.configureInteractionResponseMessage(MavenContractTests.java:57)
u
Failed to invoke protoc binary: exit code exit status: 1
means it can't run the Protobuf compiler. What OS are you running with? Is it running within docker with Alpine Linux?
k
mac
u
mac M1 or Intel?
k
intel
u
what plugin version are you using?
k
you mean protobuf plugin or protoc?
u
protobuf plugin
k
0.1.17
u
What do you get if you run
~/.pact/plugins/protobuf-0.1.17/protoc/bin/protoc --version
k
~/.pact/plugins/protobuf-0.1.17/protoc/bin/protoc --version libprotoc 3.19.1 krishnamohanelluru@Krishnas-MacBook-Pro protobuf-provider %
u
Hmm, that is working ok
can you provide the plugin logs? You may need to enable debug logs in the test
k
okay..
2022-11-25T094704.997+05:30 WARN 9816 --- [ main] i.p.p.j.core.DefaultPactPluginManifest : args field in plugin manifest is invalid this error rings any bell Uglyog?
u
No. Have you edited the plugin manifest?
k
no. I didn’t.
u
What is in the plugin manifest?
k
I don’t think I have seen any manifest file
095432.431 [grpc-nio-worker-ELG-1-5] DEBUG io.grpc.netty.NettyClientHandler - [id: 0xfc6f1942, L/127.0.0.151654 - R/127.0.0.151651] OUTBOUND PING: ack=false bytes=1234 095432.431 [grpc-nio-worker-ELG-1-5] DEBUG io.grpc.netty.NettyClientHandler - [id: 0xfc6f1942, L/127.0.0.151654 - R/127.0.0.151651] INBOUND HEADERS: streamId=9 headers=GrpcHttp2ResponseHeaders[grpc-status: 0] padding=0 endStream=true 095432.432 [main] DEBUG io.pact.plugins.jvm.core.DefaultPluginManager - Got response: error: “Failed to process protobuf: Failed to invoke protoc binary: exit code exit status: 1”
u
what is in
~/.pact/plugins/protobuf-0.1.17/pact-plugin.json
k
{“pluginInterfaceVersion”1,“name”“protobuf”,“version”“0.1.17”,“executableType”“exec”,“minimumRequiredVersion”null,“entryPoint”“pact-protobuf-plugin”,“entryPoints”{},“args”null,“dependencies”null,“pluginConfig”{“protocVersion”:“3.19.1",“hostToBindTo”:“127.0.0.1",“downloadUrl”:“https://github.com/protocolbuffers/protobuf/releases/download”}}*%*
u
k
I think, I found the problem for the error. I had made incorrect path reference to proto, found it from logs and fixed it. now able to compile. Sorry for the false Alarm Uglyog..
👍 1
do we need to fix the error message, as it is mis-directing?
u
Which error are you referring to?
This one?
Got response: error: "Failed to process protobuf: Failed to invoke protoc binary: exit code exit status: 1"
k
yes.
it should probably highlight that file not found?
u
Makes sense