Skip to content

Fix resources/test (when running locally) - #10127

Merged
Hexcles merged 2 commits into
masterfrom
fix-resources-unittest
Mar 22, 2018
Merged

Hexcles merged 2 commits into
masterfrom
fix-resources-unittest

Conversation

@Hexcles

@Hexcles Hexcles commented Mar 21, 2018 •

Copy link
Copy Markdown
Member
  1. Check the HTTP port of wptserve instead of HTTPS to avoid the
    unnecessary complexities of setting up SSL context (which may fail in
    some environments, depending on the system OpenSSL version).
  2. Use exponential backoff when waiting for wptserve and specify a
    maximum retry to avoid indefinite hang.
  3. Use terminate instead of kill to give wptserve a chance to clean
    up, which is especially useful when running locally.

Fixes #10114.


This change is Reviewable

@Hexcles
Hexcles requested review from jgraham and jugglinmike March 21, 2018 17:43
@wpt-pr-bot
wpt-pr-bot requested review from ayg and gsnedders March 21, 2018 17:43
@Hexcles

Hexcles commented Mar 21, 2018

Copy link
Copy Markdown
Member Author

cc @lukebjerring you should be able to debug your PR locally with this patch.

@ghost

ghost commented Mar 21, 2018 •

Copy link
Copy Markdown

Build PASSED

Started: 2018-03-22 19:05:17
Finished: 2018-03-22 19:22:34

View more information about this build on:

@lukebjerring

Copy link
Copy Markdown
Contributor

Yep, this lets me past the issue I was having.

@Hexcles

Hexcles commented Mar 21, 2018

Copy link
Copy Markdown
Member Author

Fixed the SSL issue. The PR is now ready for review :)

@jugglinmike jugglinmike left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can't reproduce the issue locally, but I can at least verify that this doesn't regress tox on my system.

Comment thread resources/test/wptserver.py Outdated
# Exponential backoff.
wait = 1
for _ in range(5):
time.sleep(wait)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we move this to the end of the loop body, we might avoid unnecessary startup delays. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, time.sleep(_ ** 2) might make your intention more clear (along with renaming _ and removing wait)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I actually put it here intentionally as I noticed wptserve did take a short while to start and the first attempt often failed.

You meant 2 ** iterations right? Yeah that'd be a bit cleaner. Let me change it.

@Hexcles

Hexcles commented Mar 22, 2018

Copy link
Copy Markdown
Member Author

@jugglinmike thanks. A bit more details:

Creating a SSL context is actually quite tricky. Explicitly specifying TLS/SSL version isn't portable as newer OpenSSL may deprecate older, unsafe protocols (in fact, produce a fatal error). There is a new constant ssl.PROTOCOL_TLS that alleviates the issue but is only available in very recent Python. A safer way is ssl.create_default_context and then tweaks the trust settings. At the end of the day, it's just overly and unnecessarily complicated...

Hexcles added 2 commits March 22, 2018 15:02
1. Check the HTTP port of wptserve instead of HTTPS to avoid the
   unnecessary complexities of setting up SSL context (which may fail in
   some environments).
2. Use exponential backoff when waiting for wptserve and specify a
   maximum retry to avoid indefinite hang.
3. Use `terminate` instead of `kill` to give wptserve a chance to clean
   up, which is especially useful when running locally.

WPTServe.url still returns a HTTPS URL to make sure tests that require
secure context (e.g. service workers) still work.
@Hexcles
Hexcles force-pushed the fix-resources-unittest branch from c18d546 to c6e42ae Compare March 22, 2018 19:03
@Hexcles
Hexcles merged commit 9dcebcb into master Mar 22, 2018
@Hexcles
Hexcles deleted the fix-resources-unittest branch March 22, 2018 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants