Add a script to process backlogs created while perf dashboard was in the maintenance...
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Feb 2016 01:05:14 +0000 (01:05 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Feb 2016 01:05:14 +0000 (01:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=154140

Reviewed by Chris Dumez.

Added a script to process the backlog JSONs created while the perf dashboard was put in the maintenance mode.
It re-submits each JSON file to the perf dashboard using the same server config file used by syncing scripts.

* public/include/report-processor.php:
(TestRunsGenerator::test_value_list_to_values_by_iterations): Fixed a bug in the error message code. It was
referencing an undeclared variable.
* tools/process-maintenance-backlog.py: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@196459 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/public/include/report-processor.php
Websites/perf.webkit.org/tools/process-maintenance-backlog.py [new file with mode: 0644]

index a1c39f0..b6f3a46 100644 (file)
@@ -1,5 +1,20 @@
 2016-02-11  Ryosuke Niwa  <rniwa@webkit.org>
 
+        Add a script to process backlogs created while perf dashboard was in the maintenance mode
+        https://bugs.webkit.org/show_bug.cgi?id=154140
+
+        Reviewed by Chris Dumez.
+
+        Added a script to process the backlog JSONs created while the perf dashboard was put in the maintenance mode.
+        It re-submits each JSON file to the perf dashboard using the same server config file used by syncing scripts.
+
+        * public/include/report-processor.php:
+        (TestRunsGenerator::test_value_list_to_values_by_iterations): Fixed a bug in the error message code. It was
+        referencing an undeclared variable.
+        * tools/process-maintenance-backlog.py: Added.
+
+2016-02-11  Ryosuke Niwa  <rniwa@webkit.org>
+
         AnalysisResultsViewer never uses this._smallerIsBetter
         https://bugs.webkit.org/show_bug.cgi?id=154134
 
index bd5c91d..545a83f 100644 (file)
@@ -335,7 +335,7 @@ class TestRunsGenerator {
             if (count($values) != count($group_sizes)) {
                 // FIXME: We should support bootstrapping or just computing the mean in this case.
                 $this->exit_with_error('IterationGroupCountIsInconsistent', array('parent' => $test_metric['test_id'],
-                    'metric' => $test_metric['metric_name'], 'childTest' => $name_and_values['name'],
+                    'metric' => $test_metric['metric_name'], 'childTest' => $test_name,
                     'valuesByIterations' => $values_by_iterations, 'values' => $values));
             }
 
@@ -345,7 +345,7 @@ class TestRunsGenerator {
                     $run_iteration_value = $values[$group][$i];
                     if (!is_numeric($run_iteration_value)) {
                         $this->exit_with_error('NonNumeralIterationValueForAggregation', array('parent' => $test_metric['test_id'],
-                            'metric' => $test_metric['metric_name'], 'childTest' => $name_and_values['name'],
+                            'metric' => $test_metric['metric_name'], 'childTest' => $test_name,
                             'valuesByIterations' => $values_by_iterations, 'values' => $values, 'index' => $i));
                     }
                     array_push($values_by_iterations[$flattened_iteration_index], $run_iteration_value);
diff --git a/Websites/perf.webkit.org/tools/process-maintenance-backlog.py b/Websites/perf.webkit.org/tools/process-maintenance-backlog.py
new file mode 100644 (file)
index 0000000..9f032d0
--- /dev/null
@@ -0,0 +1,95 @@
+#!/usr/bin/python
+
+import argparse
+import json
+import os
+import sys
+import urllib2
+
+from util import load_server_config
+
+
+def main():
+    parser = argparse.ArgumentParser()
+    parser.add_argument('--server-config-json', required=True, help='The path to a JSON file that specifies the perf dashboard.')
+    args = parser.parse_args()
+
+    maintenace_dir = determine_maintenance_dir()
+
+    server_config = load_server_config(args.server_config_json)
+
+    print 'Submitting results in "%s" to "%s"' % (maintenace_dir, server_config['server']['url'])
+
+    for filename in os.listdir(maintenace_dir):
+        path = os.path.join(maintenace_dir, filename)
+        if os.path.isfile(path) and filename.endswith('.json'):
+
+            with open(os.path.join(maintenace_dir, path)) as submitted_json_file:
+                submitted_content = submitted_json_file.read()
+
+            print '%s...' % filename,
+            sys.stdout.flush()
+
+            suffix = '.done'
+            while True:
+                if submit_report(server_config, submitted_content):
+                    break
+                if ask_yes_no_question('Suffix the file with .error and continue?'):
+                    suffix = '.error'
+                    break
+                else:
+                    sys.exit(0)
+
+            os.rename(path, path + suffix)
+
+            print 'Done'
+
+
+def determine_maintenance_dir():
+    root_dir = os.path.join(os.path.dirname(__file__), '../')
+
+    config_json_path = os.path.abspath(os.path.join(root_dir, 'config.json'))
+    with open(config_json_path) as config_json_file:
+        config = json.load(config_json_file)
+
+    dirname = config.get('maintenanceDirectory')
+    if not dirname:
+        sys.exit('maintenanceDirectory is not specified in config.json')
+
+    return os.path.abspath(os.path.join(root_dir, dirname))
+
+
+def ask_yes_no_question(question):
+    while True:
+        action = raw_input(question + ' (y/n): ')
+        if action == 'y' or action == 'yes':
+            return True
+        elif action == 'n' or action == 'no':
+            return False
+        else:
+            print 'Please answer by yes or no'
+
+
+def submit_report(server_config, payload):
+    try:
+        request = urllib2.Request(server_config['server']['url'] + '/api/report')
+        request.add_header('Content-Type', 'application/json')
+        request.add_header('Content-Length', len(payload))
+
+        output = urllib2.urlopen(request, payload).read()
+        try:
+            result = json.loads(output)
+        except Exception, error:
+            raise Exception(error, output)
+
+        if result.get('status') != 'OK':
+            raise Exception(result)
+
+        return True
+    except Exception as error:
+        print >> sys.stderr, 'Failed to submit commits: %s' % str(error)
+        return False
+
+
+if __name__ == "__main__":
+    main()