def InsertBoardPerBuild(self, build_id, board, board_metadata=None): """Inserts board-per-build into the database. This function redirects both InsertBoardPerBuild and UpdateBoardPerBuildMetadata of CIDB. Args: build_id: CIDB id of the build. board: Board of the build. board_metadata: A dict with keys - 'main-firmware-version' and 'ec-firmware-version'. """ if not self.InitializeClients(): raise BuildStoreException( 'BuildStore clients could not be initialized.') if self._write_to_cidb: if board_metadata is None: self.cidb_conn.InsertBoardPerBuild(build_id, board) else: self.cidb_conn.UpdateBoardPerBuildMetadata( build_id, board, board_metadata) if self._write_to_bb: if board_metadata is None: buildbucket_v2.UpdateSelfCommonBuildProperties(board=board) else: buildbucket_v2.UpdateSelfCommonBuildProperties( board=board, main_firmware_version=board_metadata.get( 'main-firmware-version'), ec_firmware_version=board_metadata.get( 'ec-firmware-version'))
def InsertBuildMessage( self, build_id, message_type=constants.MESSAGE_TYPE_IGNORED_REASON, message_subtype=constants.MESSAGE_SUBTYPE_SELF_DESTRUCTION, message_value=None, board=None): """Insert a build message into database. Args: build_id: primary key of build recording this message. message_type: Optional str name of message type. message_subtype: Optional str name of message subtype. message_value: Optional value of message. board: Optional str name of the board. """ assert isinstance(message_value, list) if not self.InitializeClients(): raise BuildStoreException( 'BuildStore clients could not be initialized.') if self._write_to_cidb: for buildbucket_id in message_value: self.cidb_conn.InsertBuildMessage( build_id, message_type=message_type, message_subtype=message_subtype, message_value=str(buildbucket_id), board=board) if self._write_to_bb: buildbucket_v2.UpdateSelfCommonBuildProperties( killed_child_builds=message_value)
def FinishBuild(self, build_id, status=None, summary=None, metadata_url=None, strict=True): """Update the given build row, marking it as finished. This should be called once per build, as the last update to the build. This will also mark the row's final=True. Args: build_id: id of row to update. status: Final build status, one of constants.BUILDER_COMPLETED_STATUSES. summary: A summary of the build (failures) collected from all slaves. metadata_url: google storage url to metadata.json file for this build, e.g. ('gs://chromeos-image-archive/master-paladin/' 'R39-6225.0.0-rc1/metadata.json') strict: If |strict| is True, can only update the build status when 'final' is False. |strict| can only be False when the caller wants to change the entry ignoring the 'final' value (For example, a build was marked as status='aborted' and final='true', a cron job to adjust the finish_time will call this method with strict=False). """ if not self.InitializeClients(): raise BuildStoreException('BuildStore clients could not be initialized.') if self._write_to_cidb: self.cidb_conn.FinishBuild( build_id, status=status, summary=summary, metadata_url=metadata_url, strict=strict) if self._write_to_bb: buildbucket_v2.UpdateSelfCommonBuildProperties(metadata_url=metadata_url)
def UpdateLuciNotifyProperties(self, email_notify=None): """Update the buildbucket build with luci-notify specific properties. Args: email_notify: List of luci-notify email_notify values representing the recipients of failure alerts to for this builder. """ if not self.InitializeClients(): raise BuildStoreException( 'BuildStore clients could not be initialized.') if self._write_to_bb: buildbucket_v2.UpdateSelfCommonBuildProperties( email_notify=email_notify)
def InsertBuild(self, builder_name, build_number, build_config, bot_hostname, master_build_id=None, timeout_seconds=None, important=None, buildbucket_id=None, branch=None): """Insert a build row. Args: builder_name: buildbot builder name. build_number: buildbot build number. build_config: cbuildbot config of build bot_hostname: hostname of bot running the build master_build_id: (Optional) primary key of master build to this build. timeout_seconds: (Optional) If provided, total time allocated for this build. A deadline is recorded in CIDB for the current build to end. important: (Optional) If provided, the |important| value for this build. buildbucket_id: (Optional) If provided, the |buildbucket_id| value for this build. branch: (Optional) Manifest branch name of this build. Returns: build_id: incremental primary ID of the build in CIDB. """ if not self.InitializeClients(): raise BuildStoreException( 'BuildStore clients could not be initialized.') build_id = 0 if self._write_to_cidb: build_id = self.cidb_conn.InsertBuild(builder_name, build_number, build_config, bot_hostname, master_build_id, timeout_seconds, important, buildbucket_id, branch) if self._write_to_bb: buildbucket_v2.UpdateSelfCommonBuildProperties(critical=important, cidb_id=build_id) return build_id
def testUpdateSelfCommonBuildProperties(self): self.underlying_function = self.PatchObject( buildbucket_v2, 'UpdateSelfBuildPropertiesNonBlocking') fake_value = 123 fake_id = 8921795536486453568 buildbucket_v2.UpdateSelfCommonBuildProperties(critical=True) self.underlying_function.assert_called_with('critical', True) buildbucket_v2.UpdateSelfCommonBuildProperties(cidb_id=fake_value) self.underlying_function.assert_called_with('cidb_id', fake_value) buildbucket_v2.UpdateSelfCommonBuildProperties( chrome_version=fake_value) self.underlying_function.assert_called_with('chrome_version', fake_value) buildbucket_v2.UpdateSelfCommonBuildProperties( milestone_version=fake_value) self.underlying_function.assert_called_with('milestone_version', fake_value) buildbucket_v2.UpdateSelfCommonBuildProperties( platform_version=fake_value) self.underlying_function.assert_called_with('platform_version', fake_value) buildbucket_v2.UpdateSelfCommonBuildProperties(full_version=fake_value) self.underlying_function.assert_called_with('full_version', fake_value) buildbucket_v2.UpdateSelfCommonBuildProperties( toolchain_url=fake_value) self.underlying_function.assert_called_with('toolchain_url', fake_value) buildbucket_v2.UpdateSelfCommonBuildProperties(build_type=fake_value) self.underlying_function.assert_called_with('build_type', fake_value) buildbucket_v2.UpdateSelfCommonBuildProperties(unibuild=True) self.underlying_function.assert_called_with('unibuild', True) buildbucket_v2.UpdateSelfCommonBuildProperties(suite_scheduling=True) self.underlying_function.assert_called_with('suite_scheduling', True) buildbucket_v2.UpdateSelfCommonBuildProperties( killed_child_builds=[fake_id, fake_value]) self.underlying_function.assert_called_with('killed_child_builds', str([fake_id, fake_value])) buildbucket_v2.UpdateSelfCommonBuildProperties(board='grunt') self.underlying_function.assert_called_with('board', 'grunt') buildbucket_v2.UpdateSelfCommonBuildProperties( main_firmware_version='Google_Grunt.11031.62.0') self.underlying_function.assert_called_with('main_firmware_version', 'Google_Grunt.11031.62.0') buildbucket_v2.UpdateSelfCommonBuildProperties( ec_firmware_version='aleena_v2.1.108-9ca28c388') self.underlying_function.assert_called_with( 'ec_firmware_version', 'aleena_v2.1.108-9ca28c388')