Changeset 190900 in webkit


Ignore:
Timestamp:
Oct 12, 2015, 4:05:43 PM (10 years ago)
Author:
rniwa@webkit.org
Message:

Perf dashboard tools shouldn't require server credentials in multiple configuration files
https://bugs.webkit.org/show_bug.cgi?id=149994

Reviewed by Chris Dumez.

Made detect-changes.js and pull-svn.py pull username and passwords from the server config JSON to reduce
the number of JSON files that need to include credentials.

Also made each script reload the server config after sleep to allow dynamic credential updates.

In addition, change the server config JSON's format to include scheme, host, and port numbers separately
instead of a url since detect-changes.js needs each value separately.

This reduces the number of JSONs with credentials to two for our internal dashboard.

  • tools/detect-changes.js:

(main): Added a property argument parsing. Now takes --server-config-json, --change-detection-config-json,
and --seconds-to-sleep like other scripts.
(parseArgument): Added.
(fetchManifestAndAnalyzeData): Reload the server config JSON.
(loadServerConfig): Added. Set settings.perfserver and settings.slave from the server config JSON. Also
add settings.perfserver.host to match the old format.
(configurationsForTesting): Fixed a bug that we throw an exception when a dashboard contains an empty cell.

  • tools/pull-os-versions.py:

(main): Use load_server_config after each sleep.

  • tools/pull-svn.py:

(main): Use load_server_config after each sleep.
(fetch_commits_and_submit): Use the perf dashboard's auth as subversion credential when useServerAuth is set.

  • tools/sync-with-buildbot.py:

(main): Use load_server_config after each sleep.

  • tools/util.py:

(load_server_config): Extracted from python scripts. Computes server's url from scheme, host, and port number
to match the old format python scripts except.

