-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: fix invocation of send_bsr_packet.py script for python 2 #8179
Conversation
The pim test script send_bsr_packet.py appears to not work properly with scapy and python3. sudo /usr/bin/python ./send_bsr_packet.py "01005e00000d005056961165080045c000aa5af500000167372a46000001e000000d2400f5ce165b000001004600000101000018e1010100080800000100090a090a0096650001000909090a0096660001000708090a00966700010007070907009668000100070702070096690001000705020700966a0001000702020700966b0001000202020200966c0001000020e1010101010100000100050606050096000001000020e20101010101000001000909090900960000" enp39s0 --interval=1 --count=1 Traceback (most recent call last): File "/home/sharpd/frr6/tests/topotests/lib/./send_bsr_packet.py", line 23, in <module> from scapy.all import Raw, sendp File "/usr/local/lib/python3.9/dist-packages/scapy/all.py", line 16, in <module> from scapy.arch import * File "/usr/local/lib/python3.9/dist-packages/scapy/arch/__init__.py", line 27, in <module> from scapy.arch.bpf.core import get_if_raw_addr File "/usr/local/lib/python3.9/dist-packages/scapy/arch/bpf/core.py", line 30, in <module> LIBC = cdll.LoadLibrary(find_library("libc")) File "/usr/lib/python3.9/ctypes/util.py", line 341, in find_library _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name)) File "/usr/lib/python3.9/ctypes/util.py", line 147, in _findLib_gcc if not _is_elf(file): File "/usr/lib/python3.9/ctypes/util.py", line 99, in _is_elf with open(filename, 'br') as thefile: Limit running to python2 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution to FRR!
Click for style suggestions
To apply these suggestions:
curl -s https://gist.githubusercontent.com/polychaeta/8dec74e9ee7d87c4e45991fba5e33bc7/raw/92ee456eff52902b1fbeff64090f386e89155626/cr_8179_1614647807.diff | git apply
diff --git a/tests/topotests/lib/pim.py b/tests/topotests/lib/pim.py
index d4b835643..ef826ef45 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))
If you are a new contributor to FRR, please see our contributing guidelines.
After making changes, you do not need to create a new PR. You should perform an amend or interactive rebase followed by a force push.
💚 Basic BGPD CI results: SUCCESS, 0 tests failedResults table
For details, please contact louberger |
Continuous Integration Result: SUCCESSFULCongratulations, this patch passed basic tests Tested-by: NetDEF / OpenSourceRouting.org CI System CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-17396/ This is a comment from an automated CI system. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this script works fine for me, with python 3.8.5 and python3-scapy installed - maybe there's some other issue?
yeah shits broken for 3.9
|
This is a regression in Python 3.9. Scapy has already worked around it with a commit provided by our friend Vincent Bernat. The issue for this workaround is We have a few options:
IMO 3 is the best one. Just set your system python to 3.8. |
I'm not going to muck with python version and just let the os itself decide what should be installed. I'll just live with this bullshit |
The pim test script send_bsr_packet.py appears to not work properly
with scapy and python3.
sudo /usr/bin/python ./send_bsr_packet.py "01005e00000d005056961165080045c000aa5af500000167372a46000001e000000d2400f5ce165b000001004600000101000018e1010100080800000100090a090a0096650001000909090a0096660001000708090a00966700010007070907009668000100070702070096690001000705020700966a0001000702020700966b0001000202020200966c0001000020e1010101010100000100050606050096000001000020e20101010101000001000909090900960000" enp39s0 --interval=1 --count=1
Traceback (most recent call last):
File "/home/sharpd/frr6/tests/topotests/lib/./send_bsr_packet.py", line 23, in
from scapy.all import Raw, sendp
File "/usr/local/lib/python3.9/dist-packages/scapy/all.py", line 16, in
from scapy.arch import *
File "/usr/local/lib/python3.9/dist-packages/scapy/arch/init.py", line 27, in
from scapy.arch.bpf.core import get_if_raw_addr
File "/usr/local/lib/python3.9/dist-packages/scapy/arch/bpf/core.py", line 30, in
LIBC = cdll.LoadLibrary(find_library("libc"))
File "/usr/lib/python3.9/ctypes/util.py", line 341, in find_library
_get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
File "/usr/lib/python3.9/ctypes/util.py", line 147, in _findLib_gcc
if not _is_elf(file):
File "/usr/lib/python3.9/ctypes/util.py", line 99, in _is_elf
with open(filename, 'br') as thefile:
Limit running to python2
Signed-off-by: Donald Sharp sharpd@nvidia.com