How to use set_num_huge_pages method in avocado

Best Python code snippet using avocado_python

memory_update_device.py

Source:memory_update_device.py Github

copy

Full Screen

...49 Setup vmxml for test50 """51 set_num_huge_pages = params.get("set_num_huge_pages")52 if set_num_huge_pages:53 utils_memory.set_num_huge_pages(int(set_num_huge_pages))54 libvirt_vmxml.remove_vm_devices_by_type(vm, 'memory')55 vm_attrs = eval(params.get('vm_attrs', '{}'))56 vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name)57 vmxml.setup_attrs(**vm_attrs)58 vmxml.sync()59 mem_device_attrs = eval(params.get('mem_device_attrs', '{}'))60 mem_device = Memory()61 mem_device.setup_attrs(**mem_device_attrs)62 virsh.attach_device(vm_name, mem_device.xml, flagstr='--config',63 debug=True, ignore_status=False)64 test.log.debug("vmxml is {}".format(vm_xml.VMXML.65 new_from_dumpxml(vm_name)))66 def run_test_virtio_mem():67 """68 Update memory device for virtio-mem device69 """70 mem_device_attrs = eval(params.get('mem_device_attrs', '{}'))71 vm.start()72 vm_session = vm.wait_for_login()73 cmdRes = vm_session.cmd_output('free -m')74 vm_mem_before = int(re.findall(r'Mem:\s+(\d+)\s+\d+\s+', cmdRes)[-1])75 test.log.debug("VM's memory before updating requested size: %s",76 vm_mem_before)77 test.log.info("TEST_STEP1: Update requested size for virtio-mem device.")78 vmxml_cur = vm_xml.VMXML.new_from_dumpxml(vm_name)79 mem_dev = vmxml_cur.devices.by_device_tag("memory")[0]80 mem_dev_alias = mem_dev.fetch_attrs()['alias']['name']81 virsh_opts = params.get('virsh_opts') % mem_dev_alias82 virsh.update_memory_device(vm.name, options=virsh_opts,83 wait_for_event=True, **VIRSH_ARGS)84 test.log.info("TEST_STEP2: Check requested and current size changes.")85 mem_dev = vm_xml.VMXML.new_from_dumpxml(vm_name).devices.\86 by_device_tag("memory")[0]87 expr_requested_size = int(float(utils_misc.normalize_data_size(88 params.get("requested_size", '80Mib'), order_magnitude='K')))89 for check_item in ['requested_size', 'current_size']:90 test.log.debug("Expected size is {}, Actual size is {}".91 format(expr_requested_size,92 getattr(mem_dev.target, check_item)))93 if getattr(mem_dev.target, check_item) != expr_requested_size:94 test.fail("Incorrect %s! It should be %s, but got %s."95 % (check_item, expr_requested_size,96 getattr(mem_dev.target, check_item)))97 test.log.info("TEST_STEP3: Check 'MEMORY_DEVICE_SIZE_CHANGE' in "98 "libvirtd/virtqemud log")99 log_file = utils_misc.get_path(test.debugdir, "libvirtd.log")100 check_log_str = params.get("check_log_str", "MEMORY_DEVICE_SIZE_CHANGE")101 libvirt.check_logfile(check_log_str, log_file)102 test.log.info("TEST STEP4: Check memory in the VM.")103 cmdRes = vm_session.cmd_output('free -m')104 vm_mem_after = int(re.findall(r'Mem:\s+(\d+)\s+\d+\s+', cmdRes)[-1])105 mem_request_decrease = (mem_device_attrs['target']['requested_size'] -106 expr_requested_size)/1024107 vm_mem_decrease = vm_mem_before - vm_mem_after108 if mem_request_decrease != vm_mem_decrease:109 test.fail("VM mem change comparison failed! Expect %d, but got %d."110 % (mem_request_decrease, vm_mem_decrease))111 def cleanup_test_virtio_mem():112 """113 Clean up environment114 """115 if utils_memory.get_num_huge_pages() != ORG_HP:116 utils_memory.set_num_huge_pages(ORG_HP)117 # Variable assignment118 test_case = params.get('test_case', '')119 vm_name = params.get('main_vm')120 vm = env.get_vm(vm_name)121 check_environment(vm, params)122 bkxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)123 # Get setup function124 setup_test = eval('setup_test_%s' % test_case) \125 if 'setup_test_%s' % test_case in locals() else setup_test_default126 # Get runtest function127 run_test = eval('run_test_%s' % test_case)128 # Get cleanup function129 cleanup_test = eval('cleanup_test_%s' % test_case) \130 if 'cleanup_test_%s' % test_case in locals() else cleanup_test_default...

Full Screen

Full Screen

memory_attach_device.py

Source:memory_attach_device.py Github

copy

Full Screen

...47 Setup vmxml for test48 """49 set_num_huge_pages = params.get("set_num_huge_pages")50 if set_num_huge_pages:51 utils_memory.set_num_huge_pages(int(set_num_huge_pages))52 libvirt_vmxml.remove_vm_devices_by_type(vm, 'memory')53 vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name)54 vm_attrs = eval(params.get('vm_attrs', '{}'))55 vmxml.setup_attrs(**vm_attrs)56 vmxml.sync()57 if params.get("start_vm") == "yes":58 vm.start()59 vm.wait_for_login().close()60 def run_test_virtio_mem():61 """62 Attach a virtio-mem device63 """64 mem_device_attrs = eval(params.get('mem_device_attrs', '{}'))65 mem_device = Memory()66 mem_device.setup_attrs(**mem_device_attrs)67 test.log.info("TEST_STEP1: Attach a virtio-mem device.")68 options = '' if vm.is_alive() else '--config'69 virsh.attach_device(vm_name, mem_device.xml, flagstr=options,70 debug=True, ignore_status=False)71 if not vm.is_alive():72 vm.start()73 vm.wait_for_login().close()74 test.log.info("TEST_STEP2: Check requested and current size.")75 vmxml_cur = vm_xml.VMXML.new_from_dumpxml(vm_name)76 test.log.debug("Current VM XML: %s.", vmxml_cur)77 mem_dev = vmxml_cur.devices.by_device_tag("memory")[0]78 expr_requested_size = mem_device_attrs['target']['requested_size']79 for check_item in ['requested_size', 'current_size']:80 if getattr(mem_dev.target, check_item) != expr_requested_size:81 test.fail("Incorrect %s! It should be %s, but got %s."82 % (check_item, expr_requested_size,83 getattr(mem_dev.target, check_item)))84 test.log.info("TEST_STEP3: Check VM memory.")85 memory_gap = vmxml_cur.get_memory() - vmxml_cur.get_current_mem()86 virtio_mem_gap = mem_dev.target.get_size() - \87 mem_dev.target.get_current_size()88 if memory_gap != virtio_mem_gap:89 test.fail("Size of memory - currentMemory(%s) should be equal to "90 "virtio-mem size - current(%s)."91 % (memory_gap, virtio_mem_gap))92 def cleanup_test_virtio_mem():93 """94 Clean up environment95 """96 if utils_memory.get_num_huge_pages() != ORG_HP:97 utils_memory.set_num_huge_pages(ORG_HP)98 # Variable assignment99 test_case = params.get('test_case', '')100 vm_name = params.get('main_vm')101 vm = env.get_vm(vm_name)102 check_environment(vm, params)103 bkxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)104 # Get setup function105 setup_test = eval('setup_test_%s' % test_case) \106 if 'setup_test_%s' % test_case in locals() else setup_test_default107 # Get runtest function108 run_test = eval('run_test_%s' % test_case)109 # Get cleanup function110 cleanup_test = eval('cleanup_test_%s' % test_case) \111 if 'cleanup_test_%s' % test_case in locals() else cleanup_test_default...

Full Screen

Full Screen

transparent_hugepages_defrag.py

Source:transparent_hugepages_defrag.py Github

copy

Full Screen

...96 '''97 Tries to set the hugepages to the nr_full value and returns the98 max possible value set.99 '''100 memory.set_num_huge_pages(nr_full)101 return memory.get_num_huge_pages()102 def tearDown(self):103 '''104 Removes files and unmounts the tmpfs.105 '''106 if self.mem_path:107 self.log.info('Cleaning Up!!!')108 memory.set_thp_value("khugepaged/defrag", "0")109 memory.set_num_huge_pages(0)110 self.device.unmount()...

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 avocado 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