How to use __check_mem method in yandex-tank

Best Python code snippet using yandex-tank

plugin.py

Source:plugin.py Github

copy

Full Screen

...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(54 "Not enough local resources: disk space less than %sMB in %s: %sMB"55 % (56 self.disk_limit, self.core.artifacts_base_dir,57 int(disk_free.strip())))58 def __check_mem(self):59 ''' raise exception on RAM exceeded '''60 mem_free = psutil.virtual_memory().available / 2**2061 self.log.debug("Memory free: %s/%s", mem_free, self.mem_limit)62 if mem_free < self.mem_limit:63 raise RuntimeError(64 "Not enough resources: free memory less "...

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 yandex-tank 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