def test_platform_util_lscpu_parsing(platform_mock, subprocess_mock, os_mock): """ Verifies that platform_utils gives us the proper values that we expect based on the lscpu_output string provided. """ platform_mock.return_value = platform_config.SYSTEM_TYPE os_mock.return_value = True subprocess_mock.return_value = platform_config.LSCPU_OUTPUT platform_util = PlatformUtil(MagicMock(verbose=True)) platform_util.linux_init() assert platform_util.num_cpu_sockets == 2 assert platform_util.num_cores_per_socket == 28 assert platform_util.num_threads_per_core == 2 assert platform_util.num_logical_cpus == 112 assert platform_util.num_numa_nodes == 2
def test_platform_utils_num_sockets_with_cpuset(get_cpuset_mock, platform_mock, subprocess_mock, os_mock, cpuset_range, expected_num_sockets): """ Checks that the number of sockets in platform_utils reflects the proper value based on the cpuset. If the cores being used by the container in the cpuset are all on one socket, then the num_cpu_sockets should be 1, even if the system itself has 2 sockets (since the container only has access to 1). """ platform_mock.return_value = platform_config.SYSTEM_TYPE os_mock.return_value = True get_cpuset_mock.return_value = cpuset_range subprocess_mock.return_value = platform_config.LSCPU_OUTPUT platform_util = PlatformUtil(MagicMock(verbose=True)) platform_util.linux_init() assert platform_util.num_cpu_sockets == expected_num_sockets