def unpatched(): if len(subcgroups_paths): platform = Platform(sockets=1, cores=1, cpus=2, numa_nodes=2, topology={0: { 0: [1, 2] }}, cpu_model='intel xeon', cpu_model_number=0x5E, cpu_codename=CPUCodeName.SKYLAKE, timestamp=time.time(), rdt_information=RDTInformation( True, True, rdt_mb_control_enabled, rdt_cache_control_enabled, '0', '0', 0, 0, 0), node_cpus={0: {0, 1}}, node_distances={0: { 0: 10 }}, measurements={}, swap_enabled=False) return ContainerSet( cgroup_path=cgroup_path, cgroup_paths=subcgroups_paths, platform=platform, allocation_configuration=AllocationConfiguration() if with_config else None, resgroup=ResGroup(name=resgroup_name) if rdt_enabled else None, event_names=['task_cycles']) else: platform = Platform(sockets=1, cores=1, cpus=2, numa_nodes=2, topology={0: { 0: [1, 2] }}, cpu_model='intel xeon', cpu_model_number=0x5E, cpu_codename=CPUCodeName.SKYLAKE, timestamp=time.time(), rdt_information=RDTInformation( True, True, True, True, '0', '0', 0, 0, 0), node_cpus={0: {0, 1}}, node_distances={0: { 0: 10 }}, measurements={}, swap_enabled=False) return Container( cgroup_path=cgroup_path, platform=platform, allocation_configuration=AllocationConfiguration() if with_config else None, resgroup=ResGroup(name=resgroup_name) if rdt_enabled else None, event_names=['task_cycles'], )
def unpatched(): if len(subcgroups_paths): return ContainerSet( cgroup_path=cgroup_path, cgroup_paths=subcgroups_paths, platform_cpus=1, platform_sockets=1, allocation_configuration=AllocationConfiguration() if with_config else None, resgroup=ResGroup(name=resgroup_name) if rdt_enabled else None, rdt_information=RDTInformation(True, True, rdt_mb_control_enabled, rdt_cache_control_enabled, '0', '0', 0, 0, 0), event_names=DEFAULT_EVENTS) else: return Container( cgroup_path=cgroup_path, platform_cpus=1, platform_sockets=1, rdt_information=RDTInformation(True, True, True, True, '0', '0', 0, 0, 0), allocation_configuration=AllocationConfiguration() if with_config else None, resgroup=ResGroup(name=resgroup_name) if rdt_enabled else None, event_names=DEFAULT_EVENTS)
def test_cpuset_for_container_set(): rdt_information = RDTInformation(True, True, True, True, '0', '0', 0, 0, 0) platform_mock = Mock( spec=Platform, cpus=10, sockets=1, rdt_information=rdt_information, node_cpus={ 0: [0, 1], 1: [2, 3] }, numa_nodes=2, swap_enabled=False, ) foo_container_set = ContainerSet( cgroup_path='/foo', cgroup_paths=['/foo/bar-1', '/foo/bar-2', '/foo/bar-3'], platform=platform_mock, ) cgroup = foo_container_set.get_cgroup() cgroup.set_cpuset_cpus = Mock() cgroup.set_cpuset_mems = Mock() for subcgroup in foo_container_set.get_subcgroups(): subcgroup.set_cpuset_cpus = Mock() subcgroup.set_cpuset_mems = Mock() cpuset_cpus = CPUSetCPUSAllocationValue('0-2', foo_container_set, {}) cpuset_cpus.perform_allocations() cpuset_mems = CPUSetMEMSAllocationValue('0-1', foo_container_set, {}) cpuset_mems.perform_allocations() # Cgroup shouldn't be affected. cgroup.set_cpuset_cpus.assert_not_called() cgroup.set_cpuset_mems.assert_not_called() # Subcgroups should change cpuset param. for subcgroup in foo_container_set.get_subcgroups(): subcgroup.set_cpuset_cpus.assert_called_once_with({0, 1, 2}) subcgroup.set_cpuset_mems.assert_called_once_with({0, 1})
def unpatched(): if len(subcgroups_paths): platform = Platform(sockets=1, cores=1, cpus=2, cpu_model='intel xeon', cpu_model_number=0x5E, cpu_codename=CPUCodeName.SKYLAKE, cpus_usage={ 0: 10, 1: 10 }, total_memory_used=10, timestamp=time.time(), rdt_information=RDTInformation( True, True, rdt_mb_control_enabled, rdt_cache_control_enabled, '0', '0', 0, 0, 0)) return ContainerSet( cgroup_path=cgroup_path, cgroup_paths=subcgroups_paths, platform=platform, allocation_configuration=AllocationConfiguration() if with_config else None, resgroup=ResGroup(name=resgroup_name) if rdt_enabled else None, event_names=DEFAULT_EVENTS) else: platform = Platform(sockets=1, cores=1, cpus=2, cpu_model='intel xeon', cpu_model_number=0x5E, cpu_codename=CPUCodeName.SKYLAKE, cpus_usage={ 0: 10, 1: 10 }, total_memory_used=10, timestamp=time.time(), rdt_information=RDTInformation( True, True, True, True, '0', '0', 0, 0, 0)) return Container( cgroup_path=cgroup_path, platform=platform, allocation_configuration=AllocationConfiguration() if with_config else None, resgroup=ResGroup(name=resgroup_name) if rdt_enabled else None, event_names=DEFAULT_EVENTS)