| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 from datetime import timedelta | 6 from datetime import timedelta |
| 7 import webapp2 | 7 import webapp2 |
| 8 | 8 |
| 9 from handlers import try_job_dashboard | 9 from handlers import try_job_dashboard |
| 10 from model.wf_try_job_data import WfTryJobData | 10 from model.wf_try_job_data import WfTryJobData |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 def testGet(self): | 76 def testGet(self): |
| 77 try_job_in_progress = WfTryJobData.Create(1) | 77 try_job_in_progress = WfTryJobData.Create(1) |
| 78 try_job_in_progress.master_name = 'm' | 78 try_job_in_progress.master_name = 'm' |
| 79 try_job_in_progress.builder_name = 'b' | 79 try_job_in_progress.builder_name = 'b' |
| 80 try_job_in_progress.build_number = 1 | 80 try_job_in_progress.build_number = 1 |
| 81 try_job_in_progress.try_job_type = 'compile' | 81 try_job_in_progress.try_job_type = 'compile' |
| 82 try_job_in_progress.start_time = datetime(2016, 5, 4, 0, 0, 1) | 82 try_job_in_progress.start_time = datetime(2016, 5, 4, 0, 0, 1) |
| 83 try_job_in_progress.request_time = datetime(2016, 5, 4, 0, 0, 0) | 83 try_job_in_progress.request_time = datetime(2016, 5, 4, 0, 0, 0) |
| 84 try_job_in_progress.try_job_url = 'url1' | 84 try_job_in_progress.try_job_url = 'url1' |
| 85 try_job_in_progress.last_buildbucket_response = {'status': 'STARTED'} |
| 85 try_job_in_progress.put() | 86 try_job_in_progress.put() |
| 86 | 87 |
| 87 try_job_with_error = WfTryJobData.Create(2) | 88 try_job_with_error = WfTryJobData.Create(2) |
| 88 try_job_with_error.master_name = 'm' | 89 try_job_with_error.master_name = 'm' |
| 89 try_job_with_error.builder_name = 'b' | 90 try_job_with_error.builder_name = 'b' |
| 90 try_job_with_error.build_number = 2 | 91 try_job_with_error.build_number = 2 |
| 91 try_job_with_error.try_job_type = 'compile' | 92 try_job_with_error.try_job_type = 'compile' |
| 92 try_job_with_error.start_time = datetime(2016, 5, 4, 0, 0, 1) | 93 try_job_with_error.start_time = datetime(2016, 5, 4, 0, 0, 1) |
| 93 try_job_with_error.request_time = datetime(2016, 5, 4, 0, 0, 0) | 94 try_job_with_error.request_time = datetime(2016, 5, 4, 0, 0, 0) |
| 94 try_job_with_error.end_time = datetime(2016, 5, 4, 0, 0, 2) | 95 try_job_with_error.end_time = datetime(2016, 5, 4, 0, 0, 2) |
| 95 try_job_with_error.try_job_url = 'url2' | 96 try_job_with_error.try_job_url = 'url2' |
| 96 try_job_with_error.error = { | 97 try_job_with_error.error = { |
| 97 'message': 'some error', | 98 'message': 'some error', |
| 98 'reason': 'some reason' | 99 'reason': 'some reason' |
| 99 } | 100 } |
| 101 try_job_with_error.last_buildbucket_response = { |
| 102 'failure_reason': 'INFRA_FAILURE' |
| 103 } |
| 100 try_job_with_error.put() | 104 try_job_with_error.put() |
| 101 | 105 |
| 102 try_job_completed = WfTryJobData.Create(3) | 106 try_job_completed = WfTryJobData.Create(3) |
| 103 try_job_completed.master_name = 'm' | 107 try_job_completed.master_name = 'm' |
| 104 try_job_completed.builder_name = 'b' | 108 try_job_completed.builder_name = 'b' |
| 105 try_job_completed.build_number = 3 | 109 try_job_completed.build_number = 3 |
| 106 try_job_completed.try_job_type = 'compile' | 110 try_job_completed.try_job_type = 'compile' |
| 107 try_job_completed.start_time = datetime(2016, 5, 4, 0, 0, 1) | 111 try_job_completed.start_time = datetime(2016, 5, 4, 0, 0, 1) |
| 108 try_job_completed.request_time = datetime(2016, 5, 4, 0, 0, 0) | 112 try_job_completed.request_time = datetime(2016, 5, 4, 0, 0, 0) |
| 109 try_job_completed.end_time = datetime(2016, 5, 4, 0, 0, 2) | 113 try_job_completed.end_time = datetime(2016, 5, 4, 0, 0, 2) |
| 110 try_job_completed.try_job_url = 'url3' | 114 try_job_completed.try_job_url = 'url3' |
| 111 try_job_completed.culprits = { | 115 try_job_completed.culprits = { |
| 112 'compile': { | 116 'compile': { |
| 113 '12345': 'failed' | 117 '12345': 'failed' |
| 114 } | 118 } |
| 115 } | 119 } |
| 120 try_job_completed.last_buildbucket_response = { |
| 121 'status': 'COMPLETED' |
| 122 } |
| 116 try_job_completed.put() | 123 try_job_completed.put() |
| 117 | 124 |
| 118 expected_try_job_in_progress_display_data = { | 125 expected_try_job_in_progress_display_data = { |
| 119 'master_name': 'm', | 126 'master_name': 'm', |
| 120 'builder_name': 'b', | 127 'builder_name': 'b', |
| 121 'build_number': 1, | 128 'build_number': 1, |
| 122 'try_job_type': 'compile', | 129 'try_job_type': 'compile', |
| 123 'request_time': '2016-05-04 00:00:00 UTC', | 130 'request_time': '2016-05-04 00:00:00 UTC', |
| 124 'try_job_url': 'url1', | 131 'try_job_url': 'url1', |
| 125 'status': 'running' | 132 'status': 'running', |
| 133 'last_buildbucket_response': '{"status": "STARTED"}' |
| 126 } | 134 } |
| 127 | 135 |
| 128 expected_try_job_with_error_display_data = { | 136 expected_try_job_with_error_display_data = { |
| 129 'master_name': 'm', | 137 'master_name': 'm', |
| 130 'builder_name': 'b', | 138 'builder_name': 'b', |
| 131 'build_number': 2, | 139 'build_number': 2, |
| 132 'try_job_type': 'compile', | 140 'try_job_type': 'compile', |
| 133 'request_time': '2016-05-04 00:00:00 UTC', | 141 'request_time': '2016-05-04 00:00:00 UTC', |
| 134 'try_job_url': 'url2', | 142 'try_job_url': 'url2', |
| 135 'error': 'some error', | 143 'error': 'some error', |
| 144 'last_buildbucket_response': '{"failure_reason": "INFRA_FAILURE"}' |
| 136 } | 145 } |
| 137 | 146 |
| 138 expected_try_job_completed_display_data = { | 147 expected_try_job_completed_display_data = { |
| 139 'master_name': 'm', | 148 'master_name': 'm', |
| 140 'builder_name': 'b', | 149 'builder_name': 'b', |
| 141 'build_number': 3, | 150 'build_number': 3, |
| 142 'try_job_type': 'compile', | 151 'try_job_type': 'compile', |
| 143 'request_time': '2016-05-04 00:00:00 UTC', | 152 'request_time': '2016-05-04 00:00:00 UTC', |
| 144 'try_job_url': 'url3', | 153 'try_job_url': 'url3', |
| 145 'culprit_found': True | 154 'culprit_found': True, |
| 155 'last_buildbucket_response': '{"status": "COMPLETED"}' |
| 146 } | 156 } |
| 147 | 157 |
| 148 response = self.test_app.get( | 158 response = self.test_app.get( |
| 149 '/try-job-dashboard?format=json&start_date=2016-05-03') | 159 '/try-job-dashboard?format=json&start_date=2016-05-03') |
| 150 response_data = response.json_body | 160 response_data = response.json_body |
| 151 try_jobs_in_progress = response_data.get('try_jobs_in_progress') | 161 try_jobs_in_progress = response_data.get('try_jobs_in_progress') |
| 152 try_jobs_with_error = response_data.get('try_jobs_with_error') | 162 try_jobs_with_error = response_data.get('try_jobs_with_error') |
| 153 successfully_completed_try_jobs = response_data.get( | 163 successfully_completed_try_jobs = response_data.get( |
| 154 'successfully_completed_try_jobs') | 164 'successfully_completed_try_jobs') |
| 155 | 165 |
| 156 self.assertEqual(response.status_int, 200) | 166 self.assertEqual(response.status_int, 200) |
| 157 self.validateTryJobDisplayData( | 167 self.validateTryJobDisplayData( |
| 158 [expected_try_job_in_progress_display_data], | 168 [expected_try_job_in_progress_display_data], |
| 159 try_jobs_in_progress) | 169 try_jobs_in_progress) |
| 160 self.validateTryJobDisplayData( | 170 self.validateTryJobDisplayData( |
| 161 [expected_try_job_with_error_display_data], | 171 [expected_try_job_with_error_display_data], |
| 162 try_jobs_with_error) | 172 try_jobs_with_error) |
| 163 self.validateTryJobDisplayData( | 173 self.validateTryJobDisplayData( |
| 164 [expected_try_job_completed_display_data], | 174 [expected_try_job_completed_display_data], |
| 165 successfully_completed_try_jobs) | 175 successfully_completed_try_jobs) |
| 166 | 176 |
| OLD | NEW |