-
Notifications
You must be signed in to change notification settings - Fork 362
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
TST: Don't hard code server port in tests #1690
Conversation
2d070ab
to
c31af10
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first glance all looks well here, but I have not yet reviewed in detail.
I have one main comment for you to consider before moving on.
fsspec/tests/conftest.py
Outdated
if "give_path" in self.headers: | ||
return self._respond(200, data=json.dumps({"path": self.path}).encode()) | ||
if "redirect" in self.headers and file_path != "/index/realfile": | ||
new_url = f"http://127.0.0.1:{port}/index/realfile" | ||
new_url = f"http://127.0.0.1:{self.server.server_port}/index/realfile" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.server.realfile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.server
is the HTTPServer
, not the server
fixture, and doesn't have a realfile
attribute. But this could probably use _make_realfile
instead.
fsspec/tests/conftest.py
Outdated
httpd = HTTPServer(server_address, HTTPTestHandler) | ||
th = threading.Thread(target=httpd.serve_forever) | ||
th.daemon = True | ||
th.start() | ||
try: | ||
yield f"http://127.0.0.1:{port}" | ||
yield f"http://127.0.0.1:{httpd.server_port}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are choosing to become port agnostic, this may be a good time to also become server address agnostic. httpd.server_name
should be populated here, and might be other than the standard loopback, e.g., for systems that are IPv6 only.
768c381
to
41053a2
Compare
Test failures with a bunch of "Cannot connect to host 0.0.0.0:50610" look real - but only on windows. |
Unfortunately, it looks like |
This allows running tests in parallel without running into "Port already in use" errors.
41053a2
to
b52d782
Compare
Well done :) |
This allows running tests in parallel without running into "Port already in use" errors.