I use consumer driven contract-testing

I have a provider p1 and a consumer c1. Interactions between them include messaging as well as rest api calls. Both of the interactions have separate pact files generated from consumer and separate provider contract test files. When I run the Kafka interactions test file pact is picking up both the pact files since the provider name is same in which Kafka test cases are passing and Rest interactions are failing since in the context TestTarget was set to MessageTestTarget and rest interactions expects HttpTestTarget.

I tried changing the provider name as p1-kafka and p1-rest but it will then fail in our CI pipeline since we validate the provider name. One of the solutions I can think of is implementing bidirectional contract testing for Rest and consumer-driven contract testing for Kafka which is not feasible.

1

There are 1 best solutions below

0
On

You can't publish two separate contracts from the same consumer to the same provider, one with HTTP and another with Kafka (messages) - they must all be in the same contract, or be for different providers (as you noted).

In the latest version of the Pact Specification, the contract may have multiple types of interactions in it (previously the only workaround was to name the REST and Messaging provider differently to work around the issue).

The latest version of the Pact JVM should support this also. I will find out the correct way to do so and update this answer.