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

enable changing of url relative to selenium #1548

Merged
merged 4 commits into from
Sep 5, 2024

Conversation

danielklim
Copy link
Contributor

Currently, there is no way to use Selenium grid in a separate container/pod because BaseDashRunner assumes that the Dash server will be on localhost relative to the Selenium host. In other words, for a setup where the Dash app lives in container1 and Selenium lives in container 2, pytest can be invoked with pytest --remote-url http://container2:4444 but it will fail because Selenium in container2 will attempt to connect to localhost rather than container1 (since url@BaseDashRunner is hardcoded to localhost).

This MR adds host and scheme attributes to BaseDashRunner so that the user can better specify the location of the app relative to Selenium.

@alexcjohnson
Copy link
Collaborator

Thanks @danielklim - just to be clear, can you show an example of using these new attributes?

Also please switch to double quotes to appease the linter (or install black==19.10b0 and call npm run format but I believe it's just the quotes) and then merge the new tip of dev to fix the cryptography problem blocking the Py3.6 build. Then this should be good to go!

@danielklim
Copy link
Contributor Author

danielklim commented Feb 11, 2021

@alexcjohnson dev merged in and here is an explanation/demo of the issue

Let me know if you need anything else -- thanks!

@alexcjohnson
Copy link
Collaborator

@danielklim thanks for the great demo, and apologies for being slow to get back to this.

Does the demo represent how you would use this in practice? I'm glad that with this update the necessary functionality exists, but it bothers me that you need to synchronize code in the calling function (pytest --remote-url http://selenium:4444) with code inside the test case (dash_duo.server.host = 'dash'). That means you can no longer run these tests locally, just calling pytest, you're locked into using the selenium grid. Could we get around that with another command line option like --dash-url http://dash:8050 or --dash-host dash so the test case itself need not know where it's being run?

@danielklim
Copy link
Contributor Author

@alexcjohnson I think it's a great idea to add command line arguments as you suggested to avoid having to hardcode the remote url!

I'm a bit slammed with other work right now so can't really do it myself but it should be a pretty quick fix for anyone who is actively working on the code base; or you could just merge in my original MR since it does technically do what it's supposed to and create a future todo for the cmd line args.

@gvwilson
Copy link
Contributor

Hi @T4rk1n - is this one still relevant or has it gone stale?

Copy link
Contributor

@T4rk1n T4rk1n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still valid but need to merge with dev.

@@ -52,6 +52,8 @@ class BaseDashRunner(object):
"""Base context manager class for running applications."""

def __init__(self, keep_open, stop_timeout):
self.scheme = "http"
self.host = "localhost"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new attributes should be added as argument with their defaults.

@@ -92,7 +94,7 @@ def __exit__(self, exc_type, exc_val, traceback):
@property
def url(self):
"""The default server url."""
return "http://localhost:{}".format(self.port)
return "{}://{}:{}".format(self.scheme, self.host, self.port)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve conflict by using f-string.

@gvwilson
Copy link
Contributor

thanks @T4rk1n - I'll add it to the pile for the next cycle.

@danielklim
Copy link
Contributor Author

Glad to see this getting merged in!

@gvwilson gvwilson added P2 considered for next cycle community community contribution feature something new labels Aug 13, 2024
@gvwilson gvwilson added the testing automated tests label Aug 22, 2024
Copy link
Contributor

@T4rk1n T4rk1n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃

@T4rk1n T4rk1n merged commit 5a98989 into plotly:dev Sep 5, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community community contribution feature something new P2 considered for next cycle testing automated tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants