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

Side by Side Diff: Tools/TestResultServer/handlers/testfilehandler_test.py

Issue 467453002: Take two at fixing android bots still using testlistjson. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright 2014 The Chromium Authors. All rights reserved. 3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 import collections 7 import collections
8 import json 8 import json
9 import imp 9 import imp
10 import logging 10 import logging
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 self.tb.deactivate() 63 self.tb.deactivate()
64 64
65 def test_basic_upload(self): 65 def test_basic_upload(self):
66 master = master_config.getMaster('chromium.chromiumos') 66 master = master_config.getMaster('chromium.chromiumos')
67 builder = 'test-builder' 67 builder = 'test-builder'
68 test_type = 'test-type' 68 test_type = 'test-type'
69 test_data = { 69 test_data = {
70 'tests': { 70 'tests': {
71 'Test1.testproc1': { 71 'Test1.testproc1': {
72 'expected': 'PASS', 72 'expected': 'PASS',
73 'actual': 'PASS', 73 'actual': 'FAIL',
74 'time': 1, 74 'time': 1,
75 } 75 }
76 }, 76 },
77 'build_number': '123', 77 'build_number': '123',
78 'version': JSON_RESULTS_HIERARCHICAL_VERSION, 78 'version': JSON_RESULTS_HIERARCHICAL_VERSION,
79 'builder_name': builder, 79 'builder_name': builder,
80 'blink_revision': '12345', 80 'blink_revision': '12345',
81 'seconds_since_epoch': 1406123456, 81 'seconds_since_epoch': 1406123456,
82 'num_failures_by_type': { 82 'num_failures_by_type': {
83 'FAIL': 0, 83 'FAIL': 0,
84 'SKIP': 0, 84 'SKIP': 0,
85 'PASS': 1 85 'PASS': 1
86 }, 86 },
87 'chromium_revision': '67890', 87 'chromium_revision': '67890',
88 } 88 }
89 89
90 params = collections.OrderedDict([ 90 params = collections.OrderedDict([
91 (testfilehandler.PARAM_BUILDER, builder), 91 (testfilehandler.PARAM_BUILDER, builder),
92 (testfilehandler.PARAM_MASTER, master['url_name']), 92 (testfilehandler.PARAM_MASTER, master['url_name']),
93 (testfilehandler.PARAM_TEST_TYPE, test_type), 93 (testfilehandler.PARAM_TEST_TYPE, test_type),
94 ]) 94 ])
95 upload_files = [('file', 'full_results.json', json.JSONEncoder().encode( test_data))] 95 upload_files = [('file', 'full_results.json', json.JSONEncoder().encode( test_data))]
96 response = self.testapp.post('/testfile/upload', params=params, upload_f iles=upload_files) 96 response = self.testapp.post('/testfile/upload', params=params, upload_f iles=upload_files)
97 self.assertEqual(response.status_int, 200) 97 self.assertEqual(response.status_int, 200)
98 98
99 # test aggregated results.json got generated
99 params = collections.OrderedDict([ 100 params = collections.OrderedDict([
100 (testfilehandler.PARAM_BUILDER, builder), 101 (testfilehandler.PARAM_BUILDER, builder),
101 (testfilehandler.PARAM_MASTER, master['url_name']), 102 (testfilehandler.PARAM_MASTER, master['url_name']),
102 (testfilehandler.PARAM_TEST_TYPE, test_type), 103 (testfilehandler.PARAM_TEST_TYPE, test_type),
103 (testfilehandler.PARAM_BUILD_NUMBER, '123'), 104 (testfilehandler.PARAM_NAME, 'results.json')
104 (testfilehandler.PARAM_NAME, 'full_results.json')
105 ]) 105 ])
106 response = self.testapp.get('/testfile', params=params) 106 response = self.testapp.get('/testfile', params=params)
107 self.assertEqual(response.status_int, 200) 107 self.assertEqual(response.status_int, 200)
108 response_json = json.loads(response.normal_body) 108 response_json = json.loads(response.normal_body)
109 self.assertEqual(response_json['chromium_revision'], '67890') 109 self.assertEqual(response_json[builder]['tests']['Test1.testproc1'],
110 {'results': [[1, 'Q']], 'times': [[1, 1]]})
111
112 # test testlistjson=1
113 params[testfilehandler.PARAM_TEST_LIST_JSON] = '1'
114
115 response = self.testapp.get('/testfile', params=params)
116 self.assertEqual(response.status_int, 200)
117 response_json = json.loads(response.normal_body)
118 self.assertEqual(response_json[builder]['tests']['Test1.testproc1'], {})
110 119
111 def test_deprecated_master_name(self): 120 def test_deprecated_master_name(self):
112 """Verify that a file uploaded with a deprecated master name 121 """Verify that a file uploaded with a deprecated master name
113 can be downloaded by the corresponding new-style master name. 122 can be downloaded by the corresponding new-style master name.
114 """ 123 """
115 master = master_config.getMaster('chromium.chromiumos') 124 master = master_config.getMaster('chromium.chromiumos')
116 builder = 'test-builder' 125 builder = 'test-builder'
117 test_type = 'test-type' 126 test_type = 'test-type'
118 test_data = { 127 test_data = {
119 'tests': { 128 'tests': {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 (testfilehandler.PARAM_NAME, 'full_results.json') 177 (testfilehandler.PARAM_NAME, 'full_results.json')
169 ]) 178 ])
170 response = self.testapp.get('/testfile', params=params) 179 response = self.testapp.get('/testfile', params=params)
171 self.assertEqual(response.status_int, 200) 180 self.assertEqual(response.status_int, 200)
172 response_json = json.loads(response.normal_body) 181 response_json = json.loads(response.normal_body)
173 self.assertEqual(response_json['chromium_revision'], '67890') 182 self.assertEqual(response_json['chromium_revision'], '67890')
174 183
175 if __name__ == '__main__': 184 if __name__ == '__main__':
176 logging.basicConfig(level=logging.ERROR) 185 logging.basicConfig(level=logging.ERROR)
177 unittest.main() 186 unittest.main()
OLDNEW
« no previous file with comments | « Tools/TestResultServer/handlers/testfilehandler.py ('k') | Tools/TestResultServer/model/jsonresults.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698