Changeset 88671 in webkit


Ignore:
Timestamp:
Jun 13, 2011 12:15:27 PM (13 years ago)
Author:
dpranke@chromium.org
Message:

2011-06-13 Dirk Pranke <dpranke@chromium.org>

Reviewed by Tony Chang.

webkitpy: add integration tests for new-run-webkit-httpd, stop calling shut_down_http_server
https://bugs.webkit.org/show_bug.cgi?id=62251

shut_down_http_server() was a total hack that was only used by
new-run-webkit-httpd, so I've moved the code there and switched
to using executive.kill_process() for the common case. The
method itself will be removed in the patch on bug 59993.

  • Scripts/new-run-webkit-httpd:
  • Scripts/webkitpy/layout_tests/port/apache_http_server.py:
  • Scripts/webkitpy/layout_tests/port/http_server.py:
  • Scripts/webkitpy/layout_tests/port/http_server_integrationtest.py: Added.
  • Scripts/webkitpy/layout_tests/port/websocket_server.py:
Location:
trunk/Tools
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r88661 r88671  
     12011-06-13  Dirk Pranke  <dpranke@chromium.org>
     2
     3        Reviewed by Tony Chang.
     4
     5        webkitpy: add integration tests for new-run-webkit-httpd, stop calling shut_down_http_server
     6        https://bugs.webkit.org/show_bug.cgi?id=62251
     7
     8        shut_down_http_server() was a total hack that was only used by
     9        new-run-webkit-httpd, so I've moved the code there and switched
     10        to using executive.kill_process() for the common case. The
     11        method itself will be removed in the patch on bug 59993.
     12
     13        * Scripts/new-run-webkit-httpd:
     14        * Scripts/webkitpy/layout_tests/port/apache_http_server.py:
     15        * Scripts/webkitpy/layout_tests/port/http_server.py:
     16        * Scripts/webkitpy/layout_tests/port/http_server_integrationtest.py: Added.
     17        * Scripts/webkitpy/layout_tests/port/websocket_server.py:
     18
    1192011-06-13  Tony Chang  <tony@chromium.org>
    220
  • trunk/Tools/Scripts/new-run-webkit-httpd

    r81834 r88671  
    7171            httpd.start()
    7272        else:
    73             httpd.stop(force=True)
    74 
     73            # FIXME: We use _shut_down_http_server() instead of stop_http_server()
     74            # because stop() only works if start() was called previously in the
     75            # same process. _shut_down() is too coarse and may kill unrelated
     76            # web servers, so this is a hack. We should change the interface so we
     77            # can rely on pid files or something.
     78            port_obj._shut_down_http_server(None)
    7579
    7680def main():
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/apache_http_server.py

    r85665 r88671  
    228228        _log.debug("Shutting down any running http servers")
    229229        httpd_pid = None
    230         if os.path.exists(self._pid_file):
     230        if self._httpd_proc:
     231            httpd_pid = self._httpd_proc.pid
     232        elif os.path.exists(self._pid_file):
    231233            httpd_pid = int(open(self._pid_file).readline())
    232         # FIXME: We shouldn't be calling a protected method of _port_obj!
    233         self._port_obj._shut_down_http_server(httpd_pid)
     234        if httpd_pid:
     235            self._executive.kill_process(httpd_pid)
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/http_server.py

    r85665 r88671  
    227227    # probably not being flushed, etc... why doesn't our python have os.kill ?
    228228
    229     def stop(self, force=False):
    230         if not force and not self.is_running():
     229    def stop(self):
     230        if not self.is_running():
    231231            return
    232232
     
    234234        if self._process:
    235235            httpd_pid = self._process.pid
    236         self._port_obj._shut_down_http_server(httpd_pid)
     236        self._executive.kill_process(httpd_pid)
    237237
    238238        if self._process:
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/http_server_base.py

    r85665 r88671  
    4444    def __init__(self, port_obj):
    4545        self._port_obj = port_obj
     46        self._executive = port_obj._executive
    4647
    4748    def wait_for_action(self, action):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py

    r85896 r88671  
    4949class PortTestCase(unittest.TestCase):
    5050    """Tests that all Port implementations must pass."""
    51 
    52     HTTP_PORTS = [8000, 8080, 8443]
    53     WEBSOCKET_PORTS = [8880]
     51    HTTP_PORTS = (8000, 8080, 8443)
     52    WEBSOCKET_PORTS = (8880,)
    5453
    5554    def port_maker(self, platform):
     
    9392        for port in ports:
    9493            try:
    95                 s = socket.socket()
    96                 s.connect((host, port))
     94                test_socket = socket.socket()
     95                test_socket.connect((host, port))
    9796                self.fail()
    9897            except IOError, e:
    9998                self.assertTrue(e.errno in (errno.ECONNREFUSED, errno.ECONNRESET))
    10099            finally:
    101                 s.close()
     100                test_socket.close()
    102101
    103102    def assert_servers_are_up(self, host, ports):
    104103        for port in ports:
    105104            try:
    106                 s = socket.socket()
    107                 s.connect((host, port))
     105                test_socket = socket.socket()
     106                test_socket.connect((host, port))
    108107            except IOError, e:
    109108                self.fail('failed to connect to %s:%d' % (host, port))
    110109            finally:
    111                 s.close()
     110                test_socket.close()
    112111
    113112    def integration_test_http_lock(self):
     
    138137        if not port:
    139138            return
    140 
    141139        self.assert_servers_are_down('localhost', self.HTTP_PORTS)
    142140        port.start_http_server()
     
    149147        if not port:
    150148            return
    151 
    152149        # Test that if a port isn't available, the call fails.
    153150        for port_number in self.HTTP_PORTS:
    154             s = socket.socket()
     151            test_socket = socket.socket()
    155152            try:
    156153                try:
    157                     s.bind(('localhost', port_number))
     154                    test_socket.bind(('localhost', port_number))
    158155                except socket.error, e:
    159156                    if e.errno in (errno.EADDRINUSE, errno.EALREADY):
     
    167164            finally:
    168165                port.stop_http_server()
    169                 s.close()
     166                test_socket.close()
    170167
    171168        # Test that calling start() twice fails.
     
    261258        # Test that start() fails if a port isn't available.
    262259        for port_number in self.WEBSOCKET_PORTS:
    263             s = socket.socket()
    264             try:
    265                 s.bind(('localhost', port_number))
     260            test_socket = socket.socket()
     261            try:
     262                test_socket.bind(('localhost', port_number))
    266263                try:
    267264                    port.start_websocket_server()
     
    271268            finally:
    272269                port.stop_websocket_server()
    273                 s.close()
     270                test_socket.close()
    274271
    275272        # Test that calling start() twice fails.
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/websocket_server.py

    r85665 r88671  
    210210        if not url_is_alive(url):
    211211            if self._process.returncode == None:
    212                 # FIXME: We should use a non-static Executive for easier
    213                 # testing.
    214                 Executive().kill_process(self._process.pid)
     212                self._executive.kill_process(self._process.pid)
    215213            with codecs.open(output_log, "r", "utf-8") as fp:
    216214                for line in fp:
     
    228226                file.write("%d" % self._process.pid)
    229227
    230     def stop(self, force=False):
    231         if not force and not self.is_running():
     228    def stop(self):
     229        if not self.is_running():
    232230            return
    233231
     
    244242
    245243        _log.debug('Shutting down %s server %d.' % (self._server_name, pid))
    246         # FIXME: We should use a non-static Executive for easier testing.
    247         Executive().kill_process(pid)
     244        self._executive.kill_process(pid)
    248245
    249246        if self._process:
Note: See TracChangeset for help on using the changeset viewer.