Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: scripts/slave/recipe_modules/test_utils/test_api.py

Issue 2336293002: Updating swarming api to check for chartjson results from a finished (Closed)
Patch Set: Removing debug logging Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 import json 1 import json
2 2
3 from recipe_engine import recipe_test_api 3 from recipe_engine import recipe_test_api
4 4
5 from .util import GTestResults, TestResults 5 from .util import GTestResults, TestResults
6 6
7 class TestUtilsTestApi(recipe_test_api.RecipeTestApi): 7 class TestUtilsTestApi(recipe_test_api.RecipeTestApi):
8 @recipe_test_api.placeholder_step_data 8 @recipe_test_api.placeholder_step_data
9 def test_results(self, test_results, retcode=None): 9 def test_results(self, test_results, retcode=None):
10 return self.m.json.output(test_results.as_jsonish(), retcode) 10 return self.m.json.output(test_results.as_jsonish(), retcode)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 def raw_gtest_output(self, jsonish, retcode): 109 def raw_gtest_output(self, jsonish, retcode):
110 t = GTestResults(jsonish) 110 t = GTestResults(jsonish)
111 ret = self.gtest_results(t) 111 ret = self.gtest_results(t)
112 ret.retcode = retcode 112 ret.retcode = retcode
113 return ret 113 return ret
114 114
115 def canned_isolated_script_output(self, passing, is_win, swarming=False, 115 def canned_isolated_script_output(self, passing, is_win, swarming=False,
116 shards=1, swarming_internal_failure=False, 116 shards=1, swarming_internal_failure=False,
117 isolated_script_passing=True, valid=True, 117 isolated_script_passing=True, valid=True,
118 missing_shards=[], 118 missing_shards=[],
119 empty_shards=[]): 119 empty_shards=[],
120 output_chartjson=False):
120 """Produces a test results' compatible json for isolated script tests. """ 121 """Produces a test results' compatible json for isolated script tests. """
121 per_shard_results = [] 122 per_shard_results = []
123 per_shard_chartjson_results = []
122 for i in xrange(shards): 124 for i in xrange(shards):
123 jsonish_results = {} 125 jsonish_results = {}
126 chartjsonish_results = {}
124 jsonish_results['valid'] = valid 127 jsonish_results['valid'] = valid
125 # Keep shard 0's results equivalent to the old code to minimize 128 # Keep shard 0's results equivalent to the old code to minimize
126 # expectation diffs. 129 # expectation diffs.
127 idx = 1 + (2 * i) 130 idx = 1 + (2 * i)
128 tests_run = ['test%d.Test%d' % (idx, idx), 131 tests_run = ['test%d.Test%d' % (idx, idx),
129 'test%d.Test%d' % (idx + 1, idx + 1)] 132 'test%d.Test%d' % (idx + 1, idx + 1)]
130 if isolated_script_passing: 133 if isolated_script_passing:
131 jsonish_results['failures'] = [] 134 jsonish_results['failures'] = []
132 jsonish_results['successes'] = tests_run 135 jsonish_results['successes'] = tests_run
133 else: 136 else:
134 jsonish_results['failures'] = tests_run 137 jsonish_results['failures'] = tests_run
135 jsonish_results['successes'] = [] 138 jsonish_results['successes'] = []
136 jsonish_results['times'] = {t : 0.1 for t in tests_run} 139 jsonish_results['times'] = {t : 0.1 for t in tests_run}
140 chartjsonish_results['dummy'] = 'dummy%d' % i
141 chartjsonish_results['charts'] = {'entry1': 'chart1', 'entry2': 'chart2'}
137 per_shard_results.append(jsonish_results) 142 per_shard_results.append(jsonish_results)
143 per_shard_chartjson_results.append(chartjsonish_results)
138 if swarming: 144 if swarming:
139 jsonish_shards = [] 145 jsonish_shards = []
140 files_dict = {} 146 files_dict = {}
141 for i in xrange(shards): 147 for i in xrange(shards):
142 jsonish_shards.append({ 148 jsonish_shards.append({
143 'failure': not passing, 149 'failure': not passing,
144 'internal_failure': swarming_internal_failure 150 'internal_failure': swarming_internal_failure
145 }) 151 })
146 if i not in missing_shards: 152 swarming_path = str(i)
147 swarming_path = str(i) 153 swarming_path += '\\output.json' if is_win else '/output.json'
148 swarming_path += '\\output.json' if is_win else '/output.json' 154
149 if i not in empty_shards: 155 chartjson_swarming_path = str(i)
150 files_dict[swarming_path] = json.dumps(per_shard_results[i]) 156 chartjson_swarming_path += \
151 else: 157 '\\chartjson-output.json' \
152 # Simulate a complete harness failure. 158 if is_win else '/chartjson-output.json'
153 files_dict[swarming_path] = '' 159
160 # Determine what output we are writing and if it is empty or not
161 output_missing = i in missing_shards and not output_chartjson
162 chartjson_output_missing = i in missing_shards and output_chartjson
163 output_empty = i in empty_shards and not output_chartjson
164 chartjson_output_empty = i in empty_shards and output_chartjson
165
166 if not output_missing:
167 files_dict[swarming_path] = \
168 '' if output_empty else json.dumps(per_shard_results[i])
169 if not chartjson_output_missing:
Ken Russell (switch to Gerrit) 2016/09/19 23:41:19 I think it would be more realistic to only synthes
eyaich1 2016/09/20 13:56:59 Done.
170 files_dict[chartjson_swarming_path] = \
171 '' if chartjson_output_empty \
172 else json.dumps(per_shard_chartjson_results[i])
173
154 jsonish_summary = {'shards': jsonish_shards} 174 jsonish_summary = {'shards': jsonish_shards}
155 files_dict['summary.json'] = json.dumps(jsonish_summary) 175 files_dict['summary.json'] = json.dumps(jsonish_summary)
156 return self.m.raw_io.output_dir(files_dict) 176 return self.m.raw_io.output_dir(files_dict)
157 else: 177 else:
158 return self.m.json.output(per_shard_results[0]) 178 return self.m.json.output(per_shard_results[0])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698