How to use set_thp_value method in avocado

Best Python code snippet using avocado_python

transparent_hugepages_defrag.py

Source:transparent_hugepages_defrag.py Github

copy

Full Screen

...62 Once the memory gets fragmented turns on the defrag and checks63 whether defrag happened.64 '''65 # Enables THP66 memory.set_thp_value("enabled", "always")67 # Turns off Defrag68 memory.set_thp_value("khugepaged/defrag", "0")69 # Fragments The memory70 self.log.info("Fragmenting the memory Using dd command \n")71 for iterator in range(self.count):72 defrag_cmd = 'dd if=/dev/urandom of=%s/%d bs=%dK count=1'\73 % (self.mem_path, iterator, self.block_size)74 if(process.system(defrag_cmd, timeout=900,75 verbose=False, ignore_status=True, shell=True)):76 self.fail('Defrag command Failed %s' % defrag_cmd)77 hugepagesize = memory.get_huge_page_size()78 nr_full = int(0.8 * (memory.meminfo.MemTotal.k / hugepagesize))79 # Sets max possible hugepages before defrag on80 nr_hp_before = self.set_max_hugepages(nr_full)81 # Turns Defrag ON82 memory.set_thp_value("khugepaged/defrag", "1")83 self.log.info("Sleeping %d seconds to settle out things", 12)84 time.sleep(12)85 # Sets max hugepages after defrag on86 nr_hp_after = self.set_max_hugepages(nr_full)87 # Check for memory defragmentation88 if nr_hp_before >= nr_hp_after:89 e_msg = "No Memory Defragmentation\n"90 e_msg += "%d hugepages before turning khugepaged on,\n"\91 "%d After it" % (nr_hp_before, nr_hp_after)92 self.fail(e_msg)93 self.log.info("Defrag test passed")94 @staticmethod95 def set_max_hugepages(nr_full):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

transparent_hugepages_swapping.py

Source:transparent_hugepages_swapping.py Github

copy

Full Screen

...65 THP is swapped out.66 '''67 # Enables THP68 try:69 memory.set_thp_value("enabled", "always")70 except Exception as details:71 self.fail("Failed %s" % details)72 for iterator in range(self.count):73 swap_cmd = "dd if=/dev/zero of=%s/%d bs=%sM "\74 "count=1" % (self.mem_path, iterator,75 self.hugepage_size * 2)76 if(process.system(swap_cmd, timeout=self.dd_timeout,77 verbose=False, ignore_status=True, shell=True)):78 self.fail('Swap command Failed %s' % swap_cmd)79 self.swap_free.append(memory.meminfo.SwapFree.m)80 # Checks Swap is used or not81 if self.swap_free[1] - self.swap_free[0] >= 0:82 self.fail("Swap Space remains untouched")83 def tearDown(self):...

Full Screen

Full Screen

migrate_pages.py

Source:migrate_pages.py Github

copy

Full Screen

...59 self.cancel('%s is needed for the test to be run' % package)60 # Enable THP61 if self.thp:62 try:63 memory.set_thp_value("enabled", "always")64 except Exception as details:65 self.fail("Failed to enable thp %s" % details)66 for file_name in ['node_move_pages.c', 'Makefile']:67 self.copyutil(file_name)68 build.make(self.teststmpdir)69 def test(self):70 os.chdir(self.teststmpdir)71 cmd = './node_move_pages -n %s' % self.nr_chunks72 if self.hpage:73 cmd += ' -h'74 if self.hpage_commit:75 cmd += ' -o'76 elif self.thp:77 cmd += ' -t'...

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