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

[sfps] Fix issue where the test_sfps failed due to key error #4250

Merged
merged 3 commits into from
Sep 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions tests/platform_tests/api/test_chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import pytest
import yaml

from natsort import natsorted

from tests.common.helpers.assertions import pytest_assert
from tests.common.helpers.platform_api import chassis, module
from tests.common.fixtures.conn_graph_facts import conn_graph_facts
Expand Down Expand Up @@ -61,7 +63,15 @@
@pytest.fixture(scope="module")
def physical_port_indices(duthosts, enum_rand_one_per_hwsku_hostname):
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
return get_physical_port_indices(duthost)
port_map = get_physical_port_indices(duthost)
result = []
visited_intfs = set()
for intf in natsorted(port_map.keys()):
if intf in visited_intfs:
continue
visited_intfs.add(intf)
result.append(port_map[intf])
return result

@pytest.fixture(scope="class")
def gather_facts(request, duthosts):
Expand Down Expand Up @@ -378,7 +388,6 @@ def test_sfps(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platf
num_sfps = int(chassis.get_num_sfps(platform_api_conn))
except:
pytest.fail("num_sfps is not an integer")
list_sfps = []
list_sfps = physical_port_indices
logging.info("Physical port indices = {}".format(list_sfps))
if duthost.facts.get("chassis"):
Expand Down