pact-foundation / pact-net

.NET version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://pact.io
MIT License
823 stars 225 forks source link

Provider Verification results are not published in the pipeline but are published when test is run locally #477

Closed MaciejReszotnik closed 8 months ago

MaciejReszotnik commented 8 months ago

Hello PactNet team,

I am writing to inquire about the issue I am struggling with for a number of hours. Specifically, Provider verification results are not published, but only when I run the tests on my CI pipeline.

I am using PactNet version 4.5

When I run the tests locally everything works fine, and the results appear in the Broker. Here's how I launch verification in Provider test

image

I am fully aware that this behavior should be inversed: CI is the place where I want my verification. I intended to block local verification through if clause and checking for pipeline-specific environment variables. Still, for some reason this does not work on the pipeline and I get no error message there. Am I doing something wrong or is it a bug?

EDIT: Looking at the test logs generated by MS tests in the pipeline (not console logs of the test run) I found the following information:

2023-10-11T14:42:37.746947Z ERROR ThreadId(01) verify_provider_async: pact_verifier: Publishing of verification results failed with an error: Error with the content of a HAL resource - Request to pact broker URL 'https://pactbroker.tech.kmdelements.com/pacticipants/ValueListProvider/branches/HEAD%0A/versions/0.0.c237d24%0A' failed - HTTP status client error (422 Unprocessable Entity) for url (https://pactbroker.tech.xxxyyy.com/pacticipants/ZProvider/branches/HEAD%0A/versions/0.0.c237d24%0A)

It seems that the variables {branch} and {version} are substituted incorrectly

https://pactbroker.tech.kmdelements.com/pacticipants/ValueListProvider/branches/{branch}/versions/{version} 2023-10-11T14:42:37.742085Z TRACE ThreadId(01) verify_provider_async: pact_verifier::pact_broker: Looking up value for key 'branch' 2023-10-11T14:42:37.742095Z TRACE ThreadId(01) verify_provider_async: pact_verifier::pact_broker: Looking up value for key 'version' 2023-10-11T14:42:37.742099Z DEBUG ThreadId(01) verify_provider_async: pact_verifier::pact_broker: final URL = https://pactbroker.tech.kmdelements.com/pacticipants/ValueListProvider/branches/HEAD%0A/versions/0.0.c237d24%0A

Any reason for why that happens?

MaciejReszotnik commented 8 months ago

Apologies, in the course of my own investigation I discovered it is the way we identify branch that is flawed and not the framework. As such, this question is irrelevant to your solution. Again, apologies.