def test_remove_bond_reattached_to_another_network(self, net_info): bonds = {BOND0: {'remove': True}} nets = {NET1: {'nic': NICS[0]}, NET0: {'bonding': BOND0}} with pytest.raises(ne.ConfigNetworkError) as e: valid = validator.Validator(nets, bonds, net_info) valid.validate_bond(BOND0) assert e.value.errCode == ne.ERR_USED_BOND
def test_remove_bond_attached_to_network_that_was_not_removed( self, net_info): bonds = {BOND0: {'remove': True}} with pytest.raises(ne.ConfigNetworkError) as e: valid = validator.Validator({}, bonds, net_info) valid.validate_bond(BOND0) assert e.value.errCode == ne.ERR_USED_BOND
def test_add_bond_with_slaves_fail(self, slaves, net_info): bonds = {BOND2: {'switch': 'ovs'}} if slaves: bonds[BOND2]['nics'] = slaves with pytest.raises(ne.ConfigNetworkError): valid = validator.Validator({}, bonds, net_info) valid.validate_bond(BOND2)
def test_nic_used_by_new_bond_only(self, net_info): bonds_to_add = {'bond1': {'nics': ['eth3', 'eth4']}} valid = validator.Validator({}, bonds_to_add, net_info) valid.validate_nic_usage()
def test_nic_used_by_new_network_only(self, net_info): nets_to_add = {'net2': {'nic': 'eth3'}} valid = validator.Validator(nets_to_add, {}, net_info) valid.validate_nic_usage()
def test_vlanned_nic_used_by_new_bond(self, net_info): bonds_to_add = {'bond1': {'nics': ['eth10', 'eth11']}} with pytest.raises(ne.ConfigNetworkError) as cne_context: valid = validator.Validator({}, bonds_to_add, net_info) valid.validate_nic_usage() assert cne_context.value.errCode == ne.ERR_USED_NIC
def test_nic_used_by_new_network_and_current_bond(self, net_info): nets_to_add = {'net1': {'nic': 'eth1'}} with pytest.raises(ne.ConfigNetworkError) as cne_context: valid = validator.Validator(nets_to_add, {}, net_info) valid.validate_nic_usage() assert cne_context.value.errCode == ne.ERR_USED_NIC
def test_network_with_invalid_vlan_id(self, vlan_id, net_info): nets = {NET2: {'vlan': vlan_id, 'bridged': True, 'nic': NICS[0]}} with pytest.raises(ne.ConfigNetworkError) as cne_context: valid = validator.Validator(nets, {}, net_info) valid.validate_net(NET2) assert cne_context.value.errCode == ne.ERR_BAD_VLAN
def test_add_network_with_non_existing_bond(self, net_info): nets = {NET2: {'bonding': FAKE_BOND, 'switch': 'ovs'}} with pytest.raises(ne.ConfigNetworkError) as e: valid = validator.Validator(nets, {}, net_info) valid.validate_net(NET2) assert e.value.errCode == ne.ERR_BAD_BONDING
def test_remove_bond_attached_to_network_that_will_use_nic(self, net_info): bonds = {BOND0: {'remove': True}} nets = {NET1: {'nic': NICS[0]}} valid = validator.Validator(nets, bonds, net_info) valid.validate_bond(BOND0)
def test_remove_bond_attached_to_network_that_was_removed(self, net_info): bonds = {BOND0: {'remove': True}} nets = {NET1: {'remove': True}} valid = validator.Validator(nets, bonds, net_info) valid.validate_bond(BOND0)
def test_remove_bond_not_attached_to_a_network(self, net_info): bonds = {BOND1: {'remove': True}} valid = validator.Validator({}, bonds, net_info) valid.validate_bond(BOND1)
def test_add_bond_with_slaves_pass(self, slaves, net_info): bonds = {BOND2: {'switch': 'ovs', 'nics': slaves}} valid = validator.Validator({}, bonds, net_info) valid.validate_bond(BOND2)
def test_add_network_with_running_bond(self, net_info): nets = {NET2: {'bonding': BOND1, 'switch': 'ovs'}} valid = validator.Validator(nets, {}, net_info) valid.validate_net(NET2)
def test_adding_a_new_single_untagged_net(self, net_info): nets = {NET2: {'nic': NICS[0], 'switch': 'ovs'}} valid = validator.Validator(nets, {}, net_info) valid.validate_net(NET2)
def test_remove_missing_net_fails(self, net_info): nets = {NET2: {'remove': True}} with pytest.raises(ne.ConfigNetworkError) as cne: valid = validator.Validator(nets, {}, net_info) valid.validate_net(NET2) assert cne.value.errCode == ne.ERR_BAD_BRIDGE
def test_edit_single_untagged_net_nic(self, net_info): nets = {NET1: {'nic': NICS[0], 'switch': 'ovs'}} valid = validator.Validator(nets, {}, net_info) valid.validate_net(NET1)
def test_remove_broken_net_succeeds(self, net_info): nets = {NET_BROKEN: {'remove': True}} valid = validator.Validator(nets, {}, net_info) valid.validate_net(NET_BROKEN)
def test_add_network_with_to_be_added_bond(self, net_info): nets = {NET2: {'bonding': BOND2, 'switch': 'ovs'}} bonds = {BOND2: {'nics': NICS[:1], 'switch': 'ovs'}} valid = validator.Validator(nets, bonds, net_info) valid.validate_net(NET2)
def test_add_bond_with_dpdk(self, net_info): bonds = {BOND2: {'nics': [NICS[0], DPDK_NIC0], 'switch': 'ovs'}} with pytest.raises(ne.ConfigNetworkError): valid = validator.Validator({}, bonds, net_info) valid.validate_bond(BOND2)