Skip to content
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

[Bug]: Testcase test_balancing_sub_ports[port_in_lag] fail because select incorrect interface as src_port #16529

Open
weiguo-nvidia opened this issue Jan 15, 2025 · 0 comments

Comments

@weiguo-nvidia
Copy link
Contributor

weiguo-nvidia commented Jan 15, 2025

Issue Description


Background

Test case sub_port_interfaces.test_sub_port_interfaces.TestSubPorts#test_balancing_sub_ports has two fixture parameters: ['port', 'port_in_lag']

  • test_balancing_sub_ports[port]
  • test_balancing_sub_ports[port_in_lag]

Issue

  • Case test_balancing_sub_ports[port] always pass
  • Case test_balancing_sub_ports[port_in_lag] sometimes fail because Failed: Expected packet not available.

In the test case, the src_port is selected randomly. If the src_port selects eth0 or eth1, the case will fail. The eth0 and eth1 are the ptf tested ports, which should not be selected as src_port

    def test_balancing_sub_ports(self, duthost, ptfhost, ptfadapter, apply_balancing_config):
        new_sub_ports = apply_balancing_config['new_sub_ports']
        sub_ports = apply_balancing_config['sub_ports']
        src_ports = apply_balancing_config['src_ports']
        src_port = random.choice(src_ports)                        <<<<<< HERE

Root cause

The src_ports list is generated by function apply_balancing_config, which is defined in tests/sub_port_interfaces/conftest.py.
In the current code, there already has a logic to remove ptf port from the src_ports list

        mg_facts = duthost.get_extended_minigraph_facts(tbinfo)
        all_up_ports = set()
        for port in list(mg_facts['minigraph_ports'].keys()):
            all_up_ports.add("eth" + str(mg_facts['minigraph_ptf_indices'][port]))
        src_ports = tuple(all_up_ports.difference(ptf_ports))                        <<<<<< HERE
  • When the test case is test_balancing_sub_ports[port], the ptf_ports value is ['eth0', 'eth1']
(Pdb) all_up_ports
{'eth45', 'eth37', 'eth24', 'eth13', 'eth52', 'eth41', 'eth43', 'eth4', 'eth21', 'eth20', 'eth9', 'eth32', 'eth17', 'eth25', 'eth33', 'eth14', 'eth44', 'eth5', 'eth40', 'eth12', 'eth49', 'eth8', 'eth29', 'eth36', 'eth48', 'eth53', 'eth42', 'eth1', 'eth0', 'eth15', 'eth28', 'eth16'}

(Pdb) ptf_ports
['eth0', 'eth1']

After src_ports = tuple(all_up_ports.difference(ptf_ports)), the eth0 and eth1 are removed, so the src_ports list is correct

(Pdb) src_ports
('eth45', 'eth37', 'eth24', 'eth13', 'eth52', 'eth41', 'eth43', 'eth4', 'eth21', 'eth20', 'eth9', 'eth32', 'eth17', 'eth25', 'eth33', 'eth14', 'eth44', 'eth5', 'eth40', 'eth12', 'eth49', 'eth8', 'eth29', 'eth36', 'eth48', 'eth53', 'eth42', 'eth15', 'eth28', 'eth16')
  • When the test case is test_balancing_sub_ports[port_in_lag], the ptf_ports value is OrderedDict([('bond0', 'eth0'), ('bond1', 'eth1')])
(Pdb) all_up_ports
{'eth52', 'eth14', 'eth0', 'eth1', 'eth33', 'eth4', 'eth17', 'eth32', 'eth24', 'eth36', 'eth53', 'eth41', 'eth49', 'eth44', 'eth13', 'eth5', 'eth9', 'eth15', 'eth45', 'eth40', 'eth16', 'eth20', 'eth42', 'eth21', 'eth25', 'eth48', 'eth12', 'eth28', 'eth43', 'eth29', 'eth8', 'eth37'}

(Pdb) ptf_ports
OrderedDict([('bond0', 'eth0'), ('bond1', 'eth1')])

After src_ports = tuple(all_up_ports.difference(ptf_ports)), the eth0 and eth1 still exist in src_ports list. When the src_port is randomly selected eth0 or eth1, the case will fail

(Pdb) src_ports
('eth52', 'eth14', 'eth0', 'eth1', 'eth33', 'eth4', 'eth17', 'eth32', 'eth24', 'eth36', 'eth53', 'eth41', 'eth49', 'eth44', 'eth13', 'eth5', 'eth9', 'eth15', 'eth45', 'eth40', 'eth16', 'eth20', 'eth42', 'eth21', 'eth25', 'eth48', 'eth12', 'eth28', 'eth43', 'eth29', 'eth8', 'eth37')

Results you see

See the Description section

Results you expected to see

Remove eth0 and eth1 from the src_ports list for case test_balancing_sub_ports[port_in_lag]

Is it platform specific

generic

Relevant log output

Output of show version

Attach files (if any)

No response

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

No branches or pull requests

1 participant