Bug 52872

Summary: new-run-webkit-tests fails to start HTTP server if there are proxy settings
Product: WebKit Reporter: Xianzhu Wang <phnixwxz>
Component: Tools / TestsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, commit-queue, dpranke, eric, evan, levin, mihaip, ojan, tony, wangxianzhu, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
The patch none

Description Xianzhu Wang 2011-01-21 01:03:29 PST
new-run-webkit-tests script checks if the testing HTTP server has been properly started by sending testing requests to the server with urllib.urlopen(). However, in an environment with proxy set, urllib.urlopen() can't recognize the no_proxy settings, and always use proxy even to access http://127.0.0.1:8000/. This causes the checker fails to check the status of HTTP servers and reports 'failed to start httpd.'

To resolve this, we can explicitly disable proxies in urllib.urlopen().
Comment 1 Xianzhu Wang 2011-01-21 01:11:02 PST
Even sometimes urlopen can recognize no_proxy config for non-https requests, the proxy setting sometimes still causes "SSL unknown protocol" error.  Forcing disabling proxy can resolve this.
Comment 2 Xianzhu Wang 2011-01-21 01:18:20 PST
Created attachment 79708 [details]
The patch
Comment 3 Eric Seidel (no email) 2011-01-21 02:22:58 PST
How does one set a proxy so as to trigger this?

Can we unit test this?
Comment 4 Xianzhu Wang 2011-01-21 02:51:37 PST
(In reply to comment #3)
> How does one set a proxy so as to trigger this?

I reproduce the issue on an Ubuntu Lucid with the following proxy settings:
 * Manual proxy configuration
 * Use the same proxy for all protocols
 * HTTP proxy: some valid proxy server
 * Ignored Host list:
      localhost
      127.0.0.1/8
      *.local

$ python (before this, should start a web server serving https on 8443 port) 
>>> import urllib
>>> urllib.urlopen('https://127.0.0.1:8443/')
Traceback (most recent call last):
  File "/usr/lib/python2.6/urllib.py", line 86, in urlopen
    return opener.open(url)
  File "/usr/lib/python2.6/urllib.py", line 205, in open
    return getattr(self, name)(url)
  File "/usr/lib/python2.6/urllib.py", line 439, in open_https
    h.endheaders()
  File "/usr/lib/python2.6/httplib.py", line 904, in endheaders
    self._send_output()
  File "/usr/lib/python2.6/httplib.py", line 776, in _send_output
    self.send(msg)
  File "/usr/lib/python2.6/httplib.py", line 735, in send
    self.connect()
  File "/usr/lib/python2.6/httplib.py", line 1112, in connect
    self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
  File "/usr/lib/python2.6/ssl.py", line 350, in wrap_socket
    suppress_ragged_eofs=suppress_ragged_eofs)
  File "/usr/lib/python2.6/ssl.py", line 118, in __init__
    self.do_handshake()
  File "/usr/lib/python2.6/ssl.py", line 293, in do_handshake
    self._sslobj.do_handshake()
IOError: [Errno socket error] [Errno 1] _ssl.c:480: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

>>> urllib.urlopen('https://127.0.0.1:8443/', proxies={})
<addinfourl at 19614032 whose fp = <socket._fileobject object at 0x129f550>>
>>> 

This seems a bug of python or some underlying library. Unsetting http_proxy, https_proxy, all_proxy environment variables doesn't help. I searched the error message and knew that many people encountered this and disabling proxy can resolve.

> 
> Can we unit test this?

I've no idea. Is it necessary?
Comment 5 Eric Seidel (no email) 2011-01-21 03:13:36 PST
Tests are generally more important than code fixes :)  As they prevent us from making the same bugs twice!  But if it's not possible to unit test this then we don't need to.  It may not be realistic to unit test this give that it depends on system settings.
Comment 6 Tony Chang 2011-01-21 10:15:33 PST
Will DRT pick up system proxy settings?  If so, can having a proxy set cause the http layout tests to fail?

Would it be better to just detect there is a proxy set and provide a good warning message to the user (e.g., what environment variables to set to disable when running the tests)?
Comment 7 Xianzhu Wang 2011-01-21 19:50:26 PST
(In reply to comment #6)
> Will DRT pick up system proxy settings?  If so, can having a proxy set cause the http layout tests to fail?
> 

A correct proxy setting should bypass localhost, and webkit can handle this correctly, so layout tests won't fail. The problem only occurs during python urllib.urlopen().

> Would it be better to just detect there is a proxy set and provide a good warning message to the user (e.g., what environment variables to set to disable when running the tests)?

Environment variables is not the only way to set proxy. Only unsetting environment variables seems not working for me. And I think disabling proxy before testing might be annoying for people who rely on proxies all the time.
Comment 8 Tony Chang 2011-01-24 11:39:20 PST
Comment on attachment 79708 [details]
The patch

I see, given that DRT should be able to handle system proxy settings and this is just a bug with python on Linux, this seems fine to me.
Comment 9 WebKit Commit Bot 2011-01-24 14:22:50 PST
Comment on attachment 79708 [details]
The patch

Clearing flags on attachment: 79708

Committed r76547: <http://trac.webkit.org/changeset/76547>
Comment 10 WebKit Commit Bot 2011-01-24 14:22:55 PST
All reviewed patches have been landed.  Closing bug.
Comment 11 WebKit Review Bot 2011-01-24 14:55:42 PST
http://trac.webkit.org/changeset/76547 might have broken Qt Linux Release
The following tests are not passing:
fast/text/international/cjk-segmentation.html