How to use cgconfig_restart method in autotest

Best Python code snippet using autotest_python

cpu_high_load_test.py

Source:cpu_high_load_test.py Github

copy

Full Screen

...172 dic_cgroup_property[cgroup_name2] = mk_dic_property(controller_list,173 property_value2)174 cgconfig_file_modify(cgconfig_file, controller_list,175 dic_cgroup_property, cgroup)176 utils_cgroup.cgconfig_restart()177 # After cgconfig restart, there are some cgroups created automatically178 cgroup.refresh_cgroups()179 cgroup_index1 = cgroup.get_cgroup_index(cgroup=cgroup_name1)180 cgroup_index2 = cgroup.get_cgroup_index(cgroup=cgroup_name2)181 threads = []182 cgroup_name = []183 cgroup_name.append(cgroup_name1)184 cgroup_name.append(cgroup_name2)185 sh_path = []186 sh_path.append(tmp_file1)187 sh_path.append(tmp_file2)188 for i in range(0, 2):189 thd = threading.Thread(190 target=cgroup.cgexec,191 args=(cgroup_name[i], sh_path[i]))192 threads.append(thd)193 # Start process194 for i in range(0, 2):195 threads[i].start()196 time.sleep(3)197 pid_list1 = cgroup.get_pids(cgroup_index1)198 pid_list2 = cgroup.get_pids(cgroup_index2)199 pid_rate1 = get_cpu_rate(pid_list1)200 pid_rate2 = get_cpu_rate(pid_list2)201 kill_pids(pid_list1)202 kill_pids(pid_list2)203 del cgroup204 del modules205 if pid_rate1.get(pid_list1[-1]) <= pid_rate2.get(pid_list1[-1]):206 raise error.TestFail("cpu rate test pid rate failed!")207 finally:208 # Recover environment209 utils.run(recover_cmd)210 utils_cgroup.cgconfig_restart()211def execute(cgroup_cls):212 """213 Execute cpu test.214 :param cgroup_cls: Cgroup class215 """216 if cgroup_cls is None:217 raise error.TestNAError("Got a none cgroup class")218 cpu_test = CpuHighLoad(cgroup_cls._cgroup_dir, cgroup_cls.tmpdir)...

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