def test_tagging(self, task_state, failure): session = flexmock() task_id = 9876 build_id = 1234 target_name = 'target' tag_name = 'images-candidate' target_info = {'dest_tag_name': tag_name} task_info = {'state': koji.TASK_STATES[task_state]} (session .should_receive('getBuildTarget') .with_args(target_name) .and_return(target_info)) (session .should_receive('tagBuild') .with_args(tag_name, build_id) .and_return(task_id)) (session .should_receive('taskFinished') .with_args(task_id) .and_return(True)) (session .should_receive('getTaskInfo') .with_args(task_id, request=True) .and_return(task_info)) if failure: with pytest.raises(RuntimeError): tag_koji_build(session, build_id, target_name) else: build_tag = tag_koji_build(session, build_id, target_name) assert build_tag == tag_name
def test_tagging(self, task_state, failure): session = flexmock() task_id = 9876 build_id = 1234 target_name = 'target' tag_name = 'images-candidate' target_info = {'dest_tag_name': tag_name} task_info = {'state': koji.TASK_STATES[task_state]} (session .should_receive('getBuildTarget') .with_args(target_name) .and_return(target_info)) (session .should_receive('tagBuild') .with_args(tag_name, build_id) .and_return(task_id)) (session .should_receive('taskFinished') .with_args(task_id) .and_return(True)) (session .should_receive('getTaskInfo') .with_args(task_id, request=True) .and_return(task_info)) if failure: with pytest.raises(RuntimeError): tag_koji_build(session, build_id, target_name) else: build_tag = tag_koji_build(session, build_id, target_name) assert build_tag == tag_name
def run(self): """ Run the plugin. """ if ((self.koji_principal and not self.koji_keytab) or (self.koji_keytab and not self.koji_principal)): raise RuntimeError("specify both koji_principal and koji_keytab " "or neither") # Only run if the build was successful if self.workflow.build_process_failed: self.log.info("Not promoting failed build to koji") return koji_metadata, output_files = self.get_metadata() try: session = self.login() server_dir = self.get_upload_server_dir() for output in output_files: if output.file: self.upload_file(session, output, server_dir) finally: for output in output_files: if output.file: output.file.close() try: build_info = session.CGImport(koji_metadata, server_dir) except Exception: self.log.debug("metadata: %r", koji_metadata) raise # Older versions of CGImport do not return a value. build_id = build_info.get("id") if build_info else None self.log.debug("Build information: %s", json.dumps(build_info, sort_keys=True, indent=4)) # If configured, koji_tag_build plugin will perform build tagging tag_later = are_plugins_in_order(self.workflow.exit_plugins_conf, PLUGIN_KOJI_PROMOTE_PLUGIN_KEY, PLUGIN_KOJI_TAG_BUILD_KEY) if not tag_later and build_id is not None and self.target is not None: tag_koji_build(session, build_id, self.target, poll_interval=self.poll_interval) return build_id
def run(self): """ Run the plugin. """ if ((self.koji_principal and not self.koji_keytab) or (self.koji_keytab and not self.koji_principal)): raise RuntimeError("specify both koji_principal and koji_keytab " "or neither") # Only run if the build was successful if self.workflow.build_process_failed: self.log.info("Not promoting failed build to koji") return koji_metadata, output_files = self.get_metadata() try: session = self.login() server_dir = self.get_upload_server_dir() for output in output_files: if output.file: self.upload_file(session, output, server_dir) finally: for output in output_files: if output.file: output.file.close() try: build_info = session.CGImport(koji_metadata, server_dir) except Exception: self.log.debug("metadata: %r", koji_metadata) raise # Older versions of CGImport do not return a value. build_id = build_info.get("id") if build_info else None self.log.debug("Build information: %s", json.dumps(build_info, sort_keys=True, indent=4)) # If configured, koji_tag_build plugin will perform build tagging tag_later = are_plugins_in_order(self.workflow.exit_plugins_conf, PLUGIN_KOJI_PROMOTE_PLUGIN_KEY, PLUGIN_KOJI_TAG_BUILD_KEY) if not tag_later and build_id is not None and self.target is not None: tag_koji_build(session, build_id, self.target, poll_interval=self.poll_interval) return build_id
def run(self): """ Run the plugin. """ if self.workflow.build_process_failed: self.log.info('Build failed, skipping koji tagging') return build_id = self.workflow.exit_results.get(KojiPromotePlugin.key) if not build_id: self.log.info('No koji build from %s', KojiPromotePlugin.key) return session = create_koji_session(self.kojihub, self.koji_auth) build_tag = tag_koji_build(session, build_id, self.target, poll_interval=self.poll_interval) return build_tag
def run(self): """ Run the plugin. """ if self.workflow.build_process_failed: self.log.info('Build failed, skipping koji tagging') return build_id = self.workflow.exit_results.get(KojiImportPlugin.key) if not build_id: build_id = self.workflow.exit_results.get(KojiPromotePlugin.key) if not build_id: self.log.info('No koji build from %s or %s', KojiImportPlugin.key, KojiPromotePlugin.key) return session = create_koji_session(self.kojihub, self.koji_auth) build_tag = tag_koji_build(session, build_id, self.target, poll_interval=self.poll_interval) return build_tag