def test_resource_config_not_dict(self): nic_data = {'resources': {'foo': {'properties': {'config': None}}}} errors = validation.check_nic_configs("controller.yaml", nic_data) self.assertEqual(len(errors), 1) self.assertEqual( "The 'config' property of 'foo' must be" " a dictionary.", errors[0])
def test_one_bond_multiple_interfaces(self): nic_data = self.nic_data([{ 'type': 'ovs_bridge', 'name': 'storage', 'members': [ { 'type': 'ovs_bond', 'name': 'bond0', 'members': [ { 'type': 'interface', 'name': 'eth2' }, { 'type': 'interface', 'name': 'eth3' }, ] }, { 'type': 'interface', 'name': 'eth0' }, { 'type': 'interface', 'name': 'eth1' }, ], }]) errors = validation.check_nic_configs("controller.yaml", nic_data) self.assertEqual([], errors)
def test_one_interface_without_bond(self): nic_data = self.nic_data([{ 'type': 'ovs_bridge', 'name': 'storage', 'members': [ { 'type': 'interface', 'name': 'eth0' }, ], }]) errors = validation.check_nic_configs("controller.yaml", nic_data) self.assertEqual([], errors)
def test_more_than_one_bond(self): nic_data = self.nic_data([{ 'type': 'ovs_bridge', 'name': 'storage', 'members': [ { 'type': 'ovs_bond', 'name': 'bond0', 'members': [ { 'type': 'interface', 'name': 'eth0' }, { 'type': 'interface', 'name': 'eth1' }, ] }, { 'type': 'ovs_bond', 'name': 'bond1', 'members': [ { 'type': 'interface', 'name': 'eth2' }, { 'type': 'interface', 'name': 'eth3' }, ] }, ], }]) errors = validation.check_nic_configs("controller.yaml", nic_data) self.assertEqual(len(errors), 1) self.assertIn( 'Invalid bonding: There are >= 2 bonds for bridge ' 'storage', errors[0])
def test_multiple_interfaces_without_bond(self): nic_data = self.nic_data([{ 'type': 'ovs_bridge', 'name': 'storage', 'members': [ { 'type': 'interface', 'name': 'eth0' }, { 'type': 'interface', 'name': 'eth1' }, ], }]) errors = validation.check_nic_configs("controller.yaml", nic_data) self.assertEqual(len(errors), 1) self.assertIn( 'Invalid interface: When not using a bond, there can' ' only be 1 interface for bridge storage', errors[0])
def test_network_config_not_list(self): nic_data = self.nic_data(None) errors = validation.check_nic_configs("controller.yaml", nic_data) self.assertEqual(len(errors), 1) self.assertIn("'foo' must be a list", errors[0])
def test_resource_not_dict(self): nic_data = {'resources': {'foo': None}} errors = validation.check_nic_configs("controller.yaml", nic_data) self.assertEqual(len(errors), 1) self.assertEqual("'foo' is not a valid resource.", errors[0])
def _test_resources_invalid(self, nic_data): errors = validation.check_nic_configs("controller.yaml", nic_data) self.assertEqual(len(errors), 1) self.assertEqual( "The nic_data must contain the 'resources' key and it" " must be a dictionary.", errors[0])
def test_non_dict(self): errors = validation.check_nic_configs("controller.yaml", None) self.assertEqual(len(errors), 1) self.assertEqual('The nic_data parameter must be a dictionary.', errors[0])