laminar icon indicating copy to clipboard operation
laminar copied to clipboard

Make tests use OS-assigned ports instead of a manual specified port

Open kstrafe opened this issue 5 years ago • 5 comments

Task Description

Hard-coding test ports are error-prone. We should use the OS loopback interface to find any available port instead of manually ensuring that ports on each test are different.

In rust we are able to use 127.0.0.1:0, next the OS will asignt a free port.

Task TODO

  • [ ] Check if loopback address can be used inside tests.
  • [ ] Inventarize all places where ports are bein hardcoded, report them here
  • [ ] Change all places to the dynamic port where possible.

kstrafe avatar Jun 14 '19 18:06 kstrafe

Agree, we did do that, however, when I did this in the past I got some 'address is already in use errors', not sure why it did not resolve the port automatically.

TimonPost avatar Jun 15 '19 09:06 TimonPost

I'm not sure how you implemented it but might be a TOCTOU error. (I can't find the use of loopbacks in the git log)

kstrafe avatar Jun 15 '19 12:06 kstrafe

I guess there is one way to find out, just change the tests and see what it does.

TimonPost avatar Jun 16 '19 13:06 TimonPost

Will wait for https://github.com/amethyst/laminar/pull/196 to merge

kstrafe avatar Jun 17 '19 02:06 kstrafe

Is this still something that should happen? I went through and patched all the tests I could find. There is one test in connection_manager.rs I omitted because it used FakeSocket. All the tests seem to run on my machine, if this vaguely looks ok I can submit a PR.

maniyar1 avatar May 26 '20 04:05 maniyar1