How to use parse_quickcmd method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...95 raise error.HarnessError("Bad use of 'quickcmd'")96 self.cmd = a[9:]97 else:98 raise error.HarnessError("Unknown beaker harness arg: %s" % a)99 def parse_quickcmd(self, args):100 # hack allow tests to quickly submit feedback through harness101 if not args:102 return103 if 'BEAKER_TASK_ID' not in os.environ:104 raise error.HarnessError("No BEAKER_TASK_ID set")105 task_id = os.environ['BEAKER_TASK_ID']106 # Commands are from tests and should be reported as results107 cmd, q_args = args.split(':')108 if cmd == 'submit_log':109 try:110 # rhts_submit_log has as args: -S -T -l111 # we just care about -l112 f = None113 arg_list = q_args.split(' ')114 while arg_list:115 arg = arg_list.pop(0)116 if arg == '-l':117 f = arg_list.pop(0)118 break119 if not f:120 raise HarnessException("Argument -l not found in q_args "121 "'%s'" % q_args)122 self.bkr_proxy.task_upload_file(task_id, f)123 except Exception:124 logging.critical('ERROR: Failed to process quick cmd %s' % cmd)125 elif cmd == 'submit_result':126 def init_args(testname='Need/a/testname/here', status="None", logfile=None, score="0"):127 return testname, status, logfile, score128 try:129 # report_result has TESTNAME STATUS LOGFILE SCORE130 arg_list = q_args.split(' ')131 testname, status, logfile, score = init_args(*arg_list)132 resultid = self.bkr_proxy.task_result(task_id, status,133 testname, score, '')134 if (logfile and os.path.isfile(logfile) and135 os.path.getsize(logfile) != 0):136 self.bkr_proxy.result_upload_file(task_id, resultid, logfile)137 # save the dmesg file138 dfile = '/tmp/beaker.dmesg'139 utils.system('dmesg -c > %s' % dfile)140 if os.path.getsize(dfile) != 0:141 self.bkr_proxy.result_upload_file(task_id, resultid, dfile)142 # os.remove(dfile)143 except Exception:144 logging.critical('ERROR: Failed to process quick cmd %s' % cmd)145 elif cmd == 'reboot':146 # we are in a stub job. Can't use self.job.reboot() :-(147 utils.system("sync; sync; reboot")148 self.run_pause()149 raise error.JobContinue("more to come")150 else:151 raise error.HarnessError("Bad sub-quickcmd: %s" % cmd)152 def bootstrap(self, fetchdir):153 '''How to kickstart autotest when you have no control file?154 You download the beaker XML, convert it to a control file155 and pass it back to autotest. Much like bootstrapping.. :-)156 '''157 # hack to sneakily pass results back to beaker without running158 # autotest. Need to avoid calling get_recipe below159 if self.cmd:160 self.parse_quickcmd(self.cmd)161 return None162 recipe = self.init_recipe_from_beaker()163 # remove stale file164 if os.path.isfile(self.state_file):165 os.remove(self.state_file)166 self.tests = {}167 # sanity check168 if self.recipe_id != raise error.HarnessError('Recipe mismatch: machine %s.. != XML %s..' %170 (self.recipe_id, # create unique name172 control_file_name = recipe.job_id + '_' + + '.control'173 control_file_path = fetchdir + '/' + control_file_name174 logging.debug('setting up control file - %s' % control_file_path)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?