def test_rename_nio(hypervisor): nio = NIO_Null(hypervisor) assert nio.name.startswith("nio_null") nio.rename("test") assert nio.name == "test" nio.delete()
def test_set_bandwidth(hypervisor): nio = NIO_Null(hypervisor) assert nio.bandwidth == None # no constraint by default nio.set_bandwidth(1000) # bandwidth = 1000 Kb/s assert nio.bandwidth == 1000 nio.delete()
def test_add_remove_nio(atm_bridge): nio = NIO_Null(atm_bridge.hypervisor) atm_bridge.add_nio(nio, 0) # add NIO on port 0 assert atm_bridge.nios atm_bridge.remove_nio(0) # remove NIO from port 0 nio.delete()
def test_add_nio_already_allocated_port(atm_bridge): nio = NIO_Null(atm_bridge.hypervisor) atm_bridge.add_nio(nio, 0) # add NIO on port 0 with pytest.raises(DynamipsError): atm_bridge.add_nio(nio, 0) nio.delete()
def test_add_remove_nio(ethsw): nio = NIO_Null(ethsw.hypervisor) ethsw.add_nio(nio, 0) # add NIO on port 0 assert ethsw.nios ethsw.remove_nio(0) # remove NIO from port 0 nio.delete()
def test_add_nio_already_allocated_port(ethsw): nio = NIO_Null(ethsw.hypervisor) ethsw.add_nio(nio, 0) # add NIO on port 0 with pytest.raises(DynamipsError): ethsw.add_nio(nio, 0) nio.delete()
def test_add_remove_nio(hub): nio = NIO_Null(hub.hypervisor) hub.add_nio(nio, 0) # add NIO to port 0 assert hub.mapping[0] == nio hub.remove_nio(0) # remove NIO from port 0 nio.delete()
def test_add_remove_nio(bridge): nio = NIO_Null(bridge.hypervisor) bridge.add_nio(nio) assert bridge.nios bridge.remove_nio(nio) nio.delete()
def test_set_qinq_port(ethsw): nio = NIO_Null(ethsw.hypervisor) ethsw.add_nio(nio, 0) # add NIO on port 0 ethsw.set_qinq_port(0, 100) # set port 0 as QinQ trunk with outer VLAN 100 assert ethsw.mapping[0] == ("qinq", 100) ethsw.remove_nio(0) # remove NIO from port 0 nio.delete()
def test_setup_filter(hypervisor): nio = NIO_Null(hypervisor) nio.bind_filter("in", "freq_drop") nio.setup_filter("in", "5") # drop every 5th packet assert nio.input_filter == ("freq_drop", "5") nio.unbind_filter("in") nio.delete()
def test_set_access_port(ethsw): nio = NIO_Null(ethsw.hypervisor) ethsw.add_nio(nio, 0) # add NIO on port 0 ethsw.set_access_port(0, 10) # set port 0 as access in VLAN 10 assert ethsw.mapping[0] == ("access", 10) ethsw.remove_nio(0) # remove NIO from port 0 nio.delete()
def test_slot_add_nio_to_wrong_port(router_c7200): adapter = PA_FE_TX() router_c7200.slot_add_binding(1, adapter) nio = NIO_Null(router_c7200.hypervisor) with pytest.raises(DynamipsError): router_c7200.slot_add_nio_binding(1, 1, nio) # slot 1/1 nio.delete()
def test_set_dot1q_port(ethsw): nio = NIO_Null(ethsw.hypervisor) ethsw.add_nio(nio, 0) # add NIO on port 0 ethsw.set_dot1q_port(0, 1) # set port 0 as 802.1Q trunk with native VLAN 1 assert ethsw.mapping[0] == ("dot1q", 1) ethsw.remove_nio(0) # remove NIO from port 0 nio.delete()
def test_wic_add_remove_nio_binding_for_chassis_1760(hypervisor): router = C1700(hypervisor, "1760 chassis", chassis="1760") nio = NIO_Null(router.hypervisor) wic = WIC_2T() router.install_wic(1, wic) # install WIC in slot 1 router.slot_add_nio_binding(0, 32, nio) # slot 0/17 (slot 0, wic 1, port 0) router.slot_remove_nio_binding(0, 32) assert not router.get_slot_nio_bindings(slot_id=0) nio.delete() router.delete()
def test_slot_add_remove_nio_binding(router_c7200): adapter = PA_FE_TX() router_c7200.slot_add_binding(1, adapter) nio = NIO_Null(router_c7200.hypervisor) router_c7200.slot_add_nio_binding(1, 0, nio) # slot 1/0 assert router_c7200.get_slot_nio_bindings(slot_id=1) assert router_c7200.slots[1].ports[0] == nio router_c7200.slot_remove_nio_binding(1, 0) # slot 1/0 assert not router_c7200.get_slot_nio_bindings(slot_id=0) nio.delete()
def test_wic_add_remove_nio_binding(router_c1700): nio = NIO_Null(router_c1700.hypervisor) wic = WIC_2T() router_c1700.install_wic(0, wic) # install WIC in slot 0 router_c1700.slot_add_nio_binding(0, 17, nio) # slot 0/17 (slot 0, wic 0, port 1) assert router_c1700.slots[0].ports[17] == nio assert router_c1700.get_slot_nio_bindings(slot_id=0) router_c1700.slot_remove_nio_binding(0, 17) # slot 0/17 (slot 0, wic 0, port 1) assert not router_c1700.get_slot_nio_bindings(slot_id=0) assert not router_c1700.slots[0].ports[17] == nio nio.delete()
def test_wic_add_remove_nio_binding(router_c1700): nio = NIO_Null(router_c1700.hypervisor) wic = WIC_2T() router_c1700.install_wic(0, wic) # install WIC in slot 0 router_c1700.slot_add_nio_binding(0, 17, nio) # slot 0/17 (slot 0, wic 0, port 1) assert router_c1700.slots[0].ports[17] == nio assert router_c1700.get_slot_nio_bindings(slot_id=0) router_c1700.slot_remove_nio_binding( 0, 17) # slot 0/17 (slot 0, wic 0, port 1) assert not router_c1700.get_slot_nio_bindings(slot_id=0) assert not router_c1700.slots[0].ports[17] == nio nio.delete()
def test_bridge(atm_bridge): nio1 = NIO_Null(atm_bridge.hypervisor) atm_bridge.add_nio(nio1, 0) # add NIO on port 0 (Ethernet NIO) nio2 = NIO_Null(atm_bridge.hypervisor) atm_bridge.add_nio(nio1, 1) # add NIO on port 1 (ATM NIO) atm_bridge.configure(0, 1, 10, 10) # configure Ethernet port 0 -> ATM port 1 with VC 10:10 assert atm_bridge.mapping[0] == (1, 10, 10) atm_bridge.unconfigure() atm_bridge.remove_nio(0) atm_bridge.remove_nio(1) nio1.delete() nio2.delete()
def test_pvc(atmsw): nio1 = NIO_Null(atmsw.hypervisor) atmsw.add_nio(nio1, 0) # add NIO on port 0 nio2 = NIO_Null(atmsw.hypervisor) atmsw.add_nio(nio1, 1) # add NIO on port 1 atmsw.map_pvc(0, 10, 10, 1, 20, 20) # port 0 VC 10:10 to port 1 VP 20:20 (unidirectional) atmsw.map_pvc(1, 20, 20, 0, 10, 10) # port 1 VC 20:20 to port 0 VC 10:10 (unidirectional) assert atmsw.mapping[(0, 10, 10)] == (1, 20, 20) assert atmsw.mapping[(1, 20, 20)] == (0, 10, 10) atmsw.unmap_pvc(0, 10, 10, 1, 20, 20) # port 0 VC 10:10 to port 1 VP 20:20 (unidirectional) atmsw.unmap_pvc(1, 20, 20, 0, 10, 10) # port 1 VC 20:20 to port 0 VC 10:10 (unidirectional) atmsw.remove_nio(0) atmsw.remove_nio(1) nio1.delete() nio2.delete()
def test_vc(frsw): nio1 = NIO_Null(frsw.hypervisor) frsw.add_nio(nio1, 0) # add NIO on port 0 nio2 = NIO_Null(frsw.hypervisor) frsw.add_nio(nio1, 1) # add NIO on port 1 frsw.map_vc(0, 10, 1, 20) # port 0 DLCI 10 to port 1 DLCI 20 (unidirectional) frsw.map_vc(1, 20, 0, 10) # port 1 DLCI 20 to port 0 DLCI 10 (unidirectional) assert frsw.mapping[(0, 10)] == (1, 20) assert frsw.mapping[(1, 20)] == (0, 10) frsw.unmap_vc(0, 10, 1, 20) # port 0 DLCI 10 to port 1 DLCI 20 (unidirectional) frsw.unmap_vc(1, 20, 0, 10) # port 1 DLCI 20 to port 0 DLCI 10 (unidirectional) frsw.remove_nio(0) frsw.remove_nio(1) nio1.delete() nio2.delete()
def test_bind_unknown_filter(hypervisor): nio = NIO_Null(hypervisor) with pytest.raises(DynamipsError): nio.bind_filter("both", "my_filter") nio.delete()
def test_nio_null(hypervisor): nio = NIO_Null(hypervisor) assert nio.list() nio.delete()
def test_get_stats(hypervisor): nio = NIO_Null(hypervisor) assert nio.get_stats() == "0 0 0 0" # nothing has been transmitted or received nio.delete()
def test_reset_stats(hypervisor): nio = NIO_Null(hypervisor) nio.reset_stats() nio.delete()
def test_unbind_with_no_filter_applied(hypervisor): nio = NIO_Null(hypervisor) with pytest.raises(DynamipsError): nio.unbind_filter("out") nio.delete()
def test_bind_unbind_filter(hypervisor): nio = NIO_Null(hypervisor) nio.bind_filter("both", "freq_drop") assert nio.input_filter == ("freq_drop", None) assert nio.output_filter == ("freq_drop", None) nio.unbind_filter("both") nio.bind_filter("in", "capture") assert nio.input_filter == ("capture", None) nio.unbind_filter("in") nio.delete()
def test_debug_nio(hypervisor): nio = NIO_Null(hypervisor) nio.debug(1) nio.debug(0) nio.delete()
def test_get_stats(hypervisor): nio = NIO_Null(hypervisor) assert nio.get_stats( ) == "0 0 0 0" # nothing has been transmitted or received nio.delete()