def _ExtractBuildInfo(self, master_name, builder_name, build_number): """Returns a BuildInfo instance for the specified build.""" build = build_util.DownloadBuildData(master_name, builder_name, build_number) if build is None: # pragma: no cover raise pipeline.Retry('Too many download from %s' % master_name) if not build.data: # pragma: no cover return None build_info = buildbot.ExtractBuildInfo(master_name, builder_name, build_number, build.data) if not build.completed: build.start_time = build_info.build_start_time build.completed = build_info.completed build.result = build_info.result build.put() analysis = WfAnalysis.Get(master_name, builder_name, build_number) if analysis and not analysis.build_start_time: analysis.build_start_time = build_info.build_start_time analysis.put() return build_info
def GetBuildInfo(master_name, builder_name, build_number): """Gets build info given a master, builder, and build number. Args: master_name (str): The name of the master. builder_name (str): The name of the builder. build_number (int): The build number. Returns: Build information as an instance of BuildInfo. """ build = DownloadBuildData(master_name, builder_name, build_number) if not build.data: return None return buildbot.ExtractBuildInfo(master_name, builder_name, build_number, build.data)
def testExtractBuildInfoBlameList(self): build_file = os.path.join( os.path.dirname(__file__), 'data', 'blame_list_test.json') with open(build_file, 'r') as f: build_data = f.read() master_name = 'a' builder_name = 'b' build_number = 632 expected_blame_list = [ '449cdbd05616de91fcf7e8b4282e300336d6d7c5', '6addffac2601ab1083a55d085847d9bf8e66da02' ] build_info = buildbot.ExtractBuildInfo( master_name, builder_name, build_number, build_data) self.assertEqual(expected_blame_list, build_info.blame_list)
def testExtractBuildInfoOfCompletedBuild(self): build_file = os.path.join( os.path.dirname(__file__), 'data', 'completed_build.json') with open(build_file, 'r') as f: build_data = f.read() master_name = 'a' builder_name = 'b' build_number = 632 expected_build_start_time = datetime.utcfromtimestamp(1417470720.763887) expected_chromium_revision = '449cdbd05616de91fcf7e8b4282e300336d6d7c5' expected_commit_position = 306253 expected_completed = True expected_result = None expected_blame_list = [ '449cdbd05616de91fcf7e8b4282e300336d6d7c5' ] expected_failed_steps = [ 'net_unittests on Windows-XP-SP3' ] expected_passed_steps = [ 'browser_tests on Windows-XP-SP3' ] expected_not_passed_steps = [ 'steps', 'net_unittests on Windows-XP-SP3', ] build_info = buildbot.ExtractBuildInfo( master_name, builder_name, build_number, build_data) self.assertEqual(master_name, build_info.master_name) self.assertEqual(builder_name, build_info.builder_name) self.assertEqual(build_number, build_info.build_number) self.assertEqual(expected_build_start_time, build_info.build_start_time) self.assertEqual(expected_chromium_revision, build_info.chromium_revision) self.assertEqual(expected_commit_position, build_info.commit_position) self.assertEqual(expected_completed, build_info.completed) self.assertEqual(expected_result, build_info.result) self.assertEqual(expected_blame_list, build_info.blame_list) self.assertEqual(expected_failed_steps, build_info.failed_steps) self.assertEqual(expected_passed_steps, build_info.passed_steps) self.assertEqual(expected_not_passed_steps, build_info.not_passed_steps)
def _ExtractBuildInfo(self, master_name, builder_name, build_number): """Returns a BuildInfo instance for the specified build.""" build = self._DownloadBuildData(master_name, builder_name, build_number) if not build.data: # pragma: no cover return None build_info = buildbot.ExtractBuildInfo(master_name, builder_name, build_number, build.data) if not build.completed: build.start_time = build_info.build_start_time build.completed = build_info.completed build.result = build_info.result build.put() analysis = WfAnalysis.Get(master_name, builder_name, build_number) if analysis and not analysis.build_start_time: analysis.build_start_time = build_info.build_start_time analysis.put() return build_info
def testExtractBuildInfoOfRunningBuild(self): build_file = os.path.join(os.path.dirname(__file__), 'data', 'running_build.json') with open(build_file, 'r') as f: build_data = f.read() master_name = 'a' builder_name = 'b' build_number = 632 expected_build_start_time = datetime.fromtimestamp(1417470720.763887) expected_chromium_revision = '449cdbd05616de91fcf7e8b4282e300336d6d7c5' expected_completed = False expected_result = None expected_blame_list = [ 'f1e24ae21c95228522c24697dae474db5f26854b', 'fae4955b2ae9cf68aa2a391a7640b1c3276656e8', '4ef763a9bb3dc53c7afccbcab9a1b0327b83681c', '89ef2ae2a6e2d21813c14471eb444c8651b46651', '58becfc708670659119ca72472d1d0882797f706', '1cc47034de564d0fd33a89c7d785a539b6c3a5a0', '87be98a1f687d430c4e1e1a5da04065067a4c1cc', '2fa8736ff6af5bc1f4fa0dc5cd7ff356fa24242b', '6addffac2601ab1083a55d085847d9bf8e66da02', '6bbd1fe6fe674d32d19f44c2c0f7f4f735e0b20e', 'd7777f96f98668918102861a262b311ae8c8bd74', '6b0dcfd9761235e93b45fa9ee9d90474c12adb11', '6157b49795f3dfb89220ed72861a114e24f6c0d8', '449cdbd05616de91fcf7e8b4282e300336d6d7c5' ] expected_failed_steps = ['interactive_ui_tests on Windows-XP-SP3'] expected_passed_steps = [ 'update_scripts', 'setup_build', 'taskkill', 'bot_update', 'swarming.py --version', 'read test spec', 'get compile targets for scripts', 'cleanup_temp', 'rmtree build directory', 'extract build', 'start_crash_service', '[trigger] base_unittests on Windows-XP-SP3', '[trigger] browser_tests on Windows-XP-SP3', '[trigger] content_browsertests on Windows-XP-SP3', '[trigger] content_unittests on Windows-XP-SP3', '[trigger] interactive_ui_tests on Windows-XP-SP3', '[trigger] net_unittests on Windows-XP-SP3', '[trigger] sync_integration_tests on Windows-XP-SP3', '[trigger] unit_tests on Windows-XP-SP3', 'telemetry_unittests', 'telemetry_perf_unittests', 'nacl_integration', 'accessibility_unittests', 'app_shell_browsertests', 'app_shell_unittests', 'aura_unittests', 'cacheinvalidation_unittests', 'cast_unittests', 'cc_unittests', 'chromedriver_unittests', 'chrome_elf_unittests', 'components_unittests', 'compositor_unittests', 'courgette_unittests', 'crypto_unittests', 'events_unittests', 'extensions_unittests', 'gcm_unit_tests', 'gfx_unittests', 'google_apis_unittests', 'gpu_unittests', 'installer_util_unittests', 'ipc_tests', 'jingle_unittests', 'media_unittests', 'ppapi_unittests', 'printing_unittests', 'remoting_unittests', 'sbox_unittests', 'sbox_integration_tests', 'sbox_validation_tests', 'sql_unittests', 'sync_unit_tests', 'ui_base_unittests', 'url_unittests', 'views_unittests', 'wm_unittests', 'base_unittests on Windows-XP-SP3', 'browser_tests on Windows-XP-SP3', 'content_browsertests on Windows-XP-SP3', 'content_unittests on Windows-XP-SP3', ] expected_not_passed_steps = [ 'interactive_ui_tests on Windows-XP-SP3', 'net_unittests on Windows-XP-SP3', ] build_info = buildbot.ExtractBuildInfo(master_name, builder_name, build_number, build_data) self.assertEqual(master_name, build_info.master_name) self.assertEqual(builder_name, build_info.builder_name) self.assertEqual(build_number, build_info.build_number) self.assertEqual(expected_build_start_time, build_info.build_start_time) self.assertEqual(expected_chromium_revision, build_info.chromium_revision) self.assertEqual(expected_completed, build_info.completed) self.assertEqual(expected_result, build_info.result) self.assertEqual(expected_blame_list, build_info.blame_list) self.assertEqual(expected_failed_steps, build_info.failed_steps) self.assertEqual(expected_passed_steps, build_info.passed_steps) self.assertEqual(expected_not_passed_steps, build_info.not_passed_steps)
def _CheckReverts(master_name, builder_name, current_build_number): """Checks each cl in current build to see if some of them are reverted. Returns: { 'c9cc182781484f9010f062859cda048afef': { 'action': 'Reverted', 'fixed_cl_commit_position': '341992', 'fixed_revision': 'c9cc182781484f9010f062859cda048afef', 'fixed_cl_review_url': ( 'https://codereview.chromium.org/1278653002'), 'fixing_build_number': 0, 'fixing_build_url': ( 'https://luci-milo.appspot.com/buildbot/m/b/0') 'fixing_revision': '208c65020aecfcf305d524058f7ca89363', 'fixing_cl_commit_position': '342013', 'fixing_cl_review_url': ( 'https://codereview.chromium.org/1278653005'), 'fixing_build_number': 2, 'fixing_build_url': ( 'https://luci-milo.appspot.com/buildbot/m/b/2') }, ... } """ data = {} reverted_cls = {} blamed_cls = {} steps_pass = False build_number, current_failed_steps = _GetFirstFailedBuild( master_name, builder_name, current_build_number) if not build_number: return data while not steps_pass: # Breaks the loop after the first green build # or all the current failed steps pass. build = build_util.DownloadBuildData( master_name, builder_name, build_number) if not build or not build.data: return data build_info = buildbot.ExtractBuildInfo( master_name, builder_name, build_number, build.data) if build_number <= current_build_number: # All the cls in builds prior to the current build(included) # should be checked for reverts. for blamed_revision in build_info.blame_list: blamed_cls[blamed_revision] = build_number if (build_info.result == 0 or _AllFailedStepsPassed(build_info.passed_steps, current_failed_steps)): steps_pass = True for cl_in_blame_list in build_info.blame_list: cls_info = GetPossibleRevertInfoFromRevision(cl_in_blame_list) if not cls_info: continue fixed_revision = cls_info['fixed_revision'] if (fixed_revision in blamed_cls and build_number > blamed_cls[fixed_revision] and build_number > current_build_number): # If a CL and its reverting cl are in the same build, # it doesn't have any impact on the build failure. # And possible fix should take effect after the current build. cls_info['fixed_build_number'] = blamed_cls[fixed_revision] cls_info['fixed_build_url'] = ( buildbot.CreateBuildUrl( master_name, builder_name, blamed_cls[fixed_revision])) cls_info['fixing_build_number'] = build_number cls_info['fixing_build_url'] = ( buildbot.CreateBuildUrl(master_name, builder_name, build_number)) reverted_cls[fixed_revision] = cls_info build_number += 1 if reverted_cls: data = reverted_cls return data
def GetBuildEndTime(master_name, builder_name, build_number): build = DownloadBuildData(master_name, builder_name, build_number) build_info = buildbot.ExtractBuildInfo(master_name, builder_name, build_number, build.data) return build_info.build_end_time