Best Python code snippet using yandex-tank
plugin.py
Source:plugin.py
...25 self.disk_limit = int(self.get_option("disk_limit", self.disk_limit))26 self.mem_limit = int(self.get_option("mem_limit", self.mem_limit))27 def prepare_test(self):28 self.log.info("Checking tank resources...")29 self.__check_disk()30 self.__check_mem()31 def is_test_finished(self):32 self.log.debug("Checking tank resources...")33 if time.time() - self.last_check < self.interval:34 return -135 self.__check_disk()36 self.__check_mem()37 self.last_check = time.time()38 return -139 def __check_disk(self):40 ''' raise exception on disk space exceeded '''41 cmd = "sh -c \"df --no-sync -m -P -l -x fuse -x tmpfs -x devtmpfs -x davfs -x nfs "42 cmd += self.core.artifacts_base_dir43 cmd += " | tail -n 1 | awk '{print \$4}' \""44 res = execute(cmd, True, 0.1, True)45 logging.debug("Result: %s", res)46 if not len(res[1]):47 self.log.debug("No disk usage info: %s", res[2])48 return49 disk_free = res[1]50 self.log.debug(51 "Disk free space: %s/%s", disk_free.strip(), self.disk_limit)52 if int(disk_free.strip()) < self.disk_limit:53 raise RuntimeError(...
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!!