-
Notifications
You must be signed in to change notification settings - Fork 147
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
Looking up dynamically allocated port numbers to support testing of proxied services #343
Comments
Forgive what's probably a stupid question, but can you test it via the proxy URL (e.g. If JSP launches the server, you need to make at least 1 request via the proxy to ensure it's launched before you try to talk to it. And the server may also know (via some sort of config) what URL it expects to be visible at, so it might not work properly without the proxy URL. If you do need to access it directly, one option would be to load the same config and entry points that JSP does, and launch services in your test code (at least those using dynamic ports), copying the code to get a random port number: jupyter-server-proxy/jupyter_server_proxy/handlers.py Lines 593 to 596 in 5ff4c77
|
IIRC, my issue was I have dozens of servers running on different ports, and if I launch a new Jupyter server and to test it, I don't necessarily know what port it's running on if the port is dynamically allocated. |
The proxy name should jupyter-server-proxy/tests/resources/jupyter_server_config.py Lines 31 to 88 in 31e8b30
https://github.com/jupyterhub/jupyter-server-proxy/blob/main/tests/test_proxies.py So I think it's worth investigating why it's not working for you. |
I didn't quite follow this. Is the issue that you don't know which port either Jupyter or your proxied service is running on? If your tests know how to talk to the Jupyter server, then as @manics said, the configured proxy name should work, so it's worth figuring out why it doesn't. |
In https://github.com/jupyterhub/jupyter-server-proxy/blob/main/tests/test_proxies.py, the
If I start a jupyter server, and the default 8888 is already allocated, the server is launched on a new port number. What port number? How do I assign that number to eg the env var |
OK, I think what you're really asking is "how do I find out what port jupyter-server is running on" rather than anything specific to jupyter-server-proxy, since it also applies to any extensions you want to test. For CI testing I usually aim for as much control over the environment as possible, so in that situation I'd tell jupyter-server which port ( jupyter-server-proxy/.github/workflows/test.yaml Lines 81 to 84 in 31e8b30
If you want to find out the dynamically chosen jupyter-server port though it might be worth asking over on the jupyter-server repo or on Discourse? |
For what it's worth, I think the port info could be added to the api at server-proxy/servers-info. The api is only used for UI right now. The endpoint has the comment, "Don't send anything that might be a callable, or leak sensitive info," but it is authenticated, and I'm not sure what is considered sensitive and how it could be leaked. |
Is there a simple pattern for creating basic tests of proxied services, eg using a tool such as
playwright
?If we know the port number a service is running on, then a simple test of the following form can be used to check that the page loads with the desired title, and then grabs a screenshot of it:
Using the proxy name alias doesn't seem to get resolved, whereas specifying the port number explicitly does seem to work.
But in a general case, how can we find the port number for a proxied service, particularly if it it allocated dynamically?
I note also that we can get some general metadata about proxied services from
http://localhost/server-proxy/servers-info
, although not the port numbers.The text was updated successfully, but these errors were encountered: