-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Environment
- Java: JDK 21
- Pact version: 4.6.17 (as seen in generated contract)
- Pact protobuf plugin: 0.5.4 and 0.6.5 (tested both versions)
- OS: macOS
- protoc: 32.0
Issue description
I'm experiencing inconsistent behavior with the Pact protobuf plugin for gRPC contract testing. The plugin appears to fail initialization with connection errors, but the test still passes and generates a contract file.
Specific errors in logs:
12:18:19.177 [main] WARN io.pact.plugins.jvm.core.PluginManager -- args field in plugin manifest is invalid
12:18:19.413 [main] ERROR io.pact.plugins.jvm.core.PluginManager -- Failed to initialise the plugin
io.grpc.StatusRuntimeException: UNAVAILABLE: io exception
Root cause:
Caused by: io.grpc.netty.shaded.io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /[0:0:0:0:0:0:0:1]:63110
Caused by: java.net.ConnectException: Connection refused
Observed Behavior
The strange part is:
- The logs clearly show that the plugin fails to initialize with connection errors
- Multiple attempts to connect to localhost ports (63110, 63113) are refused
- Despite these errors, the test completes successfully and the contract file is generated
- The generated contract appears to be valid and contains all the expected elements (service definitions, message formats, etc.)
This seems inconsistent with the error messages. I would expect the test to fail if the plugin cannot initialize, but it appears to be working differently.
Test Code Sample
Here's a simplified example showing the test setup:
Consumer Test
@ExtendWith(PactConsumerTestExt.class)
@PactTestFor(
providerName = "area-calculator-provider",
providerType = ProviderType.SYNCH_MESSAGE,
pactVersion = PactSpecVersion.V4
)
@PactDirectory("target/pacts")
public class PactConsumerTest {
@Pact(consumer = "grpc-consumer-jvm")
V4Pact calculateRectangleArea(PactBuilder builder) {
return builder
.usingPlugin("protobuf")
.expectsToReceive("calculate rectangle area request", "core/interaction/synchronous-message")
.with(Map.of(
"pact:proto", filePath("proto/area_calculator.proto"),
"pact:content-type", "application/grpc",
"pact:proto-service", "Calculator/calculateOne",
"request", Map.of(
"rectangle", Map.of("length", 3, "width", 4)
),
"response", List.of(Map.of(
"value", List.of(12)
))
))
.toPact();
}
@Test
@PactTestFor(pactMethod = "calculateRectangleArea")
@MockServerConfig(implementation = MockServerImplementation.Plugin, registryEntry = "protobuf/transport/grpc")
void calculateRectangleAreaTest(MockServer mockServer, V4Interaction.SynchronousMessages interaction) throws Exception {
// Test body...
}
}Provider Test
@Provider("area-calculator-provider")
@PactFolder("target/pacts")
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class CalculatorGrpcProviderTest {
@BeforeEach
void before(PactVerificationContext context) {
context.setTarget(new PluginTestTarget(
Map.of(
"host", "localhost",
"port", 6565,
"transport", "grpc"
)
));
}
@TestTemplate
@ExtendWith(PactVerificationInvocationContextProvider.class)
void verify(PactVerificationContext context) {
context.verifyInteraction();
}
}Proto
syntax = "proto3";
package area;
service Calculator {
rpc calculateOne (ShapeMessage) returns (AreaResponse) {}
}
message ShapeMessage {
oneof shape {
Rectangle rectangle = 1;
}
}
message Rectangle {
float length = 1;
float width = 2;
}
message AreaResponse {
repeated float value = 1;
}
Additional troubleshooting performed
- I've tried running with both plugin version 0.5.4 and the latest 0.6.5
- I can verify the plugin executable runs correctly when invoked directly from command line
- I've tried creating the log directory manually at ~/.pact/logs
- I've tried using absolute paths for both proto files and output directories
- I've used System.setProperty("pact.writer.overwrite", "true") to force overwrite of existing files
- I've upgraded protoc from version 29.3 to 32.0
Questions
- Is this expected behavior? Should we ignore these initialization errors if the contract is being generated successfully?
- What could be causing the connection refused errors when trying to connect to localhost ports?
- Are there known issues with the plugin manifest (seeing "args field in plugin manifest is invalid" warnings)?
- Is there a configuration that would eliminate these warning/error messages?
- How does Pact determine which plugin version to use when multiple versions are installed?
- What's the recommended approach to ensure a specific plugin version is used?
- Could there be potential issues with the generated contract despite the test passing?
Any help would be greatly appreciated, as these error messages are concerning even though the test appears to be working.
Metadata
Metadata
Assignees
Labels
No labels