| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import datetime | 5 import datetime |
| 6 import json | 6 import json |
| 7 import os | 7 import os |
| 8 import urllib | 8 import urllib |
| 9 import zlib | 9 import zlib |
| 10 | 10 |
| 11 from testing_utils import testing | |
| 12 | |
| 13 from common.http_client_appengine import HttpClientAppengine as HttpClient | 11 from common.http_client_appengine import HttpClientAppengine as HttpClient |
| 14 from model import wf_analysis_status | 12 from model import wf_analysis_status |
| 15 from model.wf_analysis import WfAnalysis | 13 from model.wf_analysis import WfAnalysis |
| 16 from model.wf_build import WfBuild | 14 from model.wf_build import WfBuild |
| 17 from model.wf_step import WfStep | 15 from model.wf_step import WfStep |
| 18 from pipeline_wrapper import pipeline_handlers | 16 from pipeline_wrapper import pipeline_handlers |
| 19 from waterfall import buildbot | 17 from waterfall import buildbot |
| 20 from waterfall import lock_util | 18 from waterfall import lock_util |
| 21 from waterfall import swarming_util | 19 from waterfall import swarming_util |
| 22 from waterfall import waterfall_config | |
| 23 from waterfall.detect_first_failure_pipeline import DetectFirstFailurePipeline | 20 from waterfall.detect_first_failure_pipeline import DetectFirstFailurePipeline |
| 21 from waterfall.test import wf_testcase |
| 24 | 22 |
| 25 | 23 |
| 26 _MOCK_SWARMING_SETTINGS = { | 24 class DetectFirstFailureTest(wf_testcase.WaterfallTestCase): |
| 27 'task_timeout_hours': 23, | |
| 28 'server_query_interval_seconds': 60, | |
| 29 'iterations_to_rerun': 10, | |
| 30 'server_host': 'chromium-swarm.appspot.com', | |
| 31 'default_request_priority': 150, | |
| 32 'isolated_storage_url': 'isolateserver.storage.googleapis.com', | |
| 33 'isolated_server': 'https://isolateserver.appspot.com', | |
| 34 'request_expiration_hours': 20 | |
| 35 } | |
| 36 | |
| 37 | |
| 38 class DetectFirstFailureTest(testing.AppengineTestCase): | |
| 39 app_module = pipeline_handlers._APP | 25 app_module = pipeline_handlers._APP |
| 40 | 26 |
| 41 def setUp(self): | 27 def setUp(self): |
| 42 super(DetectFirstFailureTest, self).setUp() | 28 super(DetectFirstFailureTest, self).setUp() |
| 43 | 29 |
| 44 with self.mock_urlfetch() as urlfetch: | 30 with self.mock_urlfetch() as urlfetch: |
| 45 self.mocked_urlfetch = urlfetch | 31 self.mocked_urlfetch = urlfetch |
| 46 | 32 |
| 47 def _WaitUntilDownloadAllowed(*_): | 33 def _WaitUntilDownloadAllowed(*_): |
| 48 return True | 34 return True |
| 49 | 35 |
| 50 self.mock(lock_util, 'WaitUntilDownloadAllowed', _WaitUntilDownloadAllowed) | 36 self.mock(lock_util, 'WaitUntilDownloadAllowed', _WaitUntilDownloadAllowed) |
| 51 | 37 |
| 52 def _MockGetSwarmingSettings(): | |
| 53 return _MOCK_SWARMING_SETTINGS | |
| 54 self.mock(waterfall_config, 'GetSwarmingSettings', _MockGetSwarmingSettings) | |
| 55 | |
| 56 def _TimeBeforeNowBySeconds(self, seconds): | 38 def _TimeBeforeNowBySeconds(self, seconds): |
| 57 return datetime.datetime.utcnow() - datetime.timedelta(0, seconds, 0) | 39 return datetime.datetime.utcnow() - datetime.timedelta(0, seconds, 0) |
| 58 | 40 |
| 59 def _CreateAndSaveWfAnanlysis( | 41 def _CreateAndSaveWfAnanlysis( |
| 60 self, master_name, builder_name, build_number, status): | 42 self, master_name, builder_name, build_number, status): |
| 61 analysis = WfAnalysis.Create(master_name, builder_name, build_number) | 43 analysis = WfAnalysis.Create(master_name, builder_name, build_number) |
| 62 analysis.status = status | 44 analysis.status = status |
| 63 analysis.put() | 45 analysis.put() |
| 64 | 46 |
| 65 def _GetBuildData(self, master_name, builder_name, build_number): | 47 def _GetBuildData(self, master_name, builder_name, build_number): |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 221: '{"Unittest3.Subtest3": "YS9iL3UzczIuY2M6MTEwOiBGYWlsdXJlCg=="}' | 665 221: '{"Unittest3.Subtest3": "YS9iL3UzczIuY2M6MTEwOiBGYWlsdXJlCg=="}' |
| 684 } | 666 } |
| 685 | 667 |
| 686 for n in xrange(223, 220, -1): | 668 for n in xrange(223, 220, -1): |
| 687 step = WfStep.Get(master_name, builder_name, n, 'abc_test') | 669 step = WfStep.Get(master_name, builder_name, n, 'abc_test') |
| 688 self.assertIsNotNone(step) | 670 self.assertIsNotNone(step) |
| 689 self.assertTrue(step.isolated) | 671 self.assertTrue(step.isolated) |
| 690 self.assertEqual(expected_step_log_data[n], step.log_data) | 672 self.assertEqual(expected_step_log_data[n], step.log_data) |
| 691 | 673 |
| 692 self.assertEqual(expected_failed_steps, failure_info['failed_steps']) | 674 self.assertEqual(expected_failed_steps, failure_info['failed_steps']) |
| OLD | NEW |