Closed rasmus-unity closed 5 years ago
The mock server it starts is stateful, as it needs to confirm the the expected interactions for each test are actually made, so running the pact tests in parallel is not possible, unless you create multiple instances of the pact struct on different ports.
See https://github.com/pact-foundation/pact-go/blob/master/README.md#splitting-tests-across-multiple-files for some insight into how you might be able to achieve it
Sorry, didn't mean to hit close. Will look into it and add some documentation for others
so running the pact tests in parallel is not possible
Probably a basic question, but even if I just run a single pact test, it still fails with race condition. Or do you mean something different?
Updated description above to include repro steps for issue when running single consumer pact test from pact-go/examples/consumer/goconsumer
. Hope I understood correctly, that this should be possible?
That's fantastic, thanks! It should be possible to run the test, so looks like a bug we can hunt down.
Fix is now in master, but not in a tagged release. If you'd like to give this a go in your project @rasmus-unity that'd be great.
@mefellows, verified it works on our test suite also. thanks for the quick fix to this!
Your welcome, thanks!
We're running our unit tests with
-race
option, and when trying to introduce pact consumer tests, they fail with a race condition. Reproduced on latest master from https://github.com/pact-foundation/pact-go repo. We can probably find a way to run pact tests without race detection, but curious to know if this is an issue which should be fixed.Software versions
master
branch)go version go1.9.4 darwin/amd64
Expected behaviour
Running pact tests with
-race
should passActual behaviour
Fails with
Steps to reproduce
git clone git@github.com:pact-foundation/pact-go.git
cd pact-go
make testrace
EDIT: Alternatively
git clone git@github.com:pact-foundation/pact-go.git
cd pact-go/examples/consumer/goconsumer
go test -race -run TestPactConsumerLoginHandler_UserExists .
Result:
Found 2 data race(s)
Relevent log files
Hope above is sufficient