def main(): parser = optparse.OptionParser(usage='%prog [options]\n\n' + __doc__.strip()) parser.add_option('-w', dest='server', default='autotest', help='Hostname of the autotest frontend RPC server.') parser.add_option('-b', dest='label', default=None, type=str, help='A label to restrict the set of hosts reverified.') options, unused_args = parser.parse_args(sys.argv) afe_client = frontend.AFE(debug=False, server=options.server) hostnames = afe_client.reverify_hosts(status='Repair Failed', label=options.label) # The old RPC interface didn't return anything. # A more recent one returns a list of hostnames to make this message useful. if hostnames: print 'The following Repair Failed hosts on', options.server, print 'will be reverified:' print ' '.join(hostnames) else: print 'Repair Failed hosts on', options.server, 'will be reverified.'
def main(): jobdirs = get_job_dirs(options.resultsdir) afe = frontend.AFE() # the way AFE API is right now is to give a whole list of jobs and can't # get specific jobs so minimize the queries caching the result finished_jobs = afe.get_jobs(finished=True) if options.jobname_pattern: jobname_pattern = re.compile(options.jobname_pattern) else: jobname_pattern = None # for each unpublished possible jobdir find it in the database and see # if it is completed for jobdir in jobdirs: job_id = int(os.path.basename(jobdir).split('-')[0]) job = [job for job in finished_jobs if job.id == job_id] if len(job) != 1: continue if jobname_pattern: # does it match the jobname pattern? if not jobname_pattern.match(job[0].name): continue # does it match the wanted job owner if options.job_owner and options.job_owner != job[0].owner: continue publish_job(jobdir)
def test_result_notify(self): class fake_job(object): result = True name = 'nameFoo' id = 'idFoo' results_platform_map = {'NORAD': {'Seeking_Joshua': ['WOPR']}} GLOBAL_CONFIG.override_config_value('SERVER', 'hostname', 'chess') rpc_client_lib.authorization_headers.expect_call( 'david', 'http://chess').and_return({'AUTHORIZATION': 'david'}) rpc_client_lib.get_proxy.expect_call( 'http://chess/afe/server/rpc/', headers={'AUTHORIZATION': 'david'}) self.god.stub_function(utils, 'send_email') utils.send_email.expect_any_call() my_afe = frontend.AFE(user='******') fake_stdout = StringIO() self.god.stub_with(sys, 'stdout', fake_stdout) my_afe.result_notify(fake_job, 'userA', 'userB') self.god.unstub(sys, 'stdout') fake_stdout = fake_stdout.getvalue() self.god.check_playback() self.assert_('PASSED' in fake_stdout) self.assert_('WOPR' in fake_stdout) self.assert_('http://chess/tko/compose_query.cgi?' in fake_stdout) self.assert_('columns=test' in fake_stdout) self.assert_('rows=machine_group' in fake_stdout) self.assert_("condition=tag~'idFoo-%25'" in fake_stdout) self.assert_('title=Report' in fake_stdout) self.assert_('Sending email' in fake_stdout)
def __init__(self, tests_map, jobname_pattern, job_owner='autotest', upload_kernel_config=False): """ Instantiate a map_action. :param tests_map: a dictionary of hostname -> machine_info :param jobname_pattern: a string pattern used to make the job name containing a single "%s" that will be replaced with the kernel version :param job_owner: the user used to talk with the RPC server :param upload_kernel_config: specify if the generate control file should contain code that downloads and sends to the client the kernel config file (in case it is an URL); this requires that the tests_map refers only to server side tests """ self._tests_map = tests_map self._jobname_pattern = jobname_pattern self._afe = frontend.AFE(user=job_owner) self._upload_kernel_config = upload_kernel_config