Best Python code snippet using autotest_python
harness_beaker.py
Source: harness_beaker.py
...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:...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!