-
Notifications
You must be signed in to change notification settings - Fork 24
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
Randomize port that mongo uses if it isn't already #280
Comments
I have an example of how to get a free port in a little side project I did a while ago: https://github.com/alechenninger/httpserverrule/blob/master/src/main/java/com/github/alechenninger/httpserverrule/UndertowHttpServer.java#L66 |
I assume you mean for testing? If so, that is actually from the lightblue-mongo project. In a test case you can use the InMemoryMongoServer annotation to change what port is used. That said, it can be an incredibly useful debugging technique to throw a breakpoint in a unit test and connect to the mongo instance locally to run queries. If the port was random, it would be harder to know how to connect to the local instance. |
Yes, this is for testing. For example, a Jenkins server is building multiple projects which run tests using the embedded mongo. Without a random port, this is broken, since if any of these projects run their tests at the same time, they will fail. |
Do you have an example of using the InMemoryMongoServer annotation? I thought that was used inside of the lightblue test harness resource. Not sure I understand what you mean. |
Wouldn't you also have a problem with the port Lightblue itself uses?
I don't, but the annotation should work on any descendent of LightblueMongoTestHarness, which LightblueClientTestHarness is, but LightblueExternalResource is not. I would be surprised if it worked with LightblueExternalResource. |
Just had a case where our build server tests failed because mongo port was already bound, I think this is because another build was going off with tests that also used embedded lightblue at the same time.
The text was updated successfully, but these errors were encountered: