Ejemplo n.º 1
0
    def test_check(self):
        def update():
            if not mock_force_rebind.called:
                raise exceptions.IncorrectConfig(error_msg='')

            interfaces[0]['virtual-interface'].update({
                'vpci': '0000:01:02.1',
                'local_ip': '10.20.30.40',
                'netmask': '255.255.0.0',
                'driver': 'ixgbe',
            })

        mock_ssh_helper = mock.Mock()
        mock_ssh_helper.execute.return_value = 0, '', ''

        interfaces = [
            {
                'name': 'name1',
                'virtual-interface': {
                    'local_mac': 404,
                }
            },
        ]

        dpdk_node = DpdkNode(NAME, interfaces, mock_ssh_helper)
        dpdk_node._probe_missing_values = mock_probe_missing = mock.Mock(
            side_effect=update)
        dpdk_node._force_rebind = mock_force_rebind = mock.Mock()

        self.assertIsNone(dpdk_node.check())
        self.assertEqual(mock_probe_missing.call_count, 2)
Ejemplo n.º 2
0
 def _check_interface_fields(self):
     num_nodes = len(self.scenario_helper.nodes)
     # OpenStack instance creation time is probably proportional to the number
     # of instances
     timeout = 120 * num_nodes
     dpdk_node = DpdkNode(self.scenario_helper.name, self.vnfd_helper.interfaces,
                          self.ssh_helper, timeout)
     dpdk_node.check()
Ejemplo n.º 3
0
    def test_force_rebind(self):
        mock_ssh_helper = mock.Mock()
        mock_ssh_helper.execute.return_value = 0, '', ''

        dpdk_node = DpdkNode(NAME, self.INTERFACES, mock_ssh_helper)
        dpdk_helper = dpdk_node.dpdk_helper
        dpdk_helper.force_dpdk_rebind = mock_helper_func = mock.Mock()

        dpdk_node._force_rebind()
        mock_helper_func.assert_called_once()
Ejemplo n.º 4
0
    def test_check_negative(self, mock_intf_type):
        mock_ssh_helper = mock.Mock()
        mock_ssh_helper.execute.return_value = 0, '', ''

        mock_intf_type().check.side_effect = exceptions.SSHError

        dpdk_node = DpdkNode(NAME, self.INTERFACES, mock_ssh_helper)

        with self.assertRaises(exceptions.IncorrectSetup):
            dpdk_node.check()
Ejemplo n.º 5
0
    def test_probe_netdevs_setup_negative(self):
        mock_ssh_helper = mock.Mock()
        mock_ssh_helper.execute.return_value = 0, '', ''

        dpdk_node = DpdkNode(NAME, self.INTERFACES, mock_ssh_helper)
        dpdk_helper = dpdk_node.dpdk_helper
        dpdk_helper.find_net_devices = mock.Mock(
            side_effect=DpdkBindHelperException)

        with self.assertRaises(DpdkBindHelperException):
            dpdk_node._probe_netdevs()
Ejemplo n.º 6
0
    def test_probe_dpdk_drivers(self):
        mock_ssh_helper = mock.Mock()
        mock_ssh_helper.execute.return_value = 0, '', ''

        interfaces = [
            {
                'name': 'name1',
                'virtual-interface': {
                    'local_mac': 404,
                    'vpci': 'pci10',
                }
            },
            {
                'name': 'name2',
                'virtual-interface': {
                    'local_mac': 404,
                    'vpci': 'pci2',
                }
            },
            {
                'name': 'name3',
                'virtual-interface': {
                    'local_mac': 404,
                    'vpci': 'some-pci1',
                }
            },
        ]

        dpdk_node = DpdkNode(NAME, interfaces, mock_ssh_helper)
        dpdk_helper = dpdk_node.dpdk_helper

        dpdk_helper.probe_real_kernel_drivers = mock.Mock()
        dpdk_helper.real_kernel_interface_driver_map = {
            'pci1': 'driver1',
            'pci2': 'driver2',
            'pci3': 'driver3',
            'pci4': 'driver1',
            'pci6': 'driver3',
        }

        dpdk_node._probe_dpdk_drivers()
        self.assertNotIn('driver', interfaces[0]['virtual-interface'])
        self.assertEqual(interfaces[1]['virtual-interface']['driver'],
                         'driver2')
        self.assertEqual(interfaces[2]['virtual-interface']['driver'],
                         'driver1')
Ejemplo n.º 7
0
    def test_probe_netdevs(self):
        mock_ssh_helper = mock.Mock()
        mock_ssh_helper.execute.return_value = 0, '', ''

        expected = {'key1': 500, 'key2': 'hello world'}
        update = {'key1': 1000, 'key3': []}

        dpdk_node = DpdkNode(NAME, self.INTERFACES, mock_ssh_helper)
        dpdk_helper = dpdk_node.dpdk_helper
        dpdk_helper.find_net_devices = mock.Mock(
            side_effect=[expected, update])

        self.assertDictEqual(dpdk_node.netdevs, {})
        dpdk_node._probe_netdevs()
        self.assertDictEqual(dpdk_node.netdevs, expected)

        expected = {'key1': 1000, 'key2': 'hello world', 'key3': []}
        dpdk_node._probe_netdevs()
        self.assertDictEqual(dpdk_node.netdevs, expected)