Skip to content

[drop_counter] Fix "list index out of range" Exception in random.choice in arp_responder#2183

Merged
bingwang-ms merged 1 commit intosonic-net:masterfrom
bingwang-ms:fix_bug_in_drop_counter
Sep 4, 2020
Merged

[drop_counter] Fix "list index out of range" Exception in random.choice in arp_responder#2183
bingwang-ms merged 1 commit intosonic-net:masterfrom
bingwang-ms:fix_bug_in_drop_counter

Conversation

@bingwang-ms
Copy link
Collaborator

Description of PR

Summary:
Fixes # (issue)
This PR is to fix "list index out of range" exception found in nightly test.

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Approach

What is the motivation for this PR?

The following error is seen in nightly test:

   def mock_server(fanouthosts, testbed_params, arp_responder, ptfadapter, duthost):
        """
        Mock the presence of a server beneath a T0.
    
        Returns:
            A MockServer which will allow the caller to mock the behavior of
            a server within a VLAN under a T0.
    
        """
        server_dst_port = random.choice(testbed_params["vlan_ports"])
>       server_dst_addr = random.choice(arp_responder[server_dst_port].keys())

  def choice(self, seq):
        """Choose a random element from a non-empty sequence."""
>       return seq[int(self.random() * len(seq))]  # raises IndexError if seq is empty
E       IndexError: list index out of range

The root cause for that is the arp_responder map store 100 ports of all vlan ports, and Line 233 random select a port from all vlan ports, which may not be in the arp_responder map. As a result, an IndexError: list index out of range is raised.

How did you do it?

Update the way for choosing dest_port.

How did you verify/test it?

Verified on Arista-7260

py.test --inventory ../ansible/str,../ansible/veos --host-pattern str-7260cx3-acs-1 --module-path ../ansible/library/ --testbed vms7-t0-7260-1 --testbed_file ../ansible/testbed.csv --junit-xml=tr.xml --log-cli-level warn --collect_techsupport=False --topology=t0,any,util -k 'not test_fast_reboot' drop_packets/test_configurable_drop_counters.py
========================================================================================= test session starts =========================================================================================
platform linux2 -- Python 2.7.12, pytest-4.6.5, py-1.8.1, pluggy-0.13.1 -- /usr/bin/python
cachedir: .pytest_cache
ansible: 2.8.7
rootdir: /data/Networking-acs-sonic-mgmt/tests, inifile: pytest.ini
plugins: forked-1.1.3, xdist-1.28.0, ansible-2.2.2, repeat-0.8.0
collected 2 items                                                                                                                                                                                     

drop_packets/test_configurable_drop_counters.py::test_neighbor_link_down[PORT_INGRESS_DROPS-L3_EGRESS_LINK_DOWN] PASSED                                                                         [ 50%]
drop_packets/test_configurable_drop_counters.py::test_neighbor_link_down[SWITCH_INGRESS_DROPS-L3_EGRESS_LINK_DOWN] SKIPPED                                                                      [100%]

------------------------------------------------------------------ generated xml file: /data/Networking-acs-sonic-mgmt/tests/tr.xml -------------------------------------------------------------------
================================================================================ 1 passed, 1 skipped in 80.91 seconds =================================================================================

Any platform specific information?

No.

Supported testbed topology if it's a new test case?

N/A

Documentation

No

The arp_responder map store 100 ports of all vlan ports, and Line 233
random select a port from all vlan ports, which may not be in the
arp_responder map. As a result, an IndexError: list index out of range
is raised.
@bingwang-ms bingwang-ms requested a review from daall September 3, 2020 08:57
@bingwang-ms bingwang-ms merged commit 78b55e5 into sonic-net:master Sep 4, 2020
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
…x-kernel] advance submodule head (sonic-net#12025)

linkmgrd:
* ab5b2c1 2022-09-02 | Fix mux config (sonic-net#128) (HEAD -> 202205, github/202205) [Longxiang Lyu]

utilities:
* 7de9305 2022-09-07 | [generate dump]Added error message when saisdkdump fails (sonic-net#2356) (HEAD -> 202205, github/202205) [Sudharsan Dhamal Gopalarathnam]
* c5b0a6d 2022-09-07 | [counterpoll]Fixing counterpoll show for tunnel and acl stats (sonic-net#2355) [Sudharsan Dhamal Gopalarathnam]
* 1452b44 2022-09-05 | [GCU] Fix missing backend in dry run (sonic-net#2347) [jingwenxie]
* bc7b845 2022-09-04 | Add Password Hardening CLI support (sonic-net#2338) [davidpil2002]
* 55e8948 2022-09-06 | [fast-reboot]Avoid stopping masked services during fast-reboot (sonic-net#2335) [Sudharsan Dhamal Gopalarathnam]
* f7d69d4 2022-08-30 | Replace cmp in acl_loader with operator.eq (sonic-net#2328) [Zhaohui Sun]
* 4054ebb 2022-09-05 | Add verification for override (sonic-net#2305) [jingwenxie]
* 729d811 2022-05-30 | Fix sonic-installer and 'show version' command crash when database docker not running issue. (sonic-net#2183) [Hua Liu]

platform-daemons:
* 36ba7c0 2022-09-07 | [ycable] cleanup logic for creating grpc future ready (sonic-net#289) (HEAD -> 202205) [vdahiya12]
* 2a9db73 2022-09-01 | [ycabled] fix insert events from xcvrd;cleanup some mux toggle logic (sonic-net#287) [vdahiya12]

platform-common:
* d7c990d 2022-09-03 | [CMIS] 'get_transceiver_info' should return 'None' when CMIS cable EEPROM is not ready  (sonic-net#305) (HEAD -> 202205) [Kebo Liu]

linux-kernel:
* 25ea052 2022-08-31 | [patch]: Add accpt_untracked_na kernel param (sonic-net#292) (HEAD -> 202205) [Lawrence Lee]

Signed-off-by: Ying Xie <[email protected]>

Signed-off-by: Ying Xie <[email protected]>
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
17315fc (HEAD -> 202111, origin/202111) [Vxlanmgr] vnet netdev cleanup during config reload fix (sonic-net#2191)
f820af3 [aclorch] Do not fail ACL rule remove flow if rule already deleted (sonic-net#2183)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants