def run(self): counter = 60 while True: counter -= 1 if not event_queue: time.sleep(60) else: event = event_queue.popleft() logger.debug("Processing event from queue:\n%s", event) # Add a goofy pipeline queue so we know # not only when nothing is in the queue # but when nothings outstanding so we can # run cleanup on the backend device pipeline.append(valid_event) # Launch instance, run tempest etc etc etc patchset_ref = event['patchSet']['ref'] revision = event['patchSet']['revision'] logger.debug('Grabbed revision from event: %s', revision) ref_name = patchset_ref.replace('/', '-') results_dir = DATA_DIR + '/' + ref_name # This might be a recheck, if so we've presumably # run things once and published, so delete the # local copy and run it again if os.path.isdir(results_dir): shutil.rmtree(results_dir) os.mkdir(results_dir) try: commit_id, success, output = \ executor.just_doit(event['patchSet']['ref'], results_dir) logger.info('Completed just_doit: %(commit)s, ' '%(success)s, %(output)s', {'commit': commit_id, 'success': success, 'output': output}) except InstanceBuildException: logger.error('Received InstanceBuildException...') pass if commit_id is None: commit_id = revision logger.info("Completed %s", cfg['AccountInfo']['ci_name']) url_name = patchset_ref.replace('/', '-') log_location = cfg['Logs']['log_dir'] + '/' + url_name self._post_results_to_gerrit(log_location, success, commit_id) #self._run_subunit2sql(results_dir, ref_name) try: pipeline.remove(valid_event) except ValueError: pass
def run(self): counter = 60 while True: counter -= 1 event_queue if not event_queue: if counter <= 1: logger.debug('Queue is empty, checking every 60 seconds...') counter = 60 time.sleep(60) else: event = event_queue.popleft() logger.debug("Processing event from queue:\n%s", event) # Add a goofy pipeline queue so we know # not only when nothing is in the queue # but when nothings outstanding so we can # run cleanup on the backend device pipeline.append(valid_event) # Launch instance, run tempest etc etc etc patchset_ref = event['patchSet']['ref'] revision = event['patchSet']['revision'] logger.debug('Grabbed revision from event: %s', revision) ref_name = patchset_ref.replace('/', '-') results_dir = DATA_DIR + '/' + ref_name os.mkdir(results_dir) try: commit_id, success, output = \ executor.just_doit(event['patchSet']['ref'], results_dir) logger.info('Completed just_doit: %(commit)s, ' '%(success)s, %(output)s', {'commit': commit_id, 'success': success, 'output': output}) except InstanceBuildException: logger.error('Received InstanceBuildException...') pass if commit_id is None: commit_id = revision logger.info("Completed %s", cfg.AccountInfo.ci_name) url_name = patchset_ref.replace('/', '-') log_location = cfg.Logs.log_dir + '/' + url_name self._post_results_to_gerrit(log_location, success, commit_id) try: pipeline.remove(valid_event) except ValueError: pass
#!/usr/bin/python import os import sys import executor # patchset is of the form 'refs/changes/26/111226/3' # results_dir is of the form '/home/user/test-dir' patchset = str(sys.argv[1]) results_dir = str(sys.argv[2]) ref_name = patchset.replace('/', '-') # build the dir results_dir = results_dir + '/' + ref_name os.mkdir(results_dir) (hash_id, success, results) = executor.just_doit(patchset, results_dir) print "hash_id:%s", hash_id print "success:%s", success print "result:%s", results