diff options
| author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-03-02 09:30:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-02 09:30:06 +0200 |
| commit | c103ac43dea8087e33e62dec69cee2d79e362ed5 (patch) | |
| tree | 82dc7576b9642d50ae050803cbf274fc8229acf7 /tests/topotests/lib/pim.py | |
| parent | 3ca7090fdcdda8dc8ab0d96ed1a2c7a0a700aaf3 (diff) | |
| parent | 5980ad0ae0352ba3865ee17cd9bf97bc65e35474 (diff) | |
Merge pull request #8172 from donaldsharp/more_pytest_bgp
More pytest stuff
Diffstat (limited to 'tests/topotests/lib/pim.py')
| -rw-r--r-- | tests/topotests/lib/pim.py | 106 |
1 files changed, 64 insertions, 42 deletions
diff --git a/tests/topotests/lib/pim.py b/tests/topotests/lib/pim.py index 294f60bf68..d07b58a774 100644 --- a/tests/topotests/lib/pim.py +++ b/tests/topotests/lib/pim.py @@ -1564,26 +1564,30 @@ def verify_pim_interface(tgen, topo, dut, interface=None, interface_ip=None): logger.info("[DUT: %s]: Verifying PIM interface status:", dut) rnode = tgen.routers()[dut] - show_ip_pim_interface_json = rnode.\ - vtysh_cmd("show ip pim interface json", isjson=True) + show_ip_pim_interface_json = rnode.vtysh_cmd( + "show ip pim interface json", isjson=True + ) - logger.info("show_ip_pim_interface_json: \n %s", - show_ip_pim_interface_json) + logger.info("show_ip_pim_interface_json: \n %s", show_ip_pim_interface_json) if interface_ip: if interface in show_ip_pim_interface_json: pim_intf_json = show_ip_pim_interface_json[interface] if pim_intf_json["address"] != interface_ip: - errormsg = ("[DUT %s]: PIM interface " - "ip is not correct " - "[FAILED]!! Expected : %s, Found : %s" - %(dut, pim_intf_json["address"],interface_ip)) + errormsg = ( + "[DUT %s]: PIM interface " + "ip is not correct " + "[FAILED]!! Expected : %s, Found : %s" + % (dut, pim_intf_json["address"], interface_ip) + ) return errormsg else: - logger.info("[DUT %s]: PIM interface " - "ip is correct " - "[Passed]!! Expected : %s, Found : %s" - %(dut, pim_intf_json["address"],interface_ip)) + logger.info( + "[DUT %s]: PIM interface " + "ip is correct " + "[Passed]!! Expected : %s, Found : %s" + % (dut, pim_intf_json["address"], interface_ip) + ) return True else: for destLink, data in topo["routers"][dut]["links"].items(): @@ -1595,24 +1599,36 @@ def verify_pim_interface(tgen, topo, dut, interface=None, interface_ip=None): pim_intf_ip = data["ipv4"].split("/")[0] if pim_interface in show_ip_pim_interface_json: - pim_intf_json = show_ip_pim_interface_json\ - [pim_interface] + pim_intf_json = show_ip_pim_interface_json[pim_interface] # Verifying PIM interface - if pim_intf_json["address"] != pim_intf_ip and \ - pim_intf_json["state"] != "up": - errormsg = ("[DUT %s]: PIM interface: %s " - "PIM interface ip: %s, status check " - "[FAILED]!! Expected : %s, Found : %s" - %(dut, pim_interface, pim_intf_ip, - pim_interface, pim_intf_json["state"])) + if ( + pim_intf_json["address"] != pim_intf_ip + and pim_intf_json["state"] != "up" + ): + errormsg = ( + "[DUT %s]: PIM interface: %s " + "PIM interface ip: %s, status check " + "[FAILED]!! Expected : %s, Found : %s" + % ( + dut, + pim_interface, + pim_intf_ip, + pim_interface, + pim_intf_json["state"], + ) + ) return errormsg - logger.info("[DUT %s]: PIM interface: %s, " - "interface ip: %s, status: %s" - " [PASSED]!!", - dut, pim_interface, pim_intf_ip, - pim_intf_json["state"]) + logger.info( + "[DUT %s]: PIM interface: %s, " + "interface ip: %s, status: %s" + " [PASSED]!!", + dut, + pim_interface, + pim_intf_ip, + pim_intf_json["state"], + ) logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name)) return True @@ -3420,30 +3436,36 @@ def verify_igmp_interface(tgen, topo, dut, igmp_iface, interface_ip): if router != dut: continue - logger.info("[DUT: %s]: Verifying PIM interface status:", - dut) + logger.info("[DUT: %s]: Verifying PIM interface status:", dut) rnode = tgen.routers()[dut] - show_ip_igmp_interface_json = \ - run_frr_cmd(rnode, "show ip igmp interface json", isjson=True) + show_ip_igmp_interface_json = run_frr_cmd( + rnode, "show ip igmp interface json", isjson=True + ) - if igmp_iface in show_ip_igmp_interface_json: + if igmp_iface in show_ip_igmp_interface_json: igmp_intf_json = show_ip_igmp_interface_json[igmp_iface] # Verifying igmp interface - if igmp_intf_json["address"] != interface_ip: - errormsg = ("[DUT %s]: igmp interface ip is not correct " - "[FAILED]!! Expected : %s, Found : %s" - %(dut, igmp_intf_json["address"], interface_ip)) + if igmp_intf_json["address"] != interface_ip: + errormsg = ( + "[DUT %s]: igmp interface ip is not correct " + "[FAILED]!! Expected : %s, Found : %s" + % (dut, igmp_intf_json["address"], interface_ip) + ) return errormsg - logger.info("[DUT %s]: igmp interface: %s, " - "interface ip: %s" - " [PASSED]!!", - dut, igmp_iface, interface_ip) + logger.info( + "[DUT %s]: igmp interface: %s, " "interface ip: %s" " [PASSED]!!", + dut, + igmp_iface, + interface_ip, + ) else: - errormsg = ("[DUT %s]: igmp interface: %s " - "igmp interface ip: %s, is not present " - %(dut, igmp_iface, interface_ip)) + errormsg = ( + "[DUT %s]: igmp interface: %s " + "igmp interface ip: %s, is not present " + % (dut, igmp_iface, interface_ip) + ) return errormsg logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name)) |
