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

Fix wdspec tests using new_session fixture #7461

Merged
merged 1 commit into from
Oct 24, 2017

Conversation

carlosgcampos
Copy link
Contributor

@carlosgcampos carlosgcampos commented Sep 25, 2017

Tests are passing capabilities that should be used when creating the
session, but they are passed directly as body of new session command,
without adding them to a capabilities object. This is also ignoring all
other configuration capabilities, preventing the browser from being
launched in cases where the browser binary is passed to the driver as a
capability. We should use the configuration capabilities, overwrite
the ones given by the test and pass them to the Session at construction.
This way we can use Session::start() instead of using send_command()
directly.

@ghost
Copy link

ghost commented Sep 25, 2017

Build ERRORED

Started: 2017-10-16 15:35:27
Finished: 2017-10-16 16:24:25

Failing Jobs

  • firefox:nightly
  • chrome:unstable

View more information about this build on:

Copy link
Member

@andreastt andreastt left a comment

Choose a reason for hiding this comment

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

Barring the fact that the documentation for overwrite_dictionary should be fixed up, this is fine.

@@ -24,6 +24,27 @@ def merge_dictionaries(first, second):

return result

def overwrite_dictionary(first, second):
"""Given two dictionaries, create a third that defines all specified
key/value pairs. This merge_dictionaries is performed "deeply" on any nested
Copy link
Member

Choose a reason for hiding this comment

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

Reference to merge_dictionaries?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, copy paste.

andreastt
andreastt previously approved these changes Sep 25, 2017
# TODO: merge in some capabilities from the confguration capabilities
# since these might be needed to start the browser
value = _session.send_command("POST", "session", body=body)
capabilities=overwrite_dictionary(configuration["capabilities"], capabilities))
Copy link
Contributor

Choose a reason for hiding this comment

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

@carlosgcampos @andreastt FYI, I needed to change this to capabilities={"alwaysMatch": caps} to get it working locally. (Where caps is the result of overwrite_dictionary(...))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, tests are already passing {"alwaysMatch": caps} to new_session, you shouldn't need to add it again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wait, not all the tests are doing the same thing, it seems new_session tests are passing {"capabilities": caps}. I'll check those and update the patch, thanks @mjzffr

Copy link
Contributor

@mjzffr mjzffr left a comment

Choose a reason for hiding this comment

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

Could you also provide a default value for capabilities? e.g. {"alwaysMatch": configuration["capabilities"]}

It would be useful if a test could use new_session() to mean that we just want the configuration capabilities. This comes up in subtests that aren't testing session creation but just need a new session for each subtest.

@carlosgcampos
Copy link
Contributor Author

Good idea, updated the patch to allow using new_session with no arguments

Copy link
Member

@andreastt andreastt left a comment

Choose a reason for hiding this comment

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

r+

Copy link
Contributor

@mjzffr mjzffr left a comment

Choose a reason for hiding this comment

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

Thanks!

@carlosgcampos
Copy link
Contributor Author

Thank you guys, can this be merged now, then?

@andreastt
Copy link
Member

The CI appears to be failing because the tests have now become unstable as a result of this change.

@carlosgcampos
Copy link
Contributor Author

How can I see what is failing? I don't see anything useful here

@andreastt
Copy link
Member

Neither can I. I don’t really understand how to debug test stability failures in those Travis jobs. I’ve retriggered the build a couple of times to no avail…

@whimboo
Copy link
Contributor

whimboo commented Oct 4, 2017

The stability tests fail because there is actually some kind of crash or disconnect in Firefox. You can see it here: https://travis-ci.org/w3c/web-platform-tests/jobs/280747953#L7012-L7013

It happens directly after http://web-platform.test:8000/webdriver/tests/support/inline.py?doc=%3Ca+href%3D%23+id%3DlinkText%3Efull+link+text%3C%2Fa%3E&content-type=text%2Fhtml%3Bcharset%3Dutf-8 got finished.

As it looks like a Firefox process might be left behind, which prevents Marionette from setting up the server socket for all the following tests. That's why the server socket failure.

@carlosgcampos
Copy link
Contributor Author

@whimboo do you think this is caused by this patch? or a problem in the bot? or maybe the firefox version used in the bots?

@whimboo
Copy link
Contributor

whimboo commented Oct 16, 2017

I cannot see that the issue should be related to your patch. Also because no capabilities should have been changed too. Did someone actually retrigger this failing job once or multiple times? How often does it fail? Given that it's using Firefox Nightly it might have been an issue on that day. So please lets get this job retriggered, so we can see if it still fails.

@andreastt
Copy link
Member

Yes, I’ve re-triggered it five or six times with the same result.

@jgraham
Copy link
Contributor

jgraham commented Oct 16, 2017

I think this is theoretically problematic because adding extra capabilities can invalidate the tests. I'm not sure what a good workaround is though, given that some capabilities are required to start the browser.

@carlosgcampos
Copy link
Contributor Author

I think this patch only changes the behavior for tests not passing a valid capabilities dictionary, because when receiving a valid capabilities dict we use that as the body of the new session command like current code does. So, the ones passing {"alwaysMatch": } might be the ones causing the failures. Those tests are using prompts, that I think are not implemented by geckodriver (right?), so with current code they are probably not executed, because the session is rejected due to the invalid capabilities. With this patch, those tests are correctly executed, but prompts are not actually handled. Could it be that we leave a firefox instance with an unhandled prompt or something? Could we try skipping those tests for firefox driver only?

@jgraham
Copy link
Contributor

jgraham commented Oct 17, 2017

The failures on Travis are mostly just the tests timing out. I ran locally and got the following unstable results:

## Unstable results ##

|                            Test                           |                            Subtest                             |          Results           | Messages |
|-----------------------------------------------------------|----------------------------------------------------------------|----------------------------|----------|
| `/webdriver/tests/navigation/current_url.py`              | `current_url.py::test_get_current_url_after_modified_location` | **FAIL: 3/10, PASS: 7/10** |          |
| `/webdriver/tests/sessions/new_session/default_values.py` | `default_values.py::test_missing_always_match`                 | **FAIL: 1/10, PASS: 9/10** |          |

I am particularly concerned with the default_values.py::test_missing_always_match test; I think that test just doesn't do what's expected in this case.

I think a more reasonable approach would be to make a fixture that could add default capabilities to a dictionary and put the tests that use new_session directly in control of adding these in the desired place (if any).

@jgraham
Copy link
Contributor

jgraham commented Oct 17, 2017

(note that I didn't check explicitly for regressions with this patch applied, but at a glance there are some, and we will need to check carefully before landing).

@carlosgcampos
Copy link
Contributor Author

But default_values.py::test_missing_always_match is passing '{"capabilities": {"firstMatch": [{}]}}' so in that case, the given dictionary is used directly as the body the new session command, there shouldn't be a change in behavior unless I'm missing something.

@jgraham
Copy link
Contributor

jgraham commented Oct 17, 2017

Oh right. But presumably then this simply won't fix that case (which is a valid new session).

I still think this implementation is too magical and that it would be better to make the tests pass this information themselves.

@carlosgcampos
Copy link
Contributor Author

This patch doesn't try to fix the tests passing { "capabilities": ... }, since the behavior doesn't change for those, but the ones passing { "alwaysMatch" : ... }. I'm fine with adding a different fixture for these one, though.

@whimboo
Copy link
Contributor

whimboo commented Oct 18, 2017

Could we temporarily run a travis job with this patch applied by using trace logging of Marionette, and maybe a debug build of Firefox? Both should give us way more debugging information to finally get a sense of what's going on here.

@jgraham if you are still able to reproduce locally maybe you could do it and upload the trace log?

@jgraham
Copy link
Contributor

jgraham commented Oct 18, 2017

@whimboo I don't think there's any mystery about what's going on here. The problem is that if the browser isn't on the $PATH we need to pass in the browser configuration capabilities to find it, which we currently don't do for the new session tests. The remaining question is how to add those to the payload in these cases where that payload is the thing under test. This patch tries to do it implicitly, but I strongly believe we should make it explicit in the tests.

@carlosgcampos
Copy link
Contributor Author

I'm going to try the explicit approach as soon as I find some time to work on this, hopefully later today.

@@ -83,6 +88,11 @@ def test_invalid_values(new_session, body, key, value):
lambda key, value: {"firstMatch": [{key: value}]}])
@pytest.mark.parametrize("key", invalid_extensions)
def test_invalid_extensions(new_session, body, key):
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to change the signature here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right

@@ -24,17 +29,17 @@ def test_platform_name(new_session, platform_name, body):


@pytest.mark.parametrize("key,value", invalid_merge)
def test_merge_invalid(new_session, key, value):
def test_merge_invalid(new_session, add_browser_capabilites, key, value):
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't strictly needed, but I guess it's better this way.

Tests are passing capabilities that should be used when creating the
session, but they are passed directly as body of new session command,
without adding them to a capabilities object. This is also ignoring all
other configuration capabilities, preventing the browser from being
launched in cases where the browser binary is passed to the driver as a
capability. This patch adds a new fixture add_browser_capabilites, that
is used by tests using new_session to provide the browser capabilities
and optionally add others.
@jgraham
Copy link
Contributor

jgraham commented Oct 24, 2017

I ran the stability checker locally and this doesn't seem to introduce any new problems, so merging.

@jgraham jgraham merged commit 09c7045 into web-platform-tests:master Oct 24, 2017
@carlosgcampos carlosgcampos deleted the wd-new-session branch October 24, 2017 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants