| 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 datetime import datetime | 5 from datetime import datetime |
| 6 import json | 6 import json |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 | 10 |
| 11 import main | 11 import main |
| 12 from model.record import Record | 12 from model.record import Record |
| 13 from tests.testing_utils import testing | 13 from tests.testing_utils import testing |
| 14 | 14 |
| 15 class PatchTimelineDataTest(testing.AppengineTestCase): | 15 class PatchTimelineDataTest(testing.AppengineTestCase): |
| 16 app_module = main.app | 16 app_module = main.app |
| 17 | 17 |
| 18 def test_patch_timeline_data_simple(self): | 18 def test_patch_timeline_data_simple(self): |
| 19 events = self._test_patch('real_patch_simple') | 19 events = self._test_patch('real_patch_simple') |
| 20 self.assertEqual(events, [{ | 20 self.assertEqual(events, [{ |
| 21 'name': 'Attempt 1', | 21 'name': 'Attempt 1', |
| 22 'cat': 'Patch Progress', | 22 'cat': 'Patch Progress', |
| 23 'ph': 'B', | 23 'ph': 'B', |
| 24 'ts': 1434395516000184, | 24 'ts': 1434395516000184, |
| 25 'pid': 'Attempt 1', | 25 'pid': 'Attempt 1', |
| 26 'tid': 'Patch Progress', | 26 'tid': 'Patch Progress', |
| 27 'args': { | 27 'cname': 'cq_build_attempt_running', |
| 28 'job_state': 'attempt_running', | 28 'args': {}, |
| 29 }, | |
| 30 }, { | 29 }, { |
| 31 'name': 'Test-Trybot', | 30 'name': 'Test-Trybot', |
| 32 'cat': 'client.skia.fyi', | 31 'cat': 'client.skia.fyi', |
| 33 'ph': 'B', | 32 'ph': 'B', |
| 34 'ts': 1434395520503088, | 33 'ts': 1434395520503088, |
| 35 'pid': 'Attempt 1', | 34 'pid': 'Attempt 1', |
| 36 'tid': 'Test-Trybot', | 35 'tid': 'Test-Trybot', |
| 36 'cname': 'cq_build_running', |
| 37 'args': {}, | 37 'args': {}, |
| 38 }, { | 38 }, { |
| 39 'name': 'Test-Trybot', | 39 'name': 'Test-Trybot', |
| 40 'cat': 'client.skia.fyi', | 40 'cat': 'client.skia.fyi', |
| 41 'ph': 'E', | 41 'ph': 'E', |
| 42 'ts': 1434395577891760, | 42 'ts': 1434395577891760, |
| 43 'pid': 'Attempt 1', | 43 'pid': 'Attempt 1', |
| 44 'tid': 'Test-Trybot', | 44 'tid': 'Test-Trybot', |
| 45 'cname': 'cq_build_passed', |
| 45 'args': { | 46 'args': { |
| 46 'build_url': ('http://build.chromium.org/p/client.skia.fyi/builders/' | 47 'build_url': ('http://build.chromium.org/p/client.skia.fyi/builders/' |
| 47 'Test-Trybot/builds/794'), | 48 'Test-Trybot/builds/794'), |
| 48 'job_state': 'passed', | |
| 49 }, | 49 }, |
| 50 }, { | 50 }, { |
| 51 'name': 'Patch Committing', | 51 'name': 'Patch Committing', |
| 52 'cat': 'Patch Progress', | 52 'cat': 'Patch Progress', |
| 53 'ph': 'B', | 53 'ph': 'B', |
| 54 'ts': 1434395579639639, | 54 'ts': 1434395579639639, |
| 55 'pid': 'Attempt 1', | 55 'pid': 'Attempt 1', |
| 56 'tid': 'Patch Progress', | 56 'tid': 'Patch Progress', |
| 57 'args': { | 57 'cname': 'cq_build_attempt_running', |
| 58 'job_state': 'attempt_running', | 58 'args': {}, |
| 59 }, | |
| 60 }, { | 59 }, { |
| 61 'name': 'Patch Committing', | 60 'name': 'Patch Committing', |
| 62 'cat': 'Patch Progress', | 61 'cat': 'Patch Progress', |
| 63 'ph': 'E', | 62 'ph': 'E', |
| 64 'ts': 1434395584564138, | 63 'ts': 1434395584564138, |
| 65 'pid': 'Attempt 1', | 64 'pid': 'Attempt 1', |
| 66 'tid': 'Patch Progress', | 65 'tid': 'Patch Progress', |
| 67 'args': { | 66 'cname': 'cq_build_attempt_passed', |
| 68 'job_state': 'attempt_passed', | 67 'args': {}, |
| 69 }, | |
| 70 }, { | 68 }, { |
| 71 'name': 'Attempt 1', | 69 'name': 'Attempt 1', |
| 72 'cat': 'Patch Progress', | 70 'cat': 'Patch Progress', |
| 73 'ph': 'E', | 71 'ph': 'E', |
| 74 'ts': 1434395584564362, | 72 'ts': 1434395584564362, |
| 75 'pid': 'Attempt 1', | 73 'pid': 'Attempt 1', |
| 76 'tid': 'Patch Progress', | 74 'tid': 'Patch Progress', |
| 75 'cname': 'cq_build_attempt_passed', |
| 77 'args': { | 76 'args': { |
| 78 'job_state': 'attempt_passed', | |
| 79 'action': 'patch_stop', | 77 'action': 'patch_stop', |
| 80 }, | 78 }, |
| 81 }]) | 79 }]) |
| 82 | 80 |
| 83 def test_patch_timeline_data_multiple_attempts(self): | 81 def test_patch_timeline_data_multiple_attempts(self): |
| 84 events = self._test_patch('real_patch_multiple_attempts') | 82 events = self._test_patch('real_patch_multiple_attempts') |
| 85 self.assertNotEqual(0, len(events)) | 83 self.assertNotEqual(0, len(events)) |
| 86 bCount = 0 | 84 bCount = 0 |
| 87 eCount = 0 | 85 eCount = 0 |
| 88 for event in events: | 86 for event in events: |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 response = self.test_app.get( | 160 response = self.test_app.get( |
| 163 '/patch-timeline-data/%s/%s' % (issue, patchset)) | 161 '/patch-timeline-data/%s/%s' % (issue, patchset)) |
| 164 summary = json.loads(response.body) | 162 summary = json.loads(response.body) |
| 165 logging.debug(json.dumps(summary, indent=2)) | 163 logging.debug(json.dumps(summary, indent=2)) |
| 166 return summary | 164 return summary |
| 167 | 165 |
| 168 | 166 |
| 169 def _load_json(filename): | 167 def _load_json(filename): |
| 170 path = os.path.join(os.path.dirname(__file__), 'resources', filename) | 168 path = os.path.join(os.path.dirname(__file__), 'resources', filename) |
| 171 return json.loads(open(path).read()) | 169 return json.loads(open(path).read()) |
| OLD | NEW |