def test_bond_class(): bond_obj = Bond(context_wrap(BONDINFO_1, CONTEXT_PATH)) assert bond_obj.file_name == 'bond0' assert not bond_obj.partner_mac_address assert bond_obj.bond_mode == '0' assert bond_obj.slave_interface == ['eno1', 'eno2'] bond_obj = Bond(context_wrap(BONDINFO_MODE_4, CONTEXT_PATH)) assert bond_obj.bond_mode == '4' assert bond_obj.partner_mac_address == "00:00:00:00:00:00" assert bond_obj.aggregator_id == ['3', '3', '2'] assert bond_obj.xmit_hash_policy == "layer2" bond_obj = Bond(context_wrap(BONDINFO_CORRUPT, CONTEXT_PATH)) assert not bond_obj.bond_mode assert bond_obj.slave_interface == [] assert not bond_obj.xmit_hash_policy with pytest.raises(ParseException) as exc: bond_obj = Bond(context_wrap(BONDINFO_UNKNOWN_BOND_MODE, CONTEXT_PATH)) assert not bond_obj.bond_mode assert 'Unrecognised bonding mode' in str(exc) bond_obj = Bond(context_wrap(BONDINFO_MODE_2, CONTEXT_PATH)) assert bond_obj.xmit_hash_policy == "layer2+3"
def test_bond_class(): bond_obj = Bond(context_wrap(BONDINFO_1, CONTEXT_PATH)) assert bond_obj.file_name == 'bond0' assert not bond_obj.partner_mac_address assert bond_obj.bond_mode == '0' assert bond_obj.slave_interface == ['eno1', 'eno2'] bond_obj = Bond(context_wrap(BONDINFO_MODE_4, CONTEXT_PATH)) assert bond_obj.bond_mode == '4' assert bond_obj.partner_mac_address == "00:00:00:00:00:00" assert bond_obj.aggregator_id == ['3', '3', '2'] assert bond_obj.xmit_hash_policy == "layer2" assert bond_obj.active_slave is None bond_obj = Bond(context_wrap(BONDINFO_CORRUPT, CONTEXT_PATH)) assert bond_obj.bond_mode is None assert bond_obj.slave_interface == [] assert not bond_obj.xmit_hash_policy bond_obj = Bond(context_wrap(BONDINFO_MODE_2, CONTEXT_PATH)) assert bond_obj.xmit_hash_policy == "layer2+3" bond_obj = Bond(context_wrap(BONDINFO_MODE_5, CONTEXT_PATH)) assert bond_obj.bond_mode == '1' assert bond_obj.active_slave == "enp17s0f0" bond_obj_2 = Bond(context_wrap(BONDINFO_MODE_6, CONTEXT_PATH)) assert bond_obj_2.bond_mode == '1' assert bond_obj_2.active_slave is None bond_obj_3 = Bond(context_wrap(BONDINFO_1, CONTEXT_PATH)) assert bond_obj_3.file_name == 'bond0' assert bond_obj_3.slave_interface == ['eno1', 'eno2'] assert bond_obj_3.slave_duplex == ['full', 'full'] assert bond_obj_3.slave_speed == ['1000 Mbps', '1000 Mbps'] assert bond_obj_3.slave_link_failure_count == ['0', '0'] assert bond_obj_3.mii_status == ['up', 'up', 'up'] assert bond_obj_3.arp_polling_interval is None assert bond_obj_3.arp_ip_target is None bond_obj_4 = Bond(context_wrap(BONDINFO_MODE_7, CONTEXT_PATH)) assert bond_obj_4.file_name == 'bond0' assert bond_obj_4.arp_polling_interval == "1000" assert bond_obj_4.arp_ip_target == "10.152.1.1" assert bond_obj_4.primary_slave == 'em3 (primary_reselect failure)' with pytest.raises(ParseException) as exc: bond_obj = Bond(context_wrap(BONDINFO_UNKNOWN_BOND_MODE, CONTEXT_PATH)) assert not bond_obj.bond_mode assert 'Unrecognised bonding mode' in str(exc)
def test_bond_class_different_file_name(): bond_obj = Bond(context_wrap(BONDINFO_1, CONTEXT_PATH_1)) assert bond_obj.file_name == 'test0' assert not bond_obj.partner_mac_address assert bond_obj.bond_mode == '0' assert bond_obj.slave_interface == ['eno1', 'eno2'] assert bond_obj.up_delay == '0' assert bond_obj.down_delay == '0' assert bond_obj.data['eno1']['speed'] == '1000 Mbps' assert bond_obj.data['eno1']['mii_status'] == 'up' assert bond_obj.data['eno2']['mii_status'] == 'up'
def test_netstat_doc_examples(): env = { 'bond_info': Bond(context_wrap(BONDINFO_MODE_4)), } failed, total = doctest.testmod(bond, globs=env) assert failed == 0