Best Python code snippet using autotest_python
numa_consistency.py
Source:numa_consistency.py  
...21    :param params: Dictionary with the test parameters22    :param env: Dictionary with test environment.23    """24    def get_vcpu_used_node(numa_node_info, vcpu_thread):25        cpu_used_host = utils_misc.get_thread_cpu(vcpu_thread)[0]26        node_used_host = ([_ for _ in node_list if cpu_used_host27                           in numa_node_info.nodes[_].cpus][0])28        return node_used_host29    error.context("Get host numa topological structure", logging.info)30    timeout = float(params.get("login_timeout", 240))31    host_numa_node = utils_misc.NumaInfo()32    node_list = host_numa_node.online_nodes33    if len(node_list) < 2:34        raise error.TestNAError("This host only has one NUMA node, "35                                "skipping test...")36    node_list.sort()37    params['smp'] = len(node_list)38    params['vcpu_cores'] = 139    params['vcpu_threads'] = 1...jstack.py
Source:jstack.py  
...22    @staticmethod23    def find_high_cpu(pid=None):24        """ find the threads that make high CPU """25        if pid:26            JStack.get_thread_cpu(pid)27            JStack.get_thread_stack(pid)28    @staticmethod29    def get_thread_cpu(pid):30        """ get top thread ids that high CPU """31        JStack.__thread_info__ = {}32        cmd_find_top_thread = 'top -b -Hp %d -n 1' % pid33        out_threads = Command.run(cmd_find_top_thread)34        loop_count = 035        for thread_line in out_threads:36            if JStack.__re_top_title__.search(thread_line):37                loop_count += 138                array_col = thread_line.split()39                index_pid = None40                index_cpu = None41                for i in range(len(array_col)):42                    if array_col[i] == 'PID':43                        index_pid = i...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!!
