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

Randomize port that mongo uses if it isn't already #280

Open
alechenninger opened this issue Mar 29, 2016 · 5 comments
Open

Randomize port that mongo uses if it isn't already #280

alechenninger opened this issue Mar 29, 2016 · 5 comments

Comments

@alechenninger
Copy link
Contributor

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.

@alechenninger
Copy link
Contributor Author

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

@dcrissman
Copy link
Member

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.

@alechenninger
Copy link
Contributor Author

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.

@alechenninger
Copy link
Contributor Author

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.

@dcrissman
Copy link
Member

Wouldn't you also have a problem with the port Lightblue itself uses?

Do you have an example of using the InMemoryMongoServer annotation?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants