Ejemplo n.º 1
0
class FCOEInterfaceTestCase(unittest.TestCase):
    """Test DBus interface of the FCoE module."""
    def setUp(self):
        """Set up the module."""
        self.fcoe_module = FCOEModule()
        self.fcoe_interface = FCOEInterface(self.fcoe_module)

    def get_nics_test(self):
        """Test the get nics method."""
        self.assertEqual(self.fcoe_interface.GetNics(), list())

    def get_dracut_arguments(self):
        """Test the get dracut arguments method."""
        self.assertEqual(self.fcoe_interface.GetDracutArguments("eth0"),
                         list())

    @patch('pyanaconda.dbus.DBus.publish_object')
    def discover_with_task_test(self, publisher):
        """Test the discover task."""
        task_path = self.fcoe_interface.DiscoverWithTask(
            "eth0",  # nic
            False,  # dcb
            True  # auto_vlan
        )

        publisher.assert_called_once()
        object_path, obj = publisher.call_args[0]

        self.assertEqual(task_path, object_path)
        self.assertIsInstance(obj, TaskInterface)

        self.assertIsInstance(obj.implementation, FCOEDiscoverTask)
        self.assertEqual(obj.implementation._nic, "eth0")
        self.assertEqual(obj.implementation._dcb, False)
        self.assertEqual(obj.implementation._auto_vlan, True)

    @patch('pyanaconda.modules.storage.fcoe.fcoe.fcoe')
    def reload_module_test(self, fcoe):
        """Test ReloadModule."""
        self.fcoe_interface.ReloadModule()
        fcoe.startup.assert_called_once_with()

    @patch('pyanaconda.modules.storage.fcoe.fcoe.fcoe')
    def write_configuration_test(self, fcoe):
        """Test WriteConfiguration."""

        with tempfile.TemporaryDirectory() as root:
            self.fcoe_interface.WriteConfiguration(root)
            fcoe.write.assert_called_once_with(root)
Ejemplo n.º 2
0
class FCOEInterfaceTestCase(unittest.TestCase):
    """Test DBus interface of the FCoE module."""
    def setUp(self):
        """Set up the module."""
        self.fcoe_module = FCOEModule()
        self.fcoe_interface = FCOEInterface(self.fcoe_module)

    @patch("pyanaconda.modules.storage.fcoe.fcoe.has_fcoe", return_value=True)
    def is_supported_test(self, is_supported):
        self.assertEqual(self.fcoe_interface.IsSupported(), True)

    def get_nics_test(self):
        """Test the get nics method."""
        self.assertEqual(self.fcoe_interface.GetNics(), list())

    def get_dracut_arguments(self):
        """Test the get dracut arguments method."""
        self.assertEqual(self.fcoe_interface.GetDracutArguments("eth0"),
                         list())

    @patch_dbus_publish_object
    def discover_with_task_test(self, publisher):
        """Test the discover task."""
        task_path = self.fcoe_interface.DiscoverWithTask(
            "eth0",  # nic
            False,  # dcb
            True  # auto_vlan
        )

        obj = check_task_creation(self, task_path, publisher, FCOEDiscoverTask)

        self.assertEqual(obj.implementation._nic, "eth0")
        self.assertEqual(obj.implementation._dcb, False)
        self.assertEqual(obj.implementation._auto_vlan, True)

    @patch('pyanaconda.modules.storage.fcoe.fcoe.fcoe')
    def reload_module_test(self, fcoe):
        """Test ReloadModule."""
        self.fcoe_interface.ReloadModule()
        fcoe.startup.assert_called_once_with()

    @patch('pyanaconda.modules.storage.fcoe.fcoe.fcoe')
    def write_configuration_test(self, fcoe):
        """Test WriteConfiguration."""
        self.fcoe_interface.WriteConfiguration()
        fcoe.write.assert_called_once_with(conf.target.system_root)
Ejemplo n.º 3
0
class FCOEInterfaceTestCase(unittest.TestCase):
    """Test DBus interface of the FCoE module."""
    def setUp(self):
        """Set up the module."""
        self.fcoe_module = FCOEModule()
        self.fcoe_interface = FCOEInterface(self.fcoe_module)

    @patch("pyanaconda.modules.storage.fcoe.fcoe.has_fcoe", return_value=True)
    def is_supported_test(self, is_supported):
        self.assertEqual(self.fcoe_interface.IsSupported(), True)

    def get_nics_test(self):
        """Test the get nics method."""
        self.assertEqual(self.fcoe_interface.GetNics(), list())

    @patch('pyanaconda.modules.storage.fcoe.fcoe.fcoe')
    def get_dracut_arguments_test(self, fcoe):
        """Test the get dracut arguments method."""
        # no nics / added FCoE targets
        self.assertEqual(self.fcoe_interface.GetDracutArguments("eth0"),
                         list())

        nics_mock = Mock()
        nics_mock.nics = [
            ("eth0", True, True),
            ("eth1", True, True),
            ("eth1", True, False),
            ("eth2", False, True),
        ]
        nics_mock.added_nics = ["eth1", "eth2"]
        fcoe.return_value = nics_mock

        # FCoE added from EDD
        self.assertEqual(self.fcoe_interface.GetDracutArguments("eth0"),
                         ["fcoe=edd:dcb"])
        # FCoE added manually (ks or ui), dcb
        self.assertEqual(self.fcoe_interface.GetDracutArguments("eth1"),
                         ["fcoe=eth1:dcb"])
        # FCoE added manually (ks or ui), dcb, no autovlan
        self.assertEqual(self.fcoe_interface.GetDracutArguments("eth1"),
                         ["fcoe=eth1:dcb"])
        # FCoE added manually (ks or ui), no dcb
        self.assertEqual(self.fcoe_interface.GetDracutArguments("eth2"),
                         ["fcoe=eth2:nodcb"])

    @patch_dbus_publish_object
    def discover_with_task_test(self, publisher):
        """Test the discover task."""
        task_path = self.fcoe_interface.DiscoverWithTask(
            "eth0",  # nic
            False,  # dcb
            True  # auto_vlan
        )

        obj = check_task_creation(self, task_path, publisher, FCOEDiscoverTask)

        self.assertEqual(obj.implementation._nic, "eth0")
        self.assertEqual(obj.implementation._dcb, False)
        self.assertEqual(obj.implementation._auto_vlan, True)

    @patch('pyanaconda.modules.storage.fcoe.fcoe.fcoe')
    def write_configuration_test(self, fcoe):
        """Test WriteConfiguration."""
        self.fcoe_interface.WriteConfiguration()
        fcoe.write.assert_called_once_with(conf.target.system_root)