question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pact JSON file not being created when running into a Docker Container

See original GitHub issue

Hello everyone,

I’m currently trying to integrate my Pact Tests with a CI/CD pipeline. I have a .NET Core application that runs its tests and builds within a Docker container.

I am able to run my tests on the machine I use to develop with no issues. Sadly, when the tests run within the container, the Pact file is not generated. On the other hand, it generates the pact log file and it does not contain any errors.

Generated log file: I, [2020-03-09T05:25:23.064685 #517] INFO -- : Cleared interactions for example "" I, [2020-03-09T05:25:23.271031 #517] INFO -- : Registered expected interaction GET /api/People?query=... D, [2020-03-09T05:25:23.271482 #517] DEBUG -- : { ... } I, [2020-03-09T05:25:24.821328 #517] INFO -- : Cleared interactions for example "" I, [2020-03-09T05:25:24.829914 #517] INFO -- : Registered expected interaction GET /api/People?query=... D, [2020-03-09T05:25:24.830098 #517] DEBUG -- : { ... } I, [2020-03-09T05:25:25.063320 #517] INFO -- : Cleared interactions for example "" Note that it is missing the message “Writing pact for *** to ***.json”

Here is the line that run the tests within the dockerfile dotnet test -p:CollectCoverage=true -p:CoverletOutputFormat=opencover -p:CoverletOutput=/testresults/coverage/"$i".xml "./tests/$prj"

Thanks in advance for your help

Cheers

David

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
david-tigerspikecommented, Mar 11, 2020

Hello guys!

Thanks for all the help. It ended up being a mix of a few issues on my side (misconfigured application together with odd failure handling on the pipeline)

However, now it has been fixed and it is all running as expected.

Thanks for all your time and sorry for the mess.

1reaction
bethesquecommented, Mar 10, 2020

You could try hacking it by sending a POST to the mock service http://localhost:<port>/pact at the end of your test to force it to write the file. It wouldn’t fix the underlying problem, but it might help identify something.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pact-mock-service is not found when run in docker ...
Steps to reproduce. Run consumer side contract tests in docker container using image node:10.15.3. NB: Everything works fine on version 9.0.3.
Read more >
Troubleshooting | Pact Docs
Pact tests may be run in parallel, which makes it difficult for Pact to know when the file is safe to clear. This...
Read more >
How to configure docker and postgres to use pact broker
1 Answer 1 ... It seems you are attempting to mount a volume on your host machine ( /var/lib/postgresql/data ) that does not...
Read more >
pactfoundation/pact-broker - Docker Image
The pactfoundation/pact-broker image is a forked version of the dius/pact-broker image. It is smaller (as it runs on Alpine Linux with Puma instead...
Read more >
Microcks and Pact for API contract testing
Pact JSON files are not typically handwritten, they're generated by tooling from some Unit Test code you have written to describe your expectation....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found