How to use convert_task_to_control method in autotest

Best Python code snippet using autotest_python

harness_beaker.py

Source:harness_beaker.py Github

copy

Full Screen

...175 control_file = open(control_file_path, 'w')176 try:177 # convert recipe xml into control file178 for task in recipe.tasks:179 self.convert_task_to_control(fetchdir, control_file, task)180 # getting the task id later, will be hard, store it in file/memory181 self.write_processed_tests(self.get_test_name(task), task.id)182 control_file.close()183 except HarnessException:184 # hook to bail out on reservesys systems and not run autotest185 return None186 except Exception, ex:187 os.remove(control_file_path)188 raise error.HarnessError('beaker_harness: convert failed with -> %s' % ex)189 # autotest should find this under FETCHDIRTEST because it is unique190 return control_file_path191 def init_recipe_from_beaker(self):192 logging.debug('Contacting beaker to get task details')193 bxp = BeakerXMLParser()194 recipe_xml = self.get_recipe_from_LC()195 recipes_dict = bxp.parse_xml(recipe_xml)196 return self.find_recipe(recipes_dict)197 def init_task_params(self, task):198 logging.debug('PrepareTaskParams')199 if task is None:200 raise error.HarnessError('No valid task')201 for (name, value) in task.params.items():202 logging.debug('adding to os.environ: <%s=%s>', name, value)203 os.environ[name] = value204 def get_recipe_from_LC(self):205 logging.debug('trying to get recipe from LC:')206 try:207 recipe = self.bkr_proxy.get_recipe()208 except Exception, exc:209 raise error.HarnessError('Failed to retrieve xml: %s' % exc)210 return recipe211 def find_recipe(self, recipes_dict):212 if self.hostname in recipes_dict:213 return recipes_dict[self.hostname]214 for h in recipes_dict:215 if self.recipe_id == recipes_dict[h].id:216 return recipes_dict[h]217 raise error.HarnessError('No valid recipe for host %s' % self.hostname)218 # the block below was taken from standalone harness219 def setupInitSymlink(self):220 logging.debug('Symlinking init scripts')221 autodir = os.environ.get('AUTODIR')222 rc = os.path.join(autodir, 'tools/autotest')223 if os.path.isfile(rc) and os.path.islink(rc):224 # nothing to do225 return226 # see if system supports event.d versus inittab227 if os.path.exists('/etc/event.d'):228 # NB: assuming current runlevel is default229 initdefault = utils.system_output('/sbin/runlevel').split()[1]230 elif os.path.exists('/etc/inittab'):231 initdefault = utils.system_output('grep :initdefault: /etc/inittab')232 initdefault = initdefault.split(':')[1]233 else:234 initdefault = '2'235 try:236 utils.system('ln -sf %s /etc/init.d/autotest' % rc)237 utils.system('ln -sf %s /etc/rc%s.d/S99autotest' % (rc, initdefault))238 logging.debug('Labeling init scripts with unconfined_exec_t')239 utils.system('chcon -h system_u:object_r:unconfined_exec_t:s0 /etc/init.d/autotest')240 utils.system('chcon -h system_u:object_r:unconfined_exec_t:s0 /etc/rc%s.d/S99autotest' % initdefault)241 autotest_init = os.path.join(autodir, 'tools/autotest')242 ret = os.system('chcon system_u:object_r:unconfined_exec_t:s0 %s' % autotest_init)243 logging.debug('chcon returned <%s>', ret)244 except Exception:245 logging.warning('Linking init scripts failed')246 def get_test_name(self, task):247 name = re.sub('-', '_', task.rpmName)248 return re.sub('\.', '_', name)249 def convert_task_to_control(self, fetchdir, control, task):250 """Tasks are really just:251 # yum install $TEST252 # cd /mnt/tests/$TEST253 # make run254 Convert that into a test module with a control file255 """256 timeout = ''257 if task.timeout:258 timeout = ", timeout=%s" % task.timeout259 # python doesn't like '-' in its class names260 rpm_name = self.get_test_name(task)261 rpm_dir = fetchdir + '/' + rpm_name262 rpm_file = rpm_dir + '/' + rpm_name + '.py'263 if task.status == 'Completed' and not self.offline:...

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:

YouTube

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?

Helpful

NotHelpful