コード例 #1
0
    def test_dpdk_bond(self):
        numa_nodes = self._create_numa_nodes(4, 8)
        components = self._create_nova_dpdk(15, 12)
        nics_numas = [0, 1]

        expected_data = {
            'components': {
                'ovs_core_mask': [0],
                'ovs_pmd_core_mask': (list(range(1, 5))
                                      + list(range(8, 12))
                                      + [16, 24, 12]),
                'nova': (list(range(17, 24))
                         + list(range(25, 32))
                         + [13]),
            },
            'isolated_cpus': (list(range(0, 5))
                              + list(range(8, 14))
                              + list(range(16, 32))),
        }

        actual = cpu_distribution.distribute_node_cpus(
            numa_nodes, components, nics_numas)

        for name in expected_data['components']:
            self.assertItemsEqual(expected_data['components'][name],
                                  actual['components'][name])

        self.assertItemsEqual(
            expected_data['isolated_cpus'],
            actual['isolated_cpus'])
コード例 #2
0
    def test_custom_components(self):
        numa_nodes = self._create_numa_nodes(2, 4)
        components = {
            'comp1': {
                'name': 'comp1',
                'required_cpus': 3,
            },
            'comp2': {
                'name': 'comp2',
                'required_cpus': 2,
            }
        }
        nics_numas = []

        expected_data = {
            'components': {
                'comp1': [0, 1, 2],
                'comp2': [4, 5],
            },
            'isolated_cpus': [0, 1, 2, 4, 5],
        }

        self.assertEqual(
            expected_data,
            cpu_distribution.distribute_node_cpus(numa_nodes, components,
                                                  nics_numas))
コード例 #3
0
    def test_custom_components(self):
        numa_nodes = self._create_numa_nodes(2, 4)
        components = {
            'comp1': {
                'name': 'comp1',
                'required_cpus': 3,
            },
            'comp2': {
                'name': 'comp2',
                'required_cpus': 2,
            }
        }
        nics_numas = []

        expected_data = {
            'components': {
                'comp1': [0, 1, 2],
                'comp2': [4, 5],
            },
            'isolated_cpus': [0, 1, 2, 4, 5],
        }

        self.assertEqual(
            expected_data,
            cpu_distribution.distribute_node_cpus(
                numa_nodes, components, nics_numas))
コード例 #4
0
    def test_dpdk_bond(self):
        numa_nodes = self._create_numa_nodes(4, 8)
        components = self._create_nova_dpdk(15, 12)
        nics_numas = [0, 1]

        expected_data = {
            'components': {
                'ovs_core_mask': [0],
                'ovs_pmd_core_mask':
                (list(range(1, 5)) + list(range(8, 12)) + [16, 24, 12]),
                'nova': (list(range(17, 24)) + list(range(25, 32)) + [13]),
            },
            'isolated_cpus':
            (list(range(0, 5)) + list(range(8, 14)) + list(range(16, 32))),
        }

        actual = cpu_distribution.distribute_node_cpus(numa_nodes, components,
                                                       nics_numas)

        for name in expected_data['components']:
            self.assertItemsEqual(expected_data['components'][name],
                                  actual['components'][name])

        self.assertItemsEqual(expected_data['isolated_cpus'],
                              actual['isolated_cpus'])
コード例 #5
0
    def test_no_cpus_required(self):
        numa_nodes = self._create_numa_nodes(2, 4)
        components = self._create_nova_dpdk(0, 0)
        nics_numas = []

        expected_data = {'components': {}, 'isolated_cpus': []}

        self.assertEqual(
            expected_data,
            cpu_distribution.distribute_node_cpus(numa_nodes, components,
                                                  nics_numas))
コード例 #6
0
    def test_no_cpus_required(self):
        numa_nodes = self._create_numa_nodes(2, 4)
        components = self._create_nova_dpdk(0, 0)
        nics_numas = []

        expected_data = {
            'components': {
            },
            'isolated_cpus': []
        }

        self.assertEqual(
            expected_data,
            cpu_distribution.distribute_node_cpus(
                numa_nodes, components, nics_numas))
コード例 #7
0
    def test_one_component(self):
        numa_nodes = self._create_numa_nodes(2, 3)
        components = self._create_nova_dpdk(5, 0)
        nics_numas = []

        expected_data = {
            'components': {
                'nova': [0, 1, 2, 3, 4],
            },
            'isolated_cpus': [0, 1, 2, 3, 4],
        }

        self.assertEqual(
            expected_data,
            cpu_distribution.distribute_node_cpus(numa_nodes, components,
                                                  nics_numas))
コード例 #8
0
    def test_one_component(self):
        numa_nodes = self._create_numa_nodes(2, 3)
        components = self._create_nova_dpdk(5, 0)
        nics_numas = []

        expected_data = {
            'components': {
                'nova': [0, 1, 2, 3, 4],
            },
            'isolated_cpus': [0, 1, 2, 3, 4],
        }

        self.assertEqual(
            expected_data,
            cpu_distribution.distribute_node_cpus(
                numa_nodes, components, nics_numas))
コード例 #9
0
    def test_few_cpus_required(self):
        numa_nodes = self._create_numa_nodes(2, 3)
        components = self._create_nova_dpdk(1, 2)
        nics_numas = [0]

        expected_data = {
            'components': {
                'ovs_core_mask': [0],
                'ovs_pmd_core_mask': [1],
                'nova': [3]
            },
            'isolated_cpus': [0, 1, 3]
        }
        self.assertEqual(
            expected_data,
            cpu_distribution.distribute_node_cpus(numa_nodes, components,
                                                  nics_numas))
