sonic-net / sonic-mgmt

Configuration management examples for SONiC
Other
201 stars 727 forks source link

[ test_orchagent_mac_move ] | TypeError: a bytes-like object is required, not 'str' #7903

Closed slutati1536 closed 1 year ago

slutati1536 commented 1 year ago

Description

test dualtor/test_orchagent_mac_move.py is failing with python3 on error: TypeError: a bytes-like object is required, not 'str'

Steps to reproduce the issue:

  1. run dualtor/test_orchagent_mac_move.py

Describe the results you received: def test_mac_move( announce_new_neighbor, apply_active_state_to_orchagent, conn_graph_facts, ptfadapter, ptfhost, rand_selected_dut, set_crm_polling_interval, tbinfo, tunnel_traffic_monitor, vmhost # noqa F811 ): tor = rand_selected_dut ptf_t1_intf = random.choice(get_t1_ptf_ports(tor, tbinfo)) ptf_t1_intf_index = int(ptf_t1_intf.strip("eth"))

    # new neighbor learnt on an active port
    test_port = next(announce_new_neighbor)
  announce_new_neighbor.send(None)

announce_new_neighbor = <generator object announce_new_neighbor.._announce_new_neighbor_gen at 0x7fe63cec5660> apply_active_state_to_orchagent = None conn_graph_facts = {'device_bmc_info': {'r-tigon-20': {}}, 'device_bmc_link': {'r-tigon-20': {}}, 'device_conn': {'r-tigon-20': {'Etherne...: 'r-tigon-19', 'peerport': 'ethernet 1/28', 'speed': '100000'}, ...}}, 'device_console_info': {'r-tigon-20': {}}, ...} ptf_t1_intf = 'eth1' ptf_t1_intf_index = 1 ptfadapter = ptfhost = <tests.common.devices.ptf.PTFHost object at 0x7fe641aef670> rand_selected_dut = set_crm_polling_interval = None tbinfo = {'comment': 'Mellanox MTR testbed', 'conf-name': 'r-tigon-20-t0-64', 'duts': ['r-tigon-20'], 'duts_map': {'r-tigon-20': 0}, ...} test_port = 'Ethernet44' tor = tunnel_traffic_monitor = <class 'tests.common.dualtor.tunnel_traffic_utils.tunnel_traffic_monitor..TunnelTrafficMonitor'> vmhost = <tests.common.devices.vmhost.VMHost object at 0x7fe63e040760>

dualtor/test_orchagent_mac_move.py:95:


dualtor/test_orchagent_mac_move.py:52: in _announce_new_neighbor_gen NEW_NEIGHBOR_IPV4_ADDR, dut_iface, dump_scapy_packet_show_output(garp_packet) dut_iface = 'Ethernet44' dut_ifaces = ['Ethernet44', 'Ethernet36', 'Ethernet144', 'Ethernet216', 'Ethernet52', 'Ethernet208', ...] dut_to_ptf_intf_map = {'Ethernet0': 0, 'Ethernet100': 25, 'Ethernet104': 26, 'Ethernet108': 27, ...} garp_packet = <Ether dst=ff:ff:ff:ff:ff:ff src=02:AA:BB:CC:DD:EE type=ARP |<ARP op=is-at hwsrc=02:AA:BB:CC:DD:EE psrc=192.168.0.25...00:00:00 pdst=192.168.0.250 |<Raw load='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |>>> ptf_iface = 11 ptfadapter = update_iface_func = None common/utilities.py:507: in dump_scapy_packet_show_output packet.show() _stdout = <_io.TextIOWrapper name="<_io.FileIO name=10 mode='rb+' closefd=True>" mode='r+' encoding='utf-8'> packet = <Ether dst=ff:ff:ff:ff:ff:ff src=02:AA:BB:CC:DD:EE type=ARP |<ARP op=is-at hwsrc=02:AA:BB:CC:DD:EE psrc=192.168.0.25...00:00:00 pdst=192.168.0.250 |<Raw load='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |>>> /var/AzDevOps/env-python3/lib/python3.8/site-packages/scapy/packet.py:1464: in show return self._show_or_dump(dump, indent, lvl, label_lvl) dump = False indent = 3 label_lvl = '' lvl = '' self = <Ether dst=ff:ff:ff:ff:ff:ff src=02:AA:BB:CC:DD:EE type=ARP |<ARP op=is-at hwsrc=02:AA:BB:CC:DD:EE psrc=192.168.0.25...00:00:00 pdst=192.168.0.250 |<Raw load='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |>>>


self = <Ether dst=ff:ff:ff:ff:ff:ff src=02:AA:BB:CC:DD:EE type=ARP |<ARP op=is-at hwsrc=02:AA:BB:CC:DD:EE psrc=192.168.0.25...00:00:00 pdst=192.168.0.250 |<Raw load='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |>>> dump = False, indent = 3, lvl = '', label_lvl = '', first_call = True

def _show_or_dump(self,
                  dump=False,  # type: bool
                  indent=3,  # type: int
                  lvl="",  # type: str
                  label_lvl="",  # type: str
                  first_call=True  # type: bool
                  ):
    # type: (...) -> Optional[str]
    """
    Internal method that shows or dumps a hierarchical view of a packet.
    Called by show.

    :param dump: determine if it prints or returns the string value
    :param int indent: the size of indentation for each layer
    :param str lvl: additional information about the layer lvl
    :param str label_lvl: additional information about the layer fields
    :param first_call: determine if the current function is the first
    :return: return a hierarchical view if dump, else print it
    """

    if dump:
        from scapy.themes import AnsiColorTheme
        ct = AnsiColorTheme()  # No color for dump output
    else:
        ct = conf.color_theme
    s = "%s%s %s %s \n" % (label_lvl,
                           ct.punct("###["),
                           ct.layer_name(self.name),
                           ct.punct("]###"))
    for f in self.fields_desc:
        if isinstance(f, ConditionalField) and not f._evalcond(self):
            continue
        if isinstance(f, Emph) or f in conf.emph:
            ncol = ct.emph_field_name
            vcol = ct.emph_field_value
        else:
            ncol = ct.field_name
            vcol = ct.field_value
        fvalue = self.getfieldval(f.name)
        if isinstance(fvalue, Packet) or (f.islist and f.holds_packets and isinstance(fvalue, list)):  # noqa: E501
            pad = max(0, 10 - len(f.name)) * " "
            s += "%s  \\%s%s\\\n" % (label_lvl + lvl, ncol(f.name), pad)
            fvalue_gen = SetGen(
                fvalue,
                _iterpacket=0
            )  # type: SetGen[Packet]
            for fvalue in fvalue_gen:
                s += fvalue._show_or_dump(dump=dump, indent=indent, label_lvl=label_lvl + lvl + "   |", first_call=False)  # noqa: E501
        else:
            pad = max(0, 10 - len(f.name)) * " "
            begn = "%s  %s%s%s " % (label_lvl + lvl,
                                    ncol(f.name),
                                    pad,
                                    ct.punct("="),)
            reprval = f.i2repr(self, fvalue)
            if isinstance(reprval, str):
                reprval = reprval.replace("\n", "\n" + " " * (len(label_lvl) +  # noqa: E501
                                                              len(lvl) +
                                                              len(f.name) +
                                                              4))
            s += "%s%s\n" % (begn, vcol(reprval))
    if self.payload:
        s += self.payload._show_or_dump(  # type: ignore
            dump=dump,
            indent=indent,
            lvl=lvl + (" " * indent * self.show_indent),
            label_lvl=label_lvl,
            first_call=False
        )

    if first_call and not dump:
      print(s)

E TypeError: a bytes-like object is required, not 'str'

Describe the results you expected: tests should not fail over python migration realted issue

Additional information you deem important: Output of show version:

SONiC Software Version: SONiC.202211_RC8.3-696a6a43b_Internal
Distribution: Debian 11.6
Kernel: 5.10.0-18-2-amd64
Build commit: 696a6a43b
Build date: Mon Mar 27 10:50:51 UTC 2023
Built by: sw-r2d2-bot@r-build-sonic-ci03-244

Platform: x86_64-mlnx_msn4600c-r0
HwSKU: Mellanox-SN4600C-C64
ASIC: mellanox
ASIC Count: 1
Serial Number: MT2131X10295
Model Number: MSN4600-CS2FO
Hardware Revision: A1
Uptime: 13:16:06 up 13:25,  2 users,  load average: 1.37, 1.34, 1.30
Date: Tue 28 Mar 2023 13:16:06

Docker images:
REPOSITORY                                         TAG                               IMAGE ID       SIZE
docker-orchagent                                   202211_RC8.3-696a6a43b_Internal   84055ebb4c77   539MB
docker-orchagent                                   latest                            84055ebb4c77   539MB
docker-fpm-frr                                     202211_RC8.3-696a6a43b_Internal   83d5f57abddb   550MB
docker-fpm-frr                                     latest                            83d5f57abddb   550MB
docker-teamd                                       202211_RC8.3-696a6a43b_Internal   e6b58409a5c6   520MB
docker-teamd                                       latest                            e6b58409a5c6   520MB
docker-macsec                                      latest                            d76f633dda63   522MB
docker-syncd-mlnx                                  202211_RC8.3-696a6a43b_Internal   2bd090589266   939MB
docker-syncd-mlnx                                  latest                            2bd090589266   939MB
docker-platform-monitor                            202211_RC8.3-696a6a43b_Internal   4fcfc27b9bbe   942MB
docker-platform-monitor                            latest                            4fcfc27b9bbe   942MB
docker-sonic-telemetry                             202211_RC8.3-696a6a43b_Internal   be9f9e750657   802MB
docker-sonic-telemetry                             latest                            be9f9e750657   802MB
docker-snmp                                        202211_RC8.3-696a6a43b_Internal   62432cf85f40   549MB
docker-snmp                                        latest                            62432cf85f40   549MB
docker-eventd                                      202211_RC8.3-696a6a43b_Internal   855b7c3d7218   503MB
docker-eventd                                      latest                            855b7c3d7218   503MB
docker-dhcp-relay                                  latest                            c90d1c5967eb   513MB
docker-lldp                                        202211_RC8.3-696a6a43b_Internal   e33be345d3f2   546MB
docker-lldp                                        latest                            e33be345d3f2   546MB
docker-mux                                         202211_RC8.3-696a6a43b_Internal   e9f6fa7ef277   552MB
docker-mux                                         latest                            e9f6fa7ef277   552MB
docker-database                                    202211_RC8.3-696a6a43b_Internal   9cae58961a25   503MB
docker-database                                    latest                            9cae58961a25   503MB
docker-sonic-p4rt                                  202211_RC8.3-696a6a43b_Internal   77b20e5b758d   586MB
docker-sonic-p4rt                                  latest                            77b20e5b758d   586MB
docker-router-advertiser                           202211_RC8.3-696a6a43b_Internal   f3a99688e9df   503MB
docker-router-advertiser                           latest                            f3a99688e9df   503MB
docker-sflow                                       202211_RC8.3-696a6a43b_Internal   780973343beb   479MB
docker-sflow                                       latest                            780973343beb   479MB
docker-nat                                         202211_RC8.3-696a6a43b_Internal   83454bb6925c   481MB
docker-nat                                         latest                            83454bb6925c   481MB
docker-sonic-mgmt-framework                        202211_RC8.3-696a6a43b_Internal   20cfc12ab3c5   612MB
docker-sonic-mgmt-framework                        latest                            20cfc12ab3c5   612MB
urm.nvidia.com/sw-nbu-sws-sonic-docker/doroce      1.1.0-202211-internal-5           078ba366e374   200MB
urm.nvidia.com/sw-nbu-sws-sonic-docker/sonic-wjh   1.4.0-202211-internal-5           b4f92852d9ca   323MB
bingwang-ms commented 1 year ago

Added @wsycqyz to check.

wsycqyz commented 1 year ago

Fixed in #8063