Best Python code snippet using avocado_python
numa_stress.py
Source: numa_stress.py
...81 memory_file = utils_misc.get_path(tmpfs_path, "test")82 dd_cmd = "dd if=/dev/urandom of=%s bs=1k count=%s" % (memory_file,83 tmpfs_size)84 utils_memory.drop_caches()85 if utils_memory.freememtotal() < tmpfs_size:86 test.cancel("Host does not have enough free memory to run the test, "87 "skipping test...")88 if not os.path.isdir(tmpfs_path):89 os.mkdir(tmpfs_path)90 test_mem = float(params.get("mem"))*float(params.get("mem_ratio", 0.8))91 stress_args = "--cpu 4 --io 4 --vm 2 --vm-bytes %sM" % int(test_mem / 2)92 most_used_node, memory_used = max_mem_map_node(host_numa_node, qemu_pid)93 for test_round in range(test_count):94 if os.path.exists(memory_file):95 os.remove(memory_file)96 utils_memory.drop_caches()97 if utils_memory.freememtotal() < tmpfs_size:98 test.error("Don't have enough memory to execute this "99 "test after %s round" % test_round)100 error_context.context("Executing stress test round: %s" % test_round,101 logging.info)102 numa_node_malloc = most_used_node103 numa_dd_cmd = "numactl -m %s %s" % (numa_node_malloc, dd_cmd)104 error_context.context("Try to allocate memory in node %s"105 % numa_node_malloc, logging.info)106 try:107 utils_misc.mount("none", tmpfs_path, "tmpfs", perm=mount_fs_size)108 funcatexit.register(env, params.get("type"), utils_misc.umount,109 "none", tmpfs_path, "tmpfs")110 process.system(numa_dd_cmd, timeout=dd_timeout, shell=True)111 except Exception as error_msg:...
hardware_SAT.py
Source: hardware_SAT.py
...47 disk_thread=True):48 '''49 Args:50 free_memory_fraction: Fraction of free memory (as determined by51 utils.freememtotal()) to use.52 wait_secs: time to wait in seconds before executing stressapptest.53 disk_thread: also stress disk using -f argument of stressapptest.54 '''55 assert free_memory_fraction > 056 assert free_memory_fraction < 157 # Wait other parallel tests memory usage to settle to a stable value, so58 # stressapptest will not claim too much memory.59 if wait_secs:60 time.sleep(wait_secs)61 # Allow shmem access to all of memory. This is used for 32 bit62 # access to > 1.4G. Virtual address space limitation prevents63 # directly mapping the memory.64 utils.run('mount -o remount,size=100% /dev/shm')65 cpus = max(utils.count_cpus(), 1)66 mbytes = max(int(utils.freememtotal() * free_memory_fraction / 1024),67 512)68 # Even though shared memory allows us to go past the 1.4G69 # limit, ftruncate still limits us to 2G max on 32 bit systems.70 if sys.maxsize < 2**32 and mbytes > 2047:71 mbytes = 204772 # SAT should use as much memory as possible, while still73 # avoiding OOMs and allowing the kernel to run, so that74 # the maximum amoun tof memory can be tested.75 args = ' -M %d' % mbytes # megabytes to test76 # The number of seconds under test can be chosen to fit into77 # manufacturing or test flow. 60 seconds gives several78 # passes and several patterns over each memory location79 # and should catch clearly fautly memeory. 4 hours80 # is an effective runin test, to catch lower frequency errors....
ksm_ksmtuned.py
Source: ksm_ksmtuned.py
...45 qemu_used_page = utils_misc.normalize_data_size(process.getoutput(46 params['cmd_get_qemu_used_mem'] % qemu_pid, shell=True) + 'K', 'B')47 pagesize = utils_memory.getpagesize()48 qemu_used_mem = int(float(qemu_used_page)) * pagesize49 free_mem_host = utils_memory.freememtotal()50 ksm_status = process.getoutput(params['cmd_check_ksm_status'])51 vm.destroy()52 logging.info('The ksm threshold is %s, the memory allocated by qemu is'53 ' %s, and the total free memory on host is %s.',54 ksm_thres, qemu_used_mem, free_mem_host)55 if free_mem_host >= ksm_thres:56 if ksm_status != '0':57 test.fail('Ksm should not start.')58 if stress:59 test.error('The host resource is not consumed as expected.')60 elif ksm_status == '0':61 test.fail('Ksm should start but it does not.')62 total_mem_host = utils_memory.memtotal()63 utils_memory.drop_caches()64 free_mem_host = utils_memory.freememtotal()65 ksm_thres = process.getoutput(params['cmd_get_thres'], shell=True)66 ksm_thres = int(total_mem_host *67 (int(re.findall('\\d+', ksm_thres)[0]) / 100))68 guest_mem = (free_mem_host - ksm_thres) // 269 if arch.ARCH in ('ppc64', 'ppc64le'):70 guest_mem = guest_mem - guest_mem % (256 * 1024)71 status_ksm_service = process.system(72 params['cmd_status_ksmtuned'], ignore_status=True)73 if status_ksm_service != 0:74 process.run(params['cmd_start_ksmtuned'])75 check_ksm(guest_mem)76 ksm_config_file = params['ksm_config_file']77 backup_file = ksm_config_file + '.backup'78 copyfile(ksm_config_file, backup_file)...
Check out the latest blogs from LambdaTest on this topic:
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
In addition to the four values, the Agile Manifesto contains twelve principles that are used as guides for all methodologies included under the Agile movement, such as XP, Scrum, and Kanban.
JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.
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!!