def test_lag_type_interface(self, match_engine): """ Scenario: Test the flow fetching objs related to LAG_TYPE iface """ params = {Interface.ARG_NAME: "PortChannel1234", "namespace": ""} m_intf = Interface(match_engine) returned = m_intf.execute(params) expect = create_template_dict( dbs=["CONFIG_DB", "APPL_DB", "ASIC_DB", "STATE_DB"]) expect["CONFIG_DB"]["keys"].extend([ "PORTCHANNEL_INTERFACE|PortChannel1234", "PORTCHANNEL_INTERFACE|PortChannel1234|7.7.7.1/24" ]) expect["APPL_DB"]["keys"].extend([ "INTF_TABLE:PortChannel1234", "INTF_TABLE:PortChannel1234:7.7.7.1/24" ]) expect["STATE_DB"]["keys"].extend([ "INTERFACE_TABLE|PortChannel1234", "INTERFACE_TABLE|PortChannel1234|7.7.7.1/24" ]) expect["ASIC_DB"]["keys"].append( "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x60000000005ec") ddiff = DeepDiff(sort_lists(returned), sort_lists(expect), ignore_order=True) assert not ddiff, ddiff
def test_all_args(self, match_engine): """ Scenario: Verify Whether the get_all_args method is working as expected """ params = {} m_port = Interface(match_engine) returned = m_port.get_all_args("") expect = ["Ethernet16", "Vlan10", "PortChannel1111", "PortChannel1234", "Eth0.1", "Loopback0", "Eth4.1"] ddiff = DeepDiff(expect, returned, ignore_order=True) assert not ddiff, ddiff
def test_loopback_interface(self, match_engine): """ Scenario: Test the flow fetching objs related to loopback iface """ params = {Interface.ARG_NAME: "Loopback0", "namespace": ""} m_intf = Interface(match_engine) returned = m_intf.execute(params) expect = create_template_dict(dbs=["CONFIG_DB", "APPL_DB", "ASIC_DB", "STATE_DB"]) expect["CONFIG_DB"]["keys"].extend(["LOOPBACK_INTERFACE|Loopback0", "LOOPBACK_INTERFACE|Loopback0|10.1.0.1/32"]) expect["APPL_DB"]["keys"].extend(["INTF_TABLE:Loopback0", "INTF_TABLE:Loopback0:10.1.0.1/32"]) expect["STATE_DB"]["keys"].extend(["INTERFACE_TABLE|Loopback0", "INTERFACE_TABLE|Loopback0|10.1.0.1/32"]) ddiff = DeepDiff(sort_lists(returned), sort_lists(expect), ignore_order=True) assert not ddiff, ddiff
def test_vlan_type_interface(self, match_engine): """ Scenario: Test the flow fetching objs related to VLAN_TYPE interfac """ params = {Interface.ARG_NAME: "Vlan10", "namespace": ""} m_intf = Interface(match_engine) returned = m_intf.execute(params) expect = create_template_dict(dbs=["CONFIG_DB", "APPL_DB", "ASIC_DB", "STATE_DB"]) expect["CONFIG_DB"]["keys"].extend(["VLAN_INTERFACE|Vlan10", "VLAN_INTERFACE|Vlan10|2.2.2.1/24"]) expect["APPL_DB"]["keys"].extend(["INTF_TABLE:Vlan10", "INTF_TABLE:Vlan10:2.2.2.1/24"]) expect["STATE_DB"]["keys"].extend(["INTERFACE_TABLE|Vlan10", "INTERFACE_TABLE|Vlan10|2.2.2.1/24"]) expect["ASIC_DB"]["keys"].append("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000c7b") ddiff = DeepDiff(sort_lists(returned), sort_lists(expect), ignore_order=True) assert not ddiff, ddiff
def test_subintf_with_invalid_vlan(self, match_engine): """ Scenario: Test the flow fetching objs related to a subintf with invalid vlan """ params = {Interface.ARG_NAME: "Eth4.1", "namespace": ""} m_intf = Interface(match_engine) returned = m_intf.execute(params) expect = create_template_dict(dbs=["CONFIG_DB", "APPL_DB", "ASIC_DB", "STATE_DB"]) expect["CONFIG_DB"]["keys"].extend(["VLAN_SUB_INTERFACE|Eth4.1"]) expect["APPL_DB"]["keys"].extend(["INTF_TABLE:Eth4.1"]) expect["STATE_DB"]["tables_not_found"].extend(["INTERFACE_TABLE"]) expect["ASIC_DB"]["tables_not_found"].extend(["ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE"]) ddiff = DeepDiff(sort_lists(returned), sort_lists(expect), ignore_order=True) assert not ddiff, ddiff
def test_no_interface(self, match_engine): """ Scenario: Test the flow fetching objs related to an interface which is not present """ params = {Interface.ARG_NAME: "Ethernet160", "namespace": ""} m_intf = Interface(match_engine) returned = m_intf.execute(params) expect = create_template_dict(dbs=["CONFIG_DB", "APPL_DB", "ASIC_DB", "STATE_DB"]) expect["CONFIG_DB"]["tables_not_found"].extend(["INTERFACE"]) expect["APPL_DB"]["tables_not_found"].extend(["INTF_TABLE"]) expect["STATE_DB"]["tables_not_found"].extend(["INTERFACE_TABLE"]) expect["ASIC_DB"]["tables_not_found"].append("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE") ddiff = DeepDiff(sort_lists(returned), sort_lists(expect), ignore_order=True) assert not ddiff, ddiff