Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from google.appengine.ext import ndb | 5 from google.appengine.ext import ndb |
| 6 import webapp2 | 6 import webapp2 |
| 7 | 7 |
| 8 from datetime import datetime | |
|
lijeffrey
2016/06/13 18:15:05
nit: i would move these imports to the very top
josiahk
2016/06/21 00:56:53
Done.
| |
| 9 from datetime import timedelta | |
|
chanli
2016/06/13 20:21:03
Move this one to top as well.
josiahk
2016/06/21 00:56:53
Done.
| |
| 10 | |
| 8 from testing_utils import testing | 11 from testing_utils import testing |
| 9 | 12 |
| 10 from handlers import triage_analysis | 13 from handlers import triage_analysis |
| 11 from model.wf_analysis import WfAnalysis | 14 from model.wf_analysis import WfAnalysis |
| 12 from model import result_status | 15 from model import result_status |
| 13 from model import analysis_status | 16 from model import analysis_status |
| 14 from waterfall import buildbot | 17 from waterfall import buildbot |
| 15 | 18 |
| 16 | 19 |
| 17 class TriageAnalysisTest(testing.AppengineTestCase): | 20 class TriageAnalysisTest(testing.AppengineTestCase): |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 self.assertEquals({'success': False}, response.json_body) | 126 self.assertEquals({'success': False}, response.json_body) |
| 124 | 127 |
| 125 def testSuccessfulTriage(self): | 128 def testSuccessfulTriage(self): |
| 126 build_url = buildbot.CreateBuildUrl( | 129 build_url = buildbot.CreateBuildUrl( |
| 127 self.master_name, self.builder_name, self.build_number_found) | 130 self.master_name, self.builder_name, self.build_number_found) |
| 128 response = self.test_app.get( | 131 response = self.test_app.get( |
| 129 '/triage-analysis', | 132 '/triage-analysis', |
| 130 params={'url': build_url, 'correct': True, 'format': 'json'}) | 133 params={'url': build_url, 'correct': True, 'format': 'json'}) |
| 131 self.assertEquals(200, response.status_int) | 134 self.assertEquals(200, response.status_int) |
| 132 self.assertEquals({'success': True}, response.json_body) | 135 self.assertEquals({'success': True}, response.json_body) |
| 136 | |
| 137 def testAnalysesMatch(self): | |
| 138 analysis_with_empty_failures = WfAnalysis.Create( | |
|
lijeffrey
2016/06/13 18:15:05
i would create these and modify them in the order
chanli
2016/06/13 20:21:03
+1
analysis_with_empty_failiures = WfAnalysis.Cre
josiahk
2016/06/21 00:56:53
Done.
| |
| 139 self.master_name, self.builder_name, 200) | |
| 140 analysis_with_no_suspected_cls = WfAnalysis.Create( | |
| 141 self.master_name, self.builder_name, 201) | |
| 142 analysis_with_suspected_cls_1 = WfAnalysis.Create( | |
| 143 self.master_name, self.builder_name, 202) | |
| 144 analysis_with_suspected_cls_2 = WfAnalysis.Create( | |
| 145 self.master_name, self.builder_name, 203) | |
| 146 analysis_with_suspected_cls_3 = WfAnalysis.Create( | |
| 147 self.master_name, self.builder_name, 204) | |
| 148 analysis_with_suspected_cls_4 = WfAnalysis.Create( | |
| 149 self.master_name, self.builder_name, 205) | |
| 150 analysis_with_tests_1 = WfAnalysis.Create( | |
| 151 self.master_name, self.builder_name, 206) | |
| 152 analysis_with_tests_2 = WfAnalysis.Create( | |
| 153 self.master_name, self.builder_name, 207) | |
| 154 | |
| 155 # Set time to yesterday | |
|
lijeffrey
2016/06/13 18:15:05
nit: comment ends with .
chanli
2016/06/13 20:21:03
nit: 'Sets'
josiahk
2016/06/21 00:56:53
Thanks!
| |
| 156 build_start_time = datetime.utcnow() - timedelta( | |
|
lijeffrey
2016/06/13 18:15:05
if it's yesterday you can do
datetime.utcnow() -
josiahk
2016/06/21 00:56:53
Thanks!
| |
| 157 triage_analysis.MATCHING_ANALYSIS_DAYS_AGO_END) | |
| 158 build_start_time = build_start_time.replace( | |
| 159 hour=12, minute=0, second=0, microsecond=0) | |
| 160 | |
| 161 analysis_with_empty_failures.result = { | |
| 162 'failures': [] | |
| 163 } | |
| 164 analysis_with_empty_failures.put() | |
| 165 | |
| 166 analysis_with_no_suspected_cls.result = { | |
| 167 'failures': [ | |
| 168 { | |
| 169 'suspected_cls': [] | |
| 170 }, | |
| 171 { | |
| 172 'suspected_cls': [] | |
| 173 }, | |
| 174 ] | |
| 175 } | |
| 176 analysis_with_no_suspected_cls.put() | |
| 177 | |
| 178 analysis_with_suspected_cls_1.result = { | |
| 179 'failures': [ | |
| 180 { | |
| 181 'step_name': 'interactive_ui_tests', | |
| 182 'suspected_cls': [ | |
| 183 { | |
| 184 'revision': '3cf9343f4602d4ec11717cb6ff56a793c1d5f84b', | |
| 185 } | |
| 186 ], | |
| 187 } | |
| 188 ] | |
| 189 } | |
| 190 analysis_with_suspected_cls_1.put() | |
| 191 | |
| 192 analysis_with_suspected_cls_2.result = { | |
| 193 'failures': [ | |
| 194 { | |
| 195 'suspected_cls': [], | |
| 196 'step_name': 'browser_tests' | |
| 197 }, | |
| 198 { | |
| 199 'suspected_cls': [ | |
| 200 { | |
| 201 'revision': '0e8dc209f5e4a6140e43551de0e036324c68a383', | |
| 202 } | |
| 203 ], | |
| 204 'step_name': 'content_browsertests' | |
| 205 } | |
| 206 ] | |
| 207 } | |
| 208 analysis_with_suspected_cls_2.put() | |
| 209 | |
| 210 analysis_with_suspected_cls_3.result = { | |
| 211 'failures': [ | |
| 212 { | |
| 213 'suspected_cls': [], | |
| 214 'step_name': 'browser_tests', | |
| 215 }, | |
| 216 { | |
| 217 'suspected_cls': [ | |
| 218 { | |
| 219 'revision': '0e8dc209f5e4a6140e43551de0e036324c68a383', | |
| 220 }, | |
| 221 { | |
| 222 'revision': '292b41bbd603ae2f11d239f457a8a5f04387fa85', | |
| 223 }, | |
| 224 { | |
| 225 'revision': 'f6c9ef029e28a6bef28e727cd70751d782963e21', | |
| 226 } | |
| 227 ], | |
| 228 'step_name': 'content_browsertests', | |
| 229 } | |
| 230 ] | |
| 231 } | |
| 232 analysis_with_suspected_cls_3.result_status = result_status.FOUND_UNTRIAGED | |
| 233 analysis_with_suspected_cls_3.build_start_time = build_start_time | |
| 234 analysis_with_suspected_cls_3.put() | |
| 235 | |
| 236 analysis_with_suspected_cls_4.result = { | |
| 237 'failures': [ | |
| 238 { | |
| 239 'suspected_cls': [], | |
| 240 'step_name': 'browser_tests', | |
| 241 }, | |
| 242 { | |
| 243 'suspected_cls': [ | |
| 244 { | |
| 245 'revision': '0e8dc209f5e4a6140e43551de0e036324c68a383', | |
| 246 }, | |
| 247 { | |
| 248 'revision': '292b41bbd603ae2f11d239f457a8a5f04387fa85', | |
| 249 }, | |
| 250 { | |
| 251 'revision': 'f6c9ef029e28a6bef28e727cd70751d782963e21', | |
| 252 } | |
| 253 ], | |
| 254 'step_name': 'content_browsertests', | |
| 255 } | |
| 256 ] | |
| 257 } | |
| 258 analysis_with_suspected_cls_4.result_status = result_status.FOUND_UNTRIAGED | |
| 259 analysis_with_suspected_cls_4.build_start_time = build_start_time | |
| 260 analysis_with_suspected_cls_4.put() | |
| 261 | |
| 262 analysis_with_tests_1.result = { | |
| 263 'failures': [ | |
| 264 { | |
| 265 'tests': [ | |
| 266 { | |
| 267 'test_name': 'super_test_1', | |
| 268 'suspected_cls': [ | |
| 269 { | |
| 270 'revision': 'abc' | |
| 271 } | |
| 272 ] | |
| 273 }, { | |
| 274 'test_name': 'super_test_2', | |
| 275 'suspected_cls': [ | |
| 276 { | |
| 277 'revision': 'def' | |
| 278 }, | |
| 279 { | |
| 280 'revision': 'ghi' | |
| 281 } | |
| 282 ] | |
| 283 } | |
| 284 ], | |
| 285 'step_name': 'interactive_ui_tests', | |
| 286 'suspected_cls': [ | |
| 287 { | |
| 288 'revision': '3cf9343f4602d4ec11717cb6ff56a793c1d5f84b', | |
| 289 } | |
| 290 ], | |
| 291 } | |
| 292 ] | |
| 293 } | |
| 294 analysis_with_tests_1.put() | |
| 295 | |
| 296 analysis_with_tests_2.result = { | |
| 297 'failures': [ | |
| 298 { | |
| 299 'tests': [ | |
| 300 { | |
| 301 'test_name': 'super_test_3', | |
| 302 'suspected_cls': [ | |
| 303 { | |
| 304 'revision': 'ab' | |
| 305 }, | |
| 306 { | |
| 307 'revision': 'cd' | |
| 308 }, | |
| 309 { | |
| 310 'revision': 'ef' | |
| 311 } | |
| 312 ] | |
| 313 } | |
| 314 ], | |
| 315 'step_name': 'interactive_ui_tests', | |
| 316 'suspected_cls': [ | |
| 317 { | |
| 318 'revision': '3cf9343f4602d4ec11717cb6ff56a793c1d5f84b', | |
| 319 } | |
| 320 ], | |
| 321 } | |
| 322 ] | |
| 323 } | |
| 324 analysis_with_tests_2.put() | |
| 325 | |
| 326 # Empty failures list | |
|
lijeffrey
2016/06/13 18:15:06
nit: all comments should end with .
josiahk
2016/06/21 00:56:53
Done.
| |
| 327 self.assertFalse(triage_analysis._DoAnalysesMatch( | |
| 328 analysis_with_empty_failures, | |
| 329 analysis_with_empty_failures)) | |
| 330 # Zero culprit-tuples | |
| 331 self.assertFalse(triage_analysis._DoAnalysesMatch( | |
| 332 analysis_with_no_suspected_cls, | |
| 333 analysis_with_no_suspected_cls)) | |
| 334 # Zero culprit-tuples and some culprit-tuples | |
| 335 self.assertFalse(triage_analysis._DoAnalysesMatch( | |
| 336 analysis_with_no_suspected_cls, | |
| 337 analysis_with_suspected_cls_1)) | |
| 338 # Has step-level culprit-tuples, and should detect match | |
| 339 self.assertTrue(triage_analysis._DoAnalysesMatch( | |
| 340 analysis_with_suspected_cls_2, | |
| 341 analysis_with_suspected_cls_2)) | |
| 342 # Two different step-level culprit-tuples, and should fail to match | |
| 343 self.assertFalse(triage_analysis._DoAnalysesMatch( | |
| 344 analysis_with_suspected_cls_2, | |
| 345 analysis_with_suspected_cls_3)) | |
| 346 # Has test-level culprit-tuples, and should detect match | |
| 347 self.assertTrue(triage_analysis._DoAnalysesMatch( | |
| 348 analysis_with_tests_1, | |
| 349 analysis_with_tests_1)) | |
| 350 # Two different test-level culprit-tuples, and should fail to match | |
| 351 self.assertFalse(triage_analysis._DoAnalysesMatch( | |
| 352 analysis_with_tests_1, | |
| 353 analysis_with_tests_2)) | |
| 354 | |
| 355 # TODO(josiahk): Put this into its own testTriageDuplicateResults test | |
| 356 triage_analysis._TriageDuplicateResults(analysis_with_suspected_cls_3, True) | |
|
lijeffrey
2016/06/13 18:15:05
why not just do this instead of leaving it in TODO
chanli
2016/06/13 20:21:03
+1
josiahk
2016/06/21 00:56:53
There is now a testTriageDuplicateResults test, th
| |
| OLD | NEW |