Skip to content

Commit 1ea7e35

Browse files
WeizhongXChromium LUCI CQ
authored and
Chromium LUCI CQ
committed
Support diffing results between content shell and Chrome linux
plus some minor changes: 1. mention product name in CSV head explicitly 2. Add --ignore-missing to ignore legacy tests on content shell 3. Do not handle flakiness if no flaky data found for some products Change-Id: Ia221e1fac535a03317b12ea1fee66878717da1ba Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3077538 Reviewed-by: Rakib Hasan <rmhasan@google.com> Commit-Queue: Weizhong Xia <weizhong@google.com> Cr-Commit-Position: refs/heads/master@{#909938}
1 parent 072a5d0 commit 1ea7e35

File tree

2 files changed

+79
-34
lines changed

2 files changed

+79
-34
lines changed

third_party/blink/tools/diff_wpt_results.py

+67-28
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,32 @@
3838
from blinkpy.web_tests.port.android import (
3939
PRODUCTS, PRODUCTS_TO_STEPNAMES)
4040

41-
CSV_HEADING = ('Test name, Test Result, Baseline Result, '
41+
CSV_HEADING = ('Test name, %s Result, %s Result, '
4242
'Result Comparison, Test Flaky Results, '
4343
'Baseline Flaky Results, Unreliable Comparison\n')
4444
YES = 'Yes'
4545
NO = 'No'
4646
_log = logging.getLogger(os.path.basename(__file__))
47+
48+
# Extend this script to compare the results between wptrunner/Chrome
49+
# and rwt/content_shell on Linux
50+
PRODUCTS = PRODUCTS + ['chrome_linux', 'content_shell']
51+
PRODUCTS_TO_STEPNAMES.update({
52+
'chrome_linux': 'wpt_tests_suite',
53+
'content_shell': 'blink_web_tests'})
54+
PRODUCTS_TO_BUILDER_NAME = {
55+
'android_weblayer': 'android-weblayer-pie-x86-wpt-fyi-rel',
56+
'android_webview': 'android-webview-pie-x86-wpt-fyi-rel',
57+
'chrome_android': 'android-web-platform-pie-x86-fyi-rel',
58+
'chrome_linux': 'linux-wpt-fyi-rel',
59+
'content_shell': "Linux Tests"}
60+
4761
STEP_NAME_VARIANTS = {
4862
'chrome_public_wpt': ['chrome_public_wpt on Ubuntu-16.04 or Ubuntu-18.04'],
49-
'weblayer_shell_wpt': ['weblayer_shell_wpt on Ubuntu-16.04 or Ubuntu-18.04']
63+
'weblayer_shell_wpt': ['weblayer_shell_wpt on Ubuntu-16.04 or Ubuntu-18.04'],
64+
'system_webview_wpt': ['system_webview_wpt on Ubuntu-16.04 or Ubuntu-18.04'],
65+
'wpt_tests_suite': ['wpt_tests_suite on Ubuntu-18.04'],
66+
'blink_web_tests': ['blink_web_tests on Ubuntu-18.04']
5067
}
5168

5269
def map_tests_to_results(output_mp, input_mp, path=''):
@@ -60,30 +77,38 @@ def map_tests_to_results(output_mp, input_mp, path=''):
6077
class WPTResultsDiffer(object):
6178

6279
def __init__(self, args, host, actual_results_map,
63-
baseline_results_map, csv_output):
80+
baseline_results_map, csv_output, ignore_missing=False):
6481
self._args = args
6582
self._host = host
6683
self._actual_results_map = actual_results_map
6784
self._baseline_results_map = baseline_results_map
6885
self._csv_output = csv_output
69-
self._test_flaky_results = self._get_flaky_test_results(
70-
args.product_to_compare)
71-
self._baseline_flaky_results = self._get_flaky_test_results(
72-
args.baseline_product)
86+
self._ignore_missing = ignore_missing
87+
self._test_flaky_results = None
88+
self._baseline_flaky_results = None
89+
90+
try:
91+
self._test_flaky_results = self._get_flaky_test_results(
92+
args.product_to_compare)
93+
except:
94+
_log.info('Failed to get flaky results for %s' % args.product_to_compare)
95+
96+
try:
97+
self._baseline_flaky_results = self._get_flaky_test_results(
98+
args.baseline_product)
99+
except:
100+
_log.info('Failed to get flaky results for %s' % args.baseline_product)
101+
102+
self._handle_flaky = self._test_flaky_results is not None \
103+
and self._baseline_flaky_results is not None
73104

74105
def _get_flaky_test_results(self, product):
75106
return self._get_bot_expectations(product).flakes_by_path(
76107
False, ignore_bot_expected_results=True,
77108
consider_only_flaky_runs=False)
78109

79110
def _get_bot_expectations(self, product):
80-
specifiers = [product]
81-
builders = self._host.builders.filter_builders(
82-
include_specifiers=specifiers)
83-
assert len(builders) == 1, (
84-
'Multiple builders match the specifiers %s' % specifiers)
85-
86-
builder_name = builders[0]
111+
builder_name = PRODUCTS_TO_BUILDER_NAME[product]
87112
bot_expectations_factory = BotTestExpectationsFactory(
88113
self._host.builders, PRODUCTS_TO_STEPNAMES[product])
89114

@@ -96,7 +121,8 @@ def flaky_results(self, test_name, flaky_dict):
96121
def create_csv(self):
97122
super_set = (set(self._actual_results_map.keys()) |
98123
set(self._baseline_results_map.keys()))
99-
file_output = CSV_HEADING
124+
file_output = CSV_HEADING % (self._args.product_to_compare,
125+
self._args.baseline_product)
100126

101127
for test in sorted(super_set):
102128
if ',' in test:
@@ -112,11 +138,13 @@ def create_csv(self):
112138
if line[-1] == line[-2]:
113139
line.append('SAME RESULTS')
114140
elif 'MISSING' in (line[-1], line[-2]):
141+
if self._ignore_missing:
142+
continue
115143
line.append('MISSING RESULTS')
116144
else:
117145
line.append('DIFFERENT RESULTS')
118146

119-
if line[-1] != 'MISSING RESULTS':
147+
if self._handle_flaky and line[-1] != 'MISSING RESULTS':
120148
test_flaky_results = self.flaky_results(
121149
test, self._test_flaky_results)
122150

@@ -169,19 +197,15 @@ def _get_product_test_results(host, product, results_path=None):
169197
else:
170198
_log.info(('Retrieving test results for '
171199
'product %s using the bb command'), product)
172-
specifiers = [product]
173-
builders = host.builders.filter_builders(
174-
include_specifiers=specifiers)
175-
assert len(builders) == 1
176-
177-
builder_name = builders[0]
200+
builder_name = PRODUCTS_TO_BUILDER_NAME[product]
201+
# TODO: Note the builder name and number in the CSV file
178202
latest_build = host.bb_agent.get_latest_finished_build(
179203
builder_name)
180204
_log.debug('The latest build for %s is %d',
181205
builder_name, latest_build.build_number)
182206

183207
build_results = _get_build_test_results(host, product, latest_build)
184-
json_results_obj = tempfile.TemporaryFile()
208+
json_results_obj = tempfile.NamedTemporaryFile()
185209
json_results_obj.write(json.dumps(build_results))
186210
json_results_obj.seek(0)
187211

@@ -197,16 +221,19 @@ def main(args):
197221
help='Path to baseline test results JSON file')
198222
parser.add_argument('--baseline-product', required=True, action='store',
199223
choices=PRODUCTS,
200-
help='Name of the baseline WPT product')
224+
help='Name of the baseline product')
201225
parser.add_argument('--test-results-to-compare', required=False,
202226
help='Path to actual test results JSON file')
203227
parser.add_argument('--product-to-compare', required=True, action='store',
204228
choices=PRODUCTS,
205-
help='Name of the WPT product being compared')
229+
help='Name of the product being compared')
206230
parser.add_argument('--csv-output', required=True,
207231
help='Path to CSV output file')
208232
parser.add_argument('--verbose', '-v', action='count', default=1,
209233
help='Verbosity level')
234+
parser.add_argument('--ignore-missing', action='store_true',
235+
required=False, default=False,
236+
help='Ignore tests that are not run for one of the product')
210237
args = parser.parse_args()
211238