コード例 #10
0
    def test_few_cpus_required(self):
        numa_nodes = self._create_numa_nodes(2, 3)
        components = self._create_nova_dpdk(1, 2)
        nics_numas = [0]

        expected_data = {
            'components': {
                'ovs_core_mask': [0],
                'ovs_pmd_core_mask': [1],
                'nova': [3]
            },
            'isolated_cpus': [0, 1, 3]
        }
        self.assertEqual(
            expected_data,
            cpu_distribution.distribute_node_cpus(
                numa_nodes, components, nics_numas))
コード例 #11
0
 def test_few_cpus_required(self):
     numa_nodes = [{'cpus': [0, 1, 2]}, {'cpus': [3, 4, 5]}]
     components = [{
         'name': 'nova',
         'required_cpus': 1
     }, {
         'name': 'dpdk',
         'required_cpus': 1
     }]
     expected_data = {
         'components': {
             'dpdk': [0],
             'nova': [1]
         },
         'isolated_cpus': [0, 1]
     }
     self.assertEquals(
         expected_data,
         cpu_distribution.distribute_node_cpus(numa_nodes, components))
コード例 #12
0
 def test_no_cpus_required(self):
     numa_nodes = [{'cpus': [0, 1, 2, 3]}, {'cpus': [4, 5, 6, 7]}]
     components = [{
         'name': 'nova',
         'required_cpus': 0
     }, {
         'name': 'dpdk',
         'required_cpus': 0
     }]
     expected_data = {
         'components': {
             'dpdk': [],
             'nova': []
         },
         'isolated_cpus': []
     }
     self.assertEquals(
         expected_data,
         cpu_distribution.distribute_node_cpus(numa_nodes, components))
コード例 #13
0
 def test_no_cpus_required(self):
     numa_nodes = [
         {'cpus': [0, 1, 2, 3]},
         {'cpus': [4, 5, 6, 7]}]
     components = [
         {'name': 'nova',
          'required_cpus': 0},
         {'name': 'dpdk',
          'required_cpus': 0}]
     expected_data = {
         'components': {
             'dpdk': [],
             'nova': []
         },
         'isolated_cpus': []
     }
     self.assertEquals(
         expected_data,
         cpu_distribution.distribute_node_cpus(numa_nodes, components))
コード例 #14
0
 def test_few_cpus_required(self):
     numa_nodes = [
         {'cpus': [0, 1, 2]},
         {'cpus': [3, 4, 5]}]
     components = [
         {'name': 'nova',
          'required_cpus': 1},
         {'name': 'dpdk',
          'required_cpus': 1}]
     expected_data = {
         'components': {
             'dpdk': [0],
             'nova': [1]
         },
         'isolated_cpus': [0, 1]
     }
     self.assertEquals(
         expected_data,
         cpu_distribution.distribute_node_cpus(numa_nodes, components))
コード例 #15
0
    def test_many_cpus_required(self):
        numa_nodes = self._create_numa_nodes(2, 4)
        components = self._create_nova_dpdk(4, 3)
        nics_numas = [1]

        expected_data = {
            'components': {
                'nova': [0, 1, 2, 3],
                'ovs_core_mask': [4],
                'ovs_pmd_core_mask': [5, 6],
            },
            'isolated_cpus': [0, 1, 2, 3, 4, 5, 6],
        }

        saved_numa_nodes = copy.deepcopy(numa_nodes)
        self.assertEqual(
            expected_data,
            cpu_distribution.distribute_node_cpus(numa_nodes, components,
                                                  nics_numas))
        self.assertEqual(saved_numa_nodes, numa_nodes)
コード例 #16
0
    def test_many_cpus_required(self):
        numa_nodes = self._create_numa_nodes(2, 4)
        components = self._create_nova_dpdk(4, 3)
        nics_numas = [1]

        expected_data = {
            'components': {
                'nova': [0, 1, 2, 3],
                'ovs_core_mask': [4],
                'ovs_pmd_core_mask': [5, 6],
            },
            'isolated_cpus': [0, 1, 2, 3, 4, 5, 6],
        }

        saved_numa_nodes = copy.deepcopy(numa_nodes)
        self.assertEqual(
            expected_data,
            cpu_distribution.distribute_node_cpus(
                numa_nodes, components, nics_numas))
        self.assertEqual(saved_numa_nodes, numa_nodes)
コード例 #17
0
 def test_many_cpus_required(self):
     numa_nodes = [
         {'cpus': [0, 1, 2, 3]},
         {'cpus': [4, 5, 6, 7]}]
     components = [
         {'name': 'nova',
          'required_cpus': 5},
         {'name': 'dpdk',
          'required_cpus': 2}]
     expected_data = {
         'components': {
             'nova': [1, 2, 3, 5, 6],
             'dpdk': [0, 4]
         },
         'isolated_cpus': [0, 1, 2, 3, 4, 5, 6]
     }
     saved_numa_nodes = copy.deepcopy(numa_nodes)
     self.assertEquals(
         expected_data,
         cpu_distribution.distribute_node_cpus(numa_nodes, components))
     self.assertEquals(saved_numa_nodes, numa_nodes)
コード例 #18
0
 def test_many_cpus_required(self):
     numa_nodes = [{'cpus': [0, 1, 2, 3]}, {'cpus': [4, 5, 6, 7]}]
     components = [{
         'name': 'nova',
         'required_cpus': 5
     }, {
         'name': 'dpdk',
         'required_cpus': 2
     }]
     expected_data = {
         'components': {
             'nova': [1, 2, 3, 5, 6],
             'dpdk': [0, 4]
         },
         'isolated_cpus': [0, 1, 2, 3, 4, 5, 6]
     }
     saved_numa_nodes = copy.deepcopy(numa_nodes)
     self.assertEquals(
         expected_data,
         cpu_distribution.distribute_node_cpus(numa_nodes, components))
     self.assertEquals(saved_numa_nodes, numa_nodes)