From 7bda35a1e36cc863adf58c8d3db1d7ed3b795b8f Mon Sep 17 00:00:00 2001 From: "rniwa@webkit.org" Date: Sat, 19 Oct 2013 01:47:40 +0000 Subject: [PATCH] New flakiness dashboard should support showing the failing tests per builder https://bugs.webkit.org/show_bug.cgi?id=123011 Reviewed by Timothy Hatcher. Added the feature. Also did some refactoring to add this feature. * ChangeLog: Added. * api/failing-tests.php: Added. * api/manifest.php: Removed the code to make maps by id. The work is now done in index.html. * api/results.php: * common.css: Added. Extracted from index.html. * include/test-results.php: Extracted parse_revisions_array and format_result_rows from results.php. * index.html: * main.css: Added. (TestResultsView.setAvailableTests): Added. (TestResultsView.showTooltip): Fixed the code to compute x and y coordinates of the tooltip to take scrolled positions into account. (TestResultsView._createTestResultRow): Extracted from _populateTestPane. (TestResultsView.fetchTest): Added the code to show "Loading..." in the pane while loading the JSON. (TestResultsView.fetchTests): Respect the doNotUpdateHash flag. (TestResultsView._populateBuilderPane): Added. (TestResultsView.fetchFailingTestsForBuilder): Added. (TestResultsView.updateLocationHash): Serialize builder & builderDays. (TestResultsView.locationHashChanged): Don't delete existing test panes since that's now done in loadTestsFromLocationHash. (TestResultsView.loadTestsFromLocationHash): Take care of both 'tests' and 'builder' components. (fetchManifest): Setup the UI to select a builder. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@157659 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Websites/test-results/ChangeLog | 31 +++ Websites/test-results/api/failing-tests.php | 33 +++ Websites/test-results/api/manifest.php | 23 +- Websites/test-results/api/results.php | 30 +-- Websites/test-results/common.css | 65 +++++ Websites/test-results/include/test-results.php | 27 ++ Websites/test-results/index.html | 335 ++++++++++--------------- Websites/test-results/main.css | 163 ++++++++++++ 8 files changed, 463 insertions(+), 244 deletions(-) create mode 100644 Websites/test-results/ChangeLog create mode 100644 Websites/test-results/api/failing-tests.php create mode 100644 Websites/test-results/common.css create mode 100644 Websites/test-results/main.css diff --git a/Websites/test-results/ChangeLog b/Websites/test-results/ChangeLog new file mode 100644 index 0000000..8172a02 --- /dev/null +++ b/Websites/test-results/ChangeLog @@ -0,0 +1,31 @@ +2013-10-18 Ryosuke Niwa + + New flakiness dashboard should support showing the failing tests per builder + https://bugs.webkit.org/show_bug.cgi?id=123011 + + Reviewed by Timothy Hatcher. + + Added the feature. Also did some refactoring to add this feature. + + * ChangeLog: Added. + * api/failing-tests.php: Added. + * api/manifest.php: Removed the code to make maps by id. The work is now done in index.html. + * api/results.php: + * common.css: Added. Extracted from index.html. + * include/test-results.php: Extracted parse_revisions_array and format_result_rows from results.php. + * index.html: + * main.css: Added. + (TestResultsView.setAvailableTests): Added. + (TestResultsView.showTooltip): Fixed the code to compute x and y coordinates of the tooltip to take + scrolled positions into account. + (TestResultsView._createTestResultRow): Extracted from _populateTestPane. + (TestResultsView.fetchTest): Added the code to show "Loading..." in the pane while loading the JSON. + (TestResultsView.fetchTests): Respect the doNotUpdateHash flag. + (TestResultsView._populateBuilderPane): Added. + (TestResultsView.fetchFailingTestsForBuilder): Added. + (TestResultsView.updateLocationHash): Serialize builder & builderDays. + (TestResultsView.locationHashChanged): Don't delete existing test panes since that's now done in + loadTestsFromLocationHash. + (TestResultsView.loadTestsFromLocationHash): Take care of both 'tests' and 'builder' components. + (fetchManifest): Setup the UI to select a builder. + diff --git a/Websites/test-results/api/failing-tests.php b/Websites/test-results/api/failing-tests.php new file mode 100644 index 0000000..8cf2b5b --- /dev/null +++ b/Websites/test-results/api/failing-tests.php @@ -0,0 +1,33 @@ + '/^[A-Za-z0-9 \(\)\-_]+$/')); +$builder_name = $_GET['builder']; +$number_of_days = array_get($_GET, 'days'); +if ($number_of_days) { + require_format('number_of_days', $number_of_days, '/^[0-9]+$/'); + $number_of_days = intval($number_of_days); +} else + $number_of_days = 3; + +$builder_row = $db->select_first_row('builders', NULL, array('name' => $builder_name)); +if (!$builder_row) + exit_with_error('BuilderNotFound'); +$builder_id = $builder_row['id']; + +$result_rows = $db->query_and_fetch_all( +'SELECT results.*, builds.*, array_agg((build_revisions.repository, build_revisions.value, build_revisions.time)) AS revisions + FROM results, builds, build_revisions + WHERE build_revisions.build = builds.id AND results.build = builds.id AND builds.builder = $1 + AND results.actual != $2 AND builds.start_time > now() - interval \'' . $number_of_days . ' days\' + GROUP BY results.id, builds.id', array($builder_id, 'PASS')); +if (!$result_rows) + exit_with_error('ResultsNotFound'); + +exit_with_success(format_result_rows($result_rows)); + +?> diff --git a/Websites/test-results/api/manifest.php b/Websites/test-results/api/manifest.php index 672b78a..19cf6f9 100644 --- a/Websites/test-results/api/manifest.php +++ b/Websites/test-results/api/manifest.php @@ -3,25 +3,10 @@ require_once('../include/json-shared.php'); $db = connect(); -$tests = $db->fetch_table('tests'); -function fetch_table_and_create_map_by_id($table_name) { - global $db; - - $rows = $db->fetch_table($table_name); - if (!$rows) - return array(); - - $results = array(); - foreach ($rows as $row) { - $results[$row['id']] = $row; - } - return $results; -} - -exit_with_success(array('tests' => $tests, - 'builders' => fetch_table_and_create_map_by_id('builders'), - 'slaves' => fetch_table_and_create_map_by_id('slaves'), - 'repositories' => fetch_table_and_create_map_by_id('repositories'))); +exit_with_success(array('tests' => $db->fetch_table('tests'), + 'builders' => $db->fetch_table('builders'), + 'slaves' => $db->fetch_table('slaves'), + 'repositories' => $db->fetch_table('repositories'))); ?> diff --git a/Websites/test-results/api/results.php b/Websites/test-results/api/results.php index 0dd6a27..1883ea0 100644 --- a/Websites/test-results/api/results.php +++ b/Websites/test-results/api/results.php @@ -1,6 +1,7 @@ query_and_fetch_all( 'SELECT results.*, builds.*, array_agg((build_revisions.repository, build_revisions.value, build_revisions.time)) AS revisions FROM results, builds, build_revisions - WHERE build_revisions.build = builds.id AND results.test = $1 AND results.build = builds.id + WHERE build_revisions.build = builds.id AND results.build = builds.id AND results.test = $1 GROUP BY results.id, builds.id', array($test['id'])); if (!$result_rows) exit_with_error('ResultsNotFound'); -date_default_timezone_set('UTC'); -function parse_revisions_array($postgres_array) { - // e.g. {"(WebKit,131456,\"2012-10-16 14:53:00\")","(Safari,162004,)"} - $outer_array = json_decode('[' . trim($postgres_array, '{}') . ']'); - $revisions = array(); - foreach ($outer_array as $item) { - $name_and_revision = explode(',', trim($item, '()')); - $time = strtotime(trim($name_and_revision[2], '"')) * 1000; - $revisions[trim($name_and_revision[0], '"')] = array(trim($name_and_revision[1], '"'), $time); - } - return $revisions; -} - -$builders = array(); -foreach ($result_rows as $result) { - array_push(array_ensure_item_has_array($builders, $result['builder']), - array('buildTime' => strtotime($result['start_time']) * 1000, - 'revisions' => parse_revisions_array($result['revisions']), - 'builder' => $result['builder'], - 'slave' => $result['slave'], - 'buildNumber' => $result['number'], - 'actual' => $result['actual'], - 'expected' => $result['expected'])); -} - -exit_with_success(array('builders' => $builders)); +exit_with_success(format_result_rows($result_rows)); ?> diff --git a/Websites/test-results/common.css b/Websites/test-results/common.css new file mode 100644 index 0000000..dcb6a24 --- /dev/null +++ b/Websites/test-results/common.css @@ -0,0 +1,65 @@ + +html, body { + margin: 0; + padding: 0; +} + +body { + background-repeat: repeat-x; + font-family: sans-serif; + padding: 10px; +} + +#title { + background-image: linear-gradient(bottom, rgb(240,240,240) 31%, rgb(255,255,255) 90%); + background-image: -o-linear-gradient(bottom, rgb(240,240,240) 31%, rgb(255,255,255) 90%); + background-image: -moz-linear-gradient(bottom, rgb(240,240,240) 31%, rgb(255,255,255) 90%); + background-image: -webkit-linear-gradient(bottom, rgb(240,240,240) 31%, rgb(255,255,255) 90%); + background-image: -ms-linear-gradient(bottom, rgb(240,240,240) 31%, rgb(255,255,255) 90%); + -moz-box-shadow: 1px 1px 3px 1px #ccc; + -webkit-box-shadow: 1px 1px 3px 1px #ccc; + box-shadow: 1px 1px 3px 1px #ccc; + padding: 5px 10px; + margin: 0 0 20px 0; + border-radius: 5px; + position: relative; +} + +#title h1 { + font-weight: normal; + text-shadow: #bbb 1px 1px 2px; + margin: 0; + padding: 0; + font-size: 2em; +} +#title li, #title ul { + list-style: none; + margin: 0; + padding: 0; +} + +#title li { + display: inline; +} + +#title li:after { + content: ' | '; +} + +#title li:last-child:after { + content: ''; +} + +#title ul { + position: absolute; + vertical-align: middle; + top: 5px; + right: 20px; + padding-top: 0.6em; +} + +a { + text-decoration: none; + color: #000; + text-shadow: #bbb 1px 1px 2px; +} diff --git a/Websites/test-results/include/test-results.php b/Websites/test-results/include/test-results.php index d77e05f..af92be1 100644 --- a/Websites/test-results/include/test-results.php +++ b/Websites/test-results/include/test-results.php @@ -66,4 +66,31 @@ function recursively_add_test_results($db, $build_id, $tests, $full_name) { 'expected' => $tests['expected'], 'actual' => $tests['actual'])); } +date_default_timezone_set('UTC'); +function parse_revisions_array($postgres_array) { + // e.g. {"(WebKit,131456,\"2012-10-16 14:53:00\")","(Safari,162004,)"} + $outer_array = json_decode('[' . trim($postgres_array, '{}') . ']'); + $revisions = array(); + foreach ($outer_array as $item) { + $name_and_revision = explode(',', trim($item, '()')); + $time = strtotime(trim($name_and_revision[2], '"')) * 1000; + $revisions[trim($name_and_revision[0], '"')] = array(trim($name_and_revision[1], '"'), $time); + } + return $revisions; +} + +function format_result_rows($result_rows) { + $builders = array(); + foreach ($result_rows as $result) { + array_push(array_ensure_item_has_array(array_ensure_item_has_array($builders, $result['builder']), $result['test']), + array('buildTime' => strtotime($result['start_time']) * 1000, + 'revisions' => parse_revisions_array($result['revisions']), + 'slave' => $result['slave'], + 'buildNumber' => $result['number'], + 'actual' => $result['actual'], + 'expected' => $result['expected'])); + } + return array('builders' => $builders); +} + ?> diff --git a/Websites/test-results/index.html b/Websites/test-results/index.html index 367375c..01f1ab6 100644 --- a/Websites/test-results/index.html +++ b/Websites/test-results/index.html @@ -2,7 +2,8 @@ WebKit Test Results - + + @@ -16,178 +17,22 @@ - +
-
-
- -