Changeset 196778 in webkit


Ignore:
Timestamp:
Feb 18, 2016, 2:31:49 PM (9 years ago)
Author:
jer.noble@apple.com
Message:

run-webkit-httpd should use webkitpy to run httpd.
https://bugs.webkit.org/show_bug.cgi?id=154271

Reviewed by Alexey Proskuryakov.

Update run-webkit-httpd to use webkitpy.port to launch httpd. Pass on http_port and http_all_interface
options to match the current run-webkit-httpd (optional) behavior.

  • Scripts/run-webkit-httpd:

(parse_args):
(main):

  • Scripts/webkitpy/layout_tests/servers/apache_http_server.py:

(LayoutTestApacheHttpd.init):

  • Scripts/webkitpy/layout_tests/servers/http_server.py:

(Lighttpd._prepare_config):

  • Scripts/webkitpy/port/base.py:

(Port.to.start_http_server):

Location:
trunk/Tools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r196756 r196778  
     12016-02-18  Jer Noble  <jer.noble@apple.com>
     2
     3        run-webkit-httpd should use webkitpy to run httpd.
     4        https://bugs.webkit.org/show_bug.cgi?id=154271
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        Update run-webkit-httpd to use webkitpy.port to launch httpd. Pass on http_port and http_all_interface
     9        options to match the current run-webkit-httpd (optional) behavior.
     10
     11        * Scripts/run-webkit-httpd:
     12        (parse_args):
     13        (main):
     14        * Scripts/webkitpy/layout_tests/servers/apache_http_server.py:
     15        (LayoutTestApacheHttpd.__init__):
     16        * Scripts/webkitpy/layout_tests/servers/http_server.py:
     17        (Lighttpd._prepare_config):
     18        * Scripts/webkitpy/port/base.py:
     19        (Port.to.start_http_server):
     20
    1212016-02-18  Filip Pizlo  <fpizlo@apple.com>
    222
  • trunk/Tools/Scripts/run-webkit-httpd

    r179405 r196778  
    1 #!/usr/bin/perl
     1#!/usr/bin/python
    22
    33# Copyright (C) 2005, 2006, 2007, 2015 Apple Inc.  All rights reserved.
     
    2929# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    3030
    31 # Script to run Apache with the same configuration as used in http layout tests.
     31import optparse
     32import subprocess
     33import sys
     34import tempfile
     35import time
    3236
    33 use strict;
    34 use warnings;
     37from webkitpy.common.host import Host
     38from webkitpy.port import platform_options
    3539
    36 use Cwd;
    37 use File::Path;
    38 use File::Basename;
    39 use Getopt::Long;
    40 use FindBin;
     40def parse_args(args):
     41    parser = optparse.OptionParser()
     42    parser.add_option("-a", "--all-interfaces", help="Bind to all interfaces", action="store_true", dest="http_all_interfaces")
     43    parser.add_option("-p", "--port", help="Bind to port NNNN", action="store", type="int", dest="http_port")
     44    return parser.parse_args(args)
    4145
    42 use lib $FindBin::Bin;
    43 use webkitperl::httpd;
    44 use webkitdirs;
     46def main(argv, stdout, stderr):
     47    options, args = parse_args(argv)
     48    host = Host()
    4549
    46 # FIXME: Dynamic HTTP-port configuration in this file is wrong.  The various
    47 # apache config files in LayoutTests/http/config govern the port numbers.
    48 # Dynamic configuration as-written will also cause random failures in
    49 # an IPv6 environment.  See https://bugs.webkit.org/show_bug.cgi?id=37104.
    50 # Argument handling
    51 my $httpdPort = 8000;
    52 my $allInterfaces = 0;
    53 my $showHelp;
     50    log_file = tempfile.NamedTemporaryFile()
     51    options.http_access_log = log_file.name
     52    options.http_error_log = log_file.name
     53    options.platform = None
    5454
    55 my $result = GetOptions(
    56     'all-interfaces|a' => \$allInterfaces,
    57     'help|h' => \$showHelp,
    58     'port=i' => \$httpdPort,
    59 );
     55    try:
     56        port = host.port_factory.get(options.platform, options)
     57    except NotImplementedError, e:
     58        print >> stderr, str(e)
     59        return EXCEPTIONAL_EXIT_STATUS
    6060
    61 if (!$result || @ARGV || $showHelp) {
    62     print "Usage: " . basename($0) . " [options]\n";
    63     print "  -a|--all-interfaces  Bind to all interfaces\n";
    64     print "  -h|--help            Show this help message\n";
    65     print "  -p|--port NNNN       Bind to port NNNN\n";
    66     exit 1;
    67 }
     61    # FIXME(154294): somehow retrieve the actual ports and interfaces bound by the httpd server
     62    http_port = options.http_port if options.http_port is not None else "8000"
     63    if options.http_all_interfaces is not None:
     64        print "Starting httpd on port %s (all interfaces)" % http_port
     65    else:
     66        print "Starting httpd on <http://127.0.0.1:%s>" % http_port
    6867
    69 setConfiguration();
    70 my $productDir = productDir();
    71 chdirWebKit();
    72 my $testDirectory = File::Spec->catfile(getcwd(), "LayoutTests");
    73 my $listen = "127.0.0.1:$httpdPort";
    74 $listen = "$httpdPort" if ($allInterfaces);
     68    port.start_http_server()
    7569
    76 if ($allInterfaces) {
    77     print "Starting httpd on port $httpdPort (all interfaces)...\n";
    78 } else {
    79     print "Starting httpd on <http://$listen/>...\n";
    80 }
    81 setShouldWaitForUserInterrupt();
    82 print "Press Ctrl+C to stop it.\n\n";
     70    try:
     71        tail = subprocess.Popen(['tail', '-F', log_file.name], stdout=subprocess.PIPE)
     72        while True:
     73            sys.stdout.write(tail.stdout.readline())
     74    except KeyboardInterrupt:
     75        port.stop_http_server()
    8376
    84 my @args = (
    85     "-C", "Listen $listen",
    86     # Run in single-process mode, do not detach from the controlling terminal.
    87     "-X",
    88     # Disable Keep-Alive support. Makes testing in multiple browsers easier (no need to wait
    89     # for another browser's connection to expire).
    90     "-c", "KeepAlive off"
    91 );
    92 
    93 if (!isAnyWindows()) {
    94     push(@args, "-c", "CustomLog |/usr/bin/tee common");
    95     push(@args, "-c", "ErrorLog |/usr/bin/tee");
    96 }
    97 
    98 my @defaultArgs = getDefaultConfigForTestDirectory($testDirectory);
    99 @args = (@defaultArgs, @args);
    100 openHTTPD(@args);
     77if __name__ == '__main__':
     78    sys.exit(main(sys.argv[1:], sys.stdout, sys.stderr))
  • trunk/Tools/Scripts/webkitpy/layout_tests/servers/apache_http_server.py

    r192944 r196778  
    4444
    4545class LayoutTestApacheHttpd(http_server_base.HttpServerBase):
    46     def __init__(self, port_obj, output_dir, additional_dirs=None):
     46    def __init__(self, port_obj, output_dir, additional_dirs=None, port=None):
    4747        """Args:
    4848          port_obj: handle to the platform-specific routines
     
    5252        # We use the name "httpd" instead of "apache" to make our paths (e.g. the pid file: /tmp/WebKit/httpd.pid)
    5353        # match old-run-webkit-tests: https://bugs.webkit.org/show_bug.cgi?id=63956
     54
    5455        self._name = 'httpd'
    55         self._mappings = [{'port': 8000},
    56                           {'port': 8080},
    57                           {'port': 8443, 'sslcert': True}]
     56        self._port = port
     57        if self._port is not None:
     58            self._mappings = [{'port': self._port}]
     59        else:
     60            self._mappings = [{'port': 8000},
     61                              {'port': 8080},
     62                              {'port': 8443, 'sslcert': True}]
    5863        self._output_dir = output_dir
    5964        self._filesystem.maybe_make_directory(output_dir)
     
    8085        error_log = self._filesystem.join(output_dir, "error_log.txt")
    8186        document_root = self._filesystem.join(test_dir, "http", "tests")
     87
     88        if port_obj.get_option('http_access_log'):
     89            access_log = port_obj.get_option('http_access_log')
     90
     91        if port_obj.get_option('http_error_log'):
     92            error_log = port_obj.get_option('http_error_log')
    8293
    8394        # FIXME: We shouldn't be calling a protected method of _port_obj!
     
    111122            enable_ipv6 = False
    112123
     124        bind_address = '' if self._port_obj.get_option("http_all_interfaces") else '127.0.0.1:'
     125
    113126        for mapping in self._mappings:
    114127            port = mapping['port']
    115128
    116             start_cmd += ['-C', "\'Listen 127.0.0.1:%d\'" % port]
     129            start_cmd += ['-C', "\'Listen %s%d\'" % (bind_address, port)]
    117130
    118131            # We listen to both IPv4 and IPv6 loop-back addresses, but ignore
  • trunk/Tools/Scripts/webkitpy/layout_tests/servers/http_server.py

    r176830 r196778  
    9595        error_log = os.path.join(self._output_dir, log_file_name)
    9696
     97        if self._port_obj.get_option('http_access_log'):
     98            access_log = self._port_obj.get_option('http_access_log')
     99
     100        if self._port_obj.get_option('http_error_log'):
     101            error_log = self._port_obj.get_option('http_error_log')
     102
    97103        # Write out the config
    98104        base_conf = self._filesystem.read_text_file(base_conf_file)
     
    150156        else:
    151157            mappings = self.VIRTUALCONFIG
     158
     159        bind_address = '' if self._port_obj.get_option('http_all_addresses') else '127.0.0.1'
    152160        for mapping in mappings:
    153161            ssl_setup = ''
     
    156164                             '  ssl.pemfile = "%s"\n' % mapping['sslcert'])
    157165
    158             f.write(('$SERVER["socket"] == "127.0.0.1:%d" {\n'
     166            f.write(('$SERVER["socket"] == "%s:%d" {\n'
    159167                     '  server.document-root = "%s"\n' +
    160168                     ssl_setup +
    161                      '}\n\n') % (mapping['port'], mapping['docroot']))
     169                     '}\n\n') % (bind_address, mapping['port'], mapping['docroot']))
    162170        f.close()
    163171
  • trunk/Tools/Scripts/webkitpy/port/base.py

    r194761 r196778  
    906906        Ports can stub this out if they don't need a web server to be running."""
    907907        assert not self._http_server, 'Already running an http server.'
    908 
     908        http_port = self.get_option('http_port')
    909909        if self._uses_apache():
    910             server = apache_http_server.LayoutTestApacheHttpd(self, self.results_directory(), additional_dirs=additional_dirs)
     910            server = apache_http_server.LayoutTestApacheHttpd(self, self.results_directory(), additional_dirs=additional_dirs, port=http_port)
    911911        else:
    912             server = http_server.Lighttpd(self, self.results_directory(), additional_dirs=additional_dirs)
     912            server = http_server.Lighttpd(self, self.results_directory(), additional_dirs=additional_dirs, port=http_port)
    913913
    914914        server.start()
Note: See TracChangeset for help on using the changeset viewer.