Location:
trunk/Websites/perf.webkit.org
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Websites/perf.webkit.org/ChangeLog

    r190898 r190900  
     12015-10-12  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Perf dashboard tools shouldn't require server credentials in multiple configuration files
     4        https://bugs.webkit.org/show_bug.cgi?id=149994
     5
     6        Reviewed by Chris Dumez.
     7
     8        Made detect-changes.js and pull-svn.py pull username and passwords from the server config JSON to reduce
     9        the number of JSON files that need to include credentials.
     10
     11        Also made each script reload the server config after sleep to allow dynamic credential updates.
     12
     13        In addition, change the server config JSON's format to include scheme, host, and port numbers separately
     14        instead of a url since detect-changes.js needs each value separately.
     15
     16        This reduces the number of JSONs with credentials to two for our internal dashboard.
     17
     18        * tools/detect-changes.js:
     19        (main): Added a property argument parsing. Now takes --server-config-json, --change-detection-config-json,
     20        and --seconds-to-sleep like other scripts.
     21        (parseArgument): Added.
     22        (fetchManifestAndAnalyzeData): Reload the server config JSON.
     23        (loadServerConfig): Added. Set settings.perfserver and settings.slave from the server config JSON. Also
     24        add settings.perfserver.host to match the old format.
     25        (configurationsForTesting): Fixed a bug that we throw an exception when a dashboard contains an empty cell.
     26
     27        * tools/pull-os-versions.py:
     28        (main): Use load_server_config after each sleep.
     29
     30        * tools/pull-svn.py:
     31        (main): Use load_server_config after each sleep.
     32        (fetch_commits_and_submit): Use the perf dashboard's auth as subversion credential when useServerAuth is set.
     33
     34        * tools/sync-with-buildbot.py:
     35        (main): Use load_server_config after each sleep.
     36
     37        * tools/util.py:
     38        (load_server_config): Extracted from python scripts. Computes server's url from scheme, host, and port number
     39        to match the old format python scripts except.
     40
    1412015-10-11  Ryosuke Niwa  <rniwa@webkit.org>
    242
  • trunk/Websites/perf.webkit.org/tools/detect-changes.js

    r183232 r190900  
    88var Statistics = require('../public/v2/js/statistics.js');
    99
     10// FIXME: We shouldn't use a global variable like this.
    1011var settings;
    1112function main(argv)
    1213{
    13     if (argv.length < 3) {
    14         console.error('Please specify the settings JSON path');
    15         return 1;
    16     }
    17 
    18     settings = JSON.parse(fs.readFileSync(argv[2], 'utf8'));
    19 
    20     fetchManifestAndAnalyzeData();
    21 }
    22 
    23 function fetchManifestAndAnalyzeData()
    24 {
     14    var options = parseArgument(argv, [
     15        {name: '--server-config-json', required: true},
     16        {name: '--change-detection-config-json', required: true},
     17        {name: '--seconds-to-sleep', type: parseFloat, default: 1200},
     18    ]);
     19    if (!options)
     20        return;
     21
     22    settings = JSON.parse(fs.readFileSync(options['--change-detection-config-json'], 'utf8'));
     23    settings.secondsToSleep = options['--seconds-to-sleep'];
     24
     25    fetchManifestAndAnalyzeData(options['--server-config-json']);
     26}
     27
     28function parseArgument(argv, acceptedOptions) {
     29    var args = argv.slice(2);
     30    var options = {}
     31    for (var i = 0; i < args.length; i += 2) {
     32        var current = args[i];
     33        var next = args[i + 1];
     34        for (var option of acceptedOptions) {
     35            if (current == option['name']) {
     36                options[option['name']] = next;
     37                next = null;
     38                break;
     39            }
     40        }
     41        if (next) {
     42            console.error('Invalid argument:', current);
     43            return null;
     44        }
     45    }
     46    for (var option of acceptedOptions) {
     47        var name = option['name'];
     48        if (option['required'] && !(name in options)) {
     49            console.log('Required argument', name, 'is missing');
     50            return null;
     51        }
     52        var value = options[name] || option['default'];
     53        var converter = option['type'];
     54        options[name] = converter ? converter(value) : value;
     55    }
     56    return options;
     57}
     58
     59function fetchManifestAndAnalyzeData(serverConfigJSON)
     60{
     61    loadServerConfig(serverConfigJSON);
     62
    2563    getJSON(settings.perfserver, '/data/manifest.json').then(function (manifest) {
    2664        return mapInOrder(configurationsForTesting(manifest), analyzeConfiguration);
    2765    }).catch(function (reason) {
    28         console.error('Failed to obtain the manifest file');
     66        console.error('Failed to obtain the manifest file', reason);
    2967    }).then(function () {
    3068        console.log('');
    3169        console.log('Sleeing for', settings.secondsToSleep, 'seconds');
    32         setTimeout(fetchManifestAndAnalyzeData, settings.secondsToSleep * 1000);
    33     });
     70        setTimeout(function () {
     71            fetchManifestAndAnalyzeData(serverConfigJSON);
     72        }, settings.secondsToSleep * 1000);
     73    });
     74}
     75
     76function loadServerConfig(serverConfigJSON)
     77{
     78    var serverConfig = JSON.parse(fs.readFileSync(serverConfigJSON, 'utf8'));
     79
     80    var server = serverConfig['server'];
     81    if ('auth' in server)
     82        server['auth'] = server['auth']['username'] + ':' + server['auth']['password'];
     83
     84    settings.perfserver = server;
     85    settings.slave = serverConfig['slave'];
    3486}
    3587
     
    55107        for (var row of dashboard) {
    56108            for (var cell of row) {
    57                 if (cell instanceof Array)
    58                     configurations.push({platformId: parseInt(cell[0]), metricId: parseInt(cell[1])});
     109                if (cell instanceof Array) {
     110                    var platformId = parseInt(cell[0]);
     111                    var metricId = parseInt(cell[1]);
     112                    if (!isNaN(platformId) && !isNaN(metricId))
     113                        configurations.push({platformId: platformId, metricId: metricId});
     114                }
    59115            }
    60116        }
  • trunk/Websites/perf.webkit.org/tools/pull-os-versions.py

    r190817 r190900  
    1515from util import submit_commits
    1616from util import text_content
    17 from util import setup_auth
     17from util import load_server_config
    1818
    1919
     
    2828        os_config_list = json.load(os_config_json)
    2929
    30     with open(args.server_config_json) as server_config_json:
    31         server_config = json.load(server_config_json)
    32         setup_auth(server_config['server'])
    33 
    3430    fetchers = [OSBuildFetcher(os_config) for os_config in os_config_list]
    3531
    3632    while True:
     33        server_config = load_server_config(args.server_config_json)
    3734        for fetcher in fetchers:
    3835            fetcher.fetch_and_report_new_builds(server_config)
  • trunk/Websites/perf.webkit.org/tools/pull-svn.py

    r190764 r190900  
    1010
    1111from xml.dom.minidom import parseString as parseXmlString
    12 from util import setup_auth
     12from util import load_server_config
    1313from util import submit_commits
    1414from util import text_content
     
    2323    args = parser.parse_args()
    2424
    25     with open(args.server_config_json) as server_config_json:
    26         server_config = json.load(server_config_json)
    27         setup_auth(server_config['server'])
    28 
    2925    with open(args.svn_config_json) as svn_config_json:
    3026        svn_config = json.load(svn_config_json)
    3127
    3228    while True:
     29        server_config = load_server_config(args.server_config_json)
    3330        for repository_info in svn_config:
    3431            fetch_commits_and_submit(repository_info, server_config, args.max_fetch_count)
     
    4441        print "Determining the stating revision for %s" % repository['name']
    4542        repository['revisionToFecth'] = determine_first_revision_to_fetch(server_config['server']['url'], repository['name'])
     43
     44    if 'useServerAuth' in repository:
     45        repository['username'] = server_config['server']['auth']['username']
     46        repository['password'] = server_config['server']['auth']['password']
    4647
    4748    pending_commits = []
  • trunk/Websites/perf.webkit.org/tools/sync-with-buildbot.py

    r186033 r190900  
    1010import urllib2
    1111
    12 from util import setup_auth
     12from util import load_server_config
    1313
    1414
     
    2828    configurations = load_config(args.builder_config_json, args.buildbot_url.strip('/'))
    2929
    30     with open(args.server_config_json) as server_config_json:
    31         server_config = json.load(server_config_json)
    32         setup_auth(server_config['server'])
    33 
    34     build_requests_url = server_config['server']['url'] + '/api/build-requests/' + args.triggerable
    35 
    3630    request_updates = {}
    3731    while True:
     32        server_config = load_server_config(args.server_config_json)
    3833        request_updates.update(find_request_updates(configurations, args.lookback_count))
    3934        if request_updates:
     
    4641            'slaveName': server_config['slave']['name'],
    4742            'slavePassword': server_config['slave']['password']}
     43
     44        build_requests_url = server_config['server']['url'] + '/api/build-requests/' + args.triggerable
    4845        response = update_and_fetch_build_requests(build_requests_url, payload)
    4946        open_requests = response.get('buildRequests', [])
  • trunk/Websites/perf.webkit.org/tools/util.py

    r186033 r190900  
    5252    auth_handler = HTTP_AUTH_HANDLERS[auth['type']](password_manager)
    5353    urllib2.install_opener(urllib2.build_opener(auth_handler))
     54
     55
     56def load_server_config(json_path):
     57    with open(json_path) as server_config_json:
     58        server_config = json.load(server_config_json)
     59        server = server_config['server']
     60        server['url'] = server['scheme'] + '://' + server['host'] + ':' + str(server['port'])
     61        setup_auth(server)
     62        return server_config
Note: See TracChangeset for help on using the changeset viewer.