Title: [89459] trunk/Tools
Revision
89459
Author
[email protected]
Date
2011-06-22 12:52:25 -0700 (Wed, 22 Jun 2011)

Log Message

2011-06-22  Dirk Pranke  <[email protected]>

        Reviewed by Tony Chang.

        run-webkit-websocketserver fails to stop websocket server
        https://bugs.webkit.org/show_bug.cgi?id=63123

        There's a ten-character change in new-run-webkit-websocketserver
        that fixes the actual bug, and then we update the code in
        new-run-webkit-httpd to do the actual stop call, and add more tests
        (refactoring the existing test code so that it is shared).

        * Scripts/new-run-webkit-httpd:
        * Scripts/new-run-webkit-websocketserver:
        * Scripts/webkitpy/layout_tests/port/http_server_integrationtest.py:

Modified Paths

Property Changed

Diff

Modified: trunk/Tools/ChangeLog (89458 => 89459)


--- trunk/Tools/ChangeLog	2011-06-22 19:47:07 UTC (rev 89458)
+++ trunk/Tools/ChangeLog	2011-06-22 19:52:25 UTC (rev 89459)
@@ -1,3 +1,19 @@
+2011-06-22  Dirk Pranke  <[email protected]>
+
+        Reviewed by Tony Chang.
+
+        run-webkit-websocketserver fails to stop websocket server
+        https://bugs.webkit.org/show_bug.cgi?id=63123
+
+        There's a ten-character change in new-run-webkit-websocketserver
+        that fixes the actual bug, and then we update the code in
+        new-run-webkit-httpd to do the actual stop call, and add more tests
+        (refactoring the existing test code so that it is shared).
+
+        * Scripts/new-run-webkit-httpd:
+        * Scripts/new-run-webkit-websocketserver:
+        * Scripts/webkitpy/layout_tests/port/http_server_integrationtest.py:
+
 2011-06-22  Adam Roben  <[email protected]>
 
         Add links to existing bugs related to failing tests on TestFailures page

Modified: trunk/Tools/Scripts/new-run-webkit-httpd (89458 => 89459)


--- trunk/Tools/Scripts/new-run-webkit-httpd	2011-06-22 19:47:07 UTC (rev 89458)
+++ trunk/Tools/Scripts/new-run-webkit-httpd	2011-06-22 19:52:25 UTC (rev 89459)
@@ -70,13 +70,9 @@
         if options.server == 'start':
             httpd.start()
         else:
-            # FIXME: We use _shut_down_http_server() instead of stop_http_server()
-            # because stop() only works if start() was called previously in the
-            # same process. _shut_down() is too coarse and may kill unrelated 
-            # web servers, so this is a hack. We should change the interface so we
-            # can rely on pid files or something.
-            port_obj._shut_down_http_server(None)
+            httpd.stop()
 
+
 def main():
     option_parser = optparse.OptionParser()
     option_parser.add_option('-k', '--server',

Modified: trunk/Tools/Scripts/new-run-webkit-websocketserver (89458 => 89459)


--- trunk/Tools/Scripts/new-run-webkit-websocketserver	2011-06-22 19:47:07 UTC (rev 89458)
+++ trunk/Tools/Scripts/new-run-webkit-websocketserver	2011-06-22 19:52:25 UTC (rev 89459)
@@ -102,7 +102,7 @@
     if 'start' == options.server:
         pywebsocket.start()
     else:
-        pywebsocket.stop(force=True)
+        pywebsocket.stop()
 
 if '__main__' == __name__:
     main()
Property changes on: trunk/Tools/Scripts/new-run-webkit-websocketserver
___________________________________________________________________

Added: svn:executable

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/http_server_integrationtest.py (89458 => 89459)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/http_server_integrationtest.py	2011-06-22 19:47:07 UTC (rev 89458)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/http_server_integrationtest.py	2011-06-22 19:52:25 UTC (rev 89459)
@@ -26,8 +26,10 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-"""Integration testing for the new-run-webkit-httpd script"""
+"""Integration tests for the new-run-webkit-httpd and new-run-webkit-websocketserver scripts"""
 
+# FIXME: Rename this file to something more descriptive.
+
 import errno
 import os
 import socket
@@ -39,50 +41,62 @@
 from webkitpy.layout_tests.port import port_testcase
 
 
-class NewRunWebKitHTTPdTest(unittest.TestCase):
-    """Tests that new-run-webkit-httpd must pass."""
-    HTTP_PORTS = (8000, 8080, 8443)
+class BaseTest(unittest.TestCase):
+    """Basic framework for script tests."""
+    HOST = 'localhost'
 
-    def assert_servers_are_down(self, host, ports):
+    # Override in actual test classes.
+    PORTS = None
+    SCRIPT_NAME = None
+
+    def assert_servers_are_down(self, ports=None):
+        ports = ports or self.PORTS
         for port in ports:
             try:
                 test_socket = socket.socket()
-                test_socket.connect((host, port))
+                test_socket.connect((self.HOST, port))
                 self.fail()
             except IOError, e:
                 self.assertTrue(e.errno in (errno.ECONNREFUSED, errno.ECONNRESET))
             finally:
                 test_socket.close()
 
-    def assert_servers_are_up(self, host, ports):
+    def assert_servers_are_up(self, ports=None):
+        ports = ports or self.PORTS
         for port in ports:
             try:
                 test_socket = socket.socket()
-                test_socket.connect((host, port))
+                test_socket.connect((self.HOST, port))
             except IOError, e:
-                self.fail('failed to connect to %s:%d' % (host, port))
+                self.fail('failed to connect to %s:%d' % (self.HOST, port))
             finally:
                 test_socket.close()
 
     def run_script(self, args):
         script_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
-        script_path = os.path.join(script_dir, 'new-run-webkit-httpd')
+        script_path = os.path.join(script_dir, self.SCRIPT_NAME)
         return subprocess.call([sys.executable, script_path] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 
-    def integration_test_http_server__normal(self):
-        self.assert_servers_are_down('localhost', self.HTTP_PORTS)
+    def integration_test_server__normal(self):
+        if not self.SCRIPT_NAME:
+            return
+
+        self.assert_servers_are_down()
         self.assertEquals(self.run_script(['--server', 'start']), 0)
-        self.assert_servers_are_up('localhost', self.HTTP_PORTS)
+        self.assert_servers_are_up()
         self.assertEquals(self.run_script(['--server', 'stop']), 0)
-        self.assert_servers_are_down('localhost', self.HTTP_PORTS)
+        self.assert_servers_are_down()
 
-    def integration_test_http_server__fails(self):
+    def integration_test_server__fails(self):
+        if not self.SCRIPT_NAME:
+            return
+
         # Test that if a port isn't available, the call fails.
-        for port_number in self.HTTP_PORTS:
+        for port_number in self.PORTS:
             test_socket = socket.socket()
             try:
                 try:
-                    test_socket.bind(('localhost', port_number))
+                    test_socket.bind((self.HOST, port_number))
                 except socket.error, e:
                     if e.errno in (errno.EADDRINUSE, errno.EALREADY):
                         self.fail('could not bind to port %d: %s' % (port_number, str(e)))
@@ -92,13 +106,6 @@
                 self.run_script(['--server', 'stop'])
                 test_socket.close()
 
-        # Test that calling start() twice fails.
-        try:
-            self.assertEquals(self.run_script(['--server', 'start']), 0)
-            self.assertEquals(self.run_script(['--server', 'start']), 1)
-        finally:
-            self.run_script(['--server', 'stop'])
-
         # Test that calling stop() twice is harmless.
         self.assertEquals(self.run_script(['--server', 'stop']), 0)
 
@@ -109,18 +116,36 @@
             if e.errno != errno.EEXIST:
                 raise
 
-    def integration_test_http_server_port_and_root(self):
+    def integration_test_port_and_root(self):
+        if not self.SCRIPT_NAME:
+            return
+
         tmpdir = tempfile.mkdtemp(prefix='webkitpytest')
-        self.maybe_make_dir(tmpdir, 'http', 'tests')
+        self.maybe_make_dir(tmpdir, 'http', 'tests', 'websocket')
         self.maybe_make_dir(tmpdir, 'fast', 'js', 'resources')
         self.maybe_make_dir(tmpdir, 'media')
 
-        self.assert_servers_are_down('localhost', [18000])
+        self.assert_servers_are_down([18000])
         self.assertEquals(self.run_script(['--server', 'start', '--port=18000', '--root', tmpdir]), 0)
-        self.assert_servers_are_up('localhost', [18000])
+        self.assert_servers_are_up([18000])
         self.assertEquals(self.run_script(['--server', 'stop']), 0)
-        self.assert_servers_are_down('localhost', [18000])
+        self.assert_servers_are_down([18000])
 
 
+class HTTPServerTest(BaseTest):
+    """Tests that new-run-webkit-http must pass."""
+
+    PORTS = (8000, 8080, 8443)
+    SCRIPT_NAME = 'new-run-webkit-httpd'
+
+
+class WebsocketserverTest(BaseTest):
+    """Tests that new-run-webkit-websocketserver must pass."""
+
+    # FIXME: test TLS at some point?
+    PORTS = (8880, )
+    SCRIPT_NAME = 'new-run-webkit-websocketserver'
+
+
 if __name__ == '__main__':
     port_testcase.main()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to