212239
if args.verbose >= 3:
@@ -240,14 +267,26 @@ def main(args):
240267
# names to their results map
241268
tests_to_actual_results = {}
242269
tests_to_baseline_results = {}
270+
if args.product_to_compare == 'chrome_linux':
271+
path = '/external/wpt'
272+
else:
273+
path = ''
243274
map_tests_to_results(tests_to_actual_results,
244-
actual_results_json['tests'])
275+
actual_results_json['tests'],
276+
path=path)
277+
278+
if args.baseline_product == 'chrome_linux':
279+
path = '/external/wpt'
280+
else:
281+
path = ''
245282
map_tests_to_results(tests_to_baseline_results,
246-
baseline_results_json['tests'])
283+
baseline_results_json['tests'],
284+
path=path)
247285

248286
# Create a CSV file which compares tests results to baseline results
249287
WPTResultsDiffer(args, host, tests_to_actual_results,
250-
tests_to_baseline_results, csv_output).create_csv()
288+
tests_to_baseline_results, csv_output,
289+
args.ignore_missing).create_csv()
251290

252291
return 0
253292

third_party/blink/tools/diff_wpt_results_unittest.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ def test_name_with_comma_escaped_in_csv(self):
8686
MockWPTResultsDiffer(actual_mp, actual_mp, csv_out).create_csv()
8787
csv_out.seek(0)
8888
content = csv_out.read()
89-
self.assertEquals(content, CSV_HEADING +
89+
heading = CSV_HEADING % (TEST_PRODUCT, TEST_BASELINE_PRODUCT)
90+
self.assertEquals(content, heading +
9091
('"test, name.html",PASS,PASS,'
9192
'SAME RESULTS,"{FAIL, TIMEOUT, PASS}",'
9293
'"{CRASH, PASS}",Yes\n'))
@@ -97,7 +98,8 @@ def test_create_csv_with_same_result(self):
9798
MockWPTResultsDiffer(actual_mp, actual_mp, csv_out).create_csv()
9899
csv_out.seek(0)
99100
content = csv_out.read()
100-
self.assertEquals(content, CSV_HEADING +
101+
heading = CSV_HEADING % (TEST_PRODUCT, TEST_BASELINE_PRODUCT)
102+
self.assertEquals(content, heading +
101103
('test.html,PASS,PASS,SAME RESULTS,'
102104
'"{FAIL, TIMEOUT, PASS}","{CRASH, PASS}",Yes\n'))
103105

@@ -109,7 +111,8 @@ def test_create_csv_with_reliable_different_result(self):
109111
MockWPTResultsDiffer(actual_mp, baseline_mp, csv_out).create_csv()
110112
csv_out.seek(0)
111113
content = csv_out.read()
112-
self.assertEquals(content, CSV_HEADING +
114+
heading = CSV_HEADING % (TEST_PRODUCT, TEST_BASELINE_PRODUCT)
115+
self.assertEquals(content, heading +
113116
('test.html,PASS,FAIL,DIFFERENT RESULTS,'
114117
'"{FAIL, TIMEOUT, PASS}","{FAIL, CRASH}",No\n'))
115118

@@ -121,7 +124,8 @@ def test_create_csv_with_unreliable_different_result(self):
121124
MockWPTResultsDiffer(actual_mp, baseline_mp, csv_out).create_csv()
122125
csv_out.seek(0)
123126
content = csv_out.read()
124-
self.assertEquals(content, CSV_HEADING +
127+
heading = CSV_HEADING % (TEST_PRODUCT, TEST_BASELINE_PRODUCT)
128+
self.assertEquals(content, heading +
125129
('test.html,CRASH,FAIL,DIFFERENT RESULTS,'
126130
'"{FAIL, CRASH, TIMEOUT}","{FAIL, CRASH}",Yes\n'))
127131

@@ -131,7 +135,8 @@ def test_create_csv_with_missing_result(self):
131135
MockWPTResultsDiffer(actual_mp, {}, csv_out).create_csv()
132136
csv_out.seek(0)
133137
content = csv_out.read()
134-
self.assertEquals(content, CSV_HEADING +
138+
heading = CSV_HEADING % (TEST_PRODUCT, TEST_BASELINE_PRODUCT)
139+
self.assertEquals(content, heading +
135140
'test.html,PASS,MISSING,MISSING RESULTS,{},{},No\n')
136141

137142
def test_use_bb_to_get_results(self):
@@ -175,7 +180,8 @@ def process_cmds(cmd_args):
175180
csv_out).create_csv()
176181
csv_out.seek(0)
177182
content = csv_out.read()
178-
self.assertEquals(content, CSV_HEADING +
183+
heading = CSV_HEADING % (TEST_PRODUCT, TEST_BASELINE_PRODUCT)
184+
self.assertEquals(content, heading +
179185
('test.html,PASS,FAIL,DIFFERENT RESULTS,'
180186
'"{FAIL, TIMEOUT, PASS}","{FAIL, CRASH}",No\n'))
181187

0 commit comments

Comments
 (0)