Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pact consumer tests' execution hangs after reaching 200 connection limit of mockServer #658

Closed
m-aster22 opened this issue Mar 29, 2018 · 8 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@m-aster22
Copy link

When running the pact consumer tests, the execution hangs after completing 200 tests (we got 222 tests to run). It seemed a bit odd that it'll stop after 200 tests but found this in the console:

image

I was able to trace this to the mockServer. It doesn't seem to close the connection after each test. Is there a way to close the connection after each test? Thanks!

@uglyog
Copy link
Member

uglyog commented Apr 3, 2018

Are you running the 222 tests in the same test class, or as part of a suite of tests?

@m-aster22
Copy link
Author

It's a suite of tests. We have around 32 test classes and test execution hangs at the 30th class (where the 201st test is located).

image

@uglyog
Copy link
Member

uglyog commented Apr 3, 2018

Thanks, I'll look into this. It might be related to #342, in that the PoolingHttpClientConnectionManager is creating a new connection for every test, while each test class gets it's own mock server.

@uglyog
Copy link
Member

uglyog commented Jun 3, 2018

This is not an issue with the MockServer, but with the Apache Http PoolingHttpClientConnectionManager. See 2.5. Connection eviction policy of https://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html for more information.

At the end of your test, you'll need to call ClientConnectionManager#closeExpiredConnections() or don't use the PoolingHttpClientConnectionManager in your tests (if possible).

@m-aster22
Copy link
Author

m-aster22 commented Jun 3, 2018 via email

@uglyog
Copy link
Member

uglyog commented Jun 3, 2018

Hmm, now that you mention it, there is a bootup check run from that function. I'll check to see if that is using the PoolingHttpClientConnectionManager.

@uglyog
Copy link
Member

uglyog commented Jun 3, 2018

I think this is the culprit: https://github.com/DiUS/pact-jvm/blob/master/pact-jvm-consumer/src/main/kotlin/au/com/dius/pact/consumer/MockHttpServer.kt#L200

I'll fix that function to use a better connection manager.

@uglyog uglyog added the bug Indicates an unexpected problem or unintended behavior label Jun 3, 2018
@uglyog
Copy link
Member

uglyog commented Jun 17, 2018

Fix has been released with version 3.5.18

@uglyog uglyog closed this as completed Jun 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants