forked from sonic-net/sonic-mgmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new file: ansible/platform_skip_inventory.json
-adding new json file to support fixture in platform tests to skip checks for modules not present in DUT new file: tests/platform_tests/cli/test_show_chassis_module.py -adding new two new test cases for verifying show chassis-module status and show chassis-module midplane status introduced as part of PRs sonic-net/sonic-utilities#1145 and sonic-net/sonic-utilities#1267 tests/platform_tests/conftest.py -adding a fixture that skips checking for modules for DUT
- Loading branch information
Showing
3 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"dut2": { | ||
"modules": { | ||
"skip": ["FABRIC-CARD0", "LINE-CARD4"] | ||
} | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import logging | ||
import re | ||
|
||
import pytest | ||
from tests.common.helpers.assertions import pytest_assert | ||
|
||
pytestmark = [ | ||
pytest.mark.topology('t2') | ||
] | ||
|
||
CMD_SHOW_CHASSIS_MODULE = "show chassis-module" | ||
|
||
|
||
def parse_chassis_module(output, expected_headers): | ||
|
||
for ln_id, temp_line in enumerate(output): | ||
if re.findall('----',temp_line): | ||
h_line_id = ln_id - 1 | ||
h_line = output[h_line_id] | ||
break | ||
|
||
headers = h_line.split() | ||
|
||
for header_v in expected_headers: | ||
pytest_assert(header_v in headers, "Missing header {}".format(header_v)) | ||
|
||
result = {} | ||
num_h = len(headers) | ||
for a_line in output[h_line_id+2:]: | ||
tmp = a_line.split() | ||
mod_idx = tmp[0] | ||
result[mod_idx] = {} | ||
for i in range(1, num_h): | ||
result[mod_idx][headers[i]] = tmp[i] | ||
|
||
return result | ||
|
||
|
||
def test_show_chassis_module_status(duthosts, enum_dut_hostname, skip_module_list): | ||
""" | ||
@summary: Verify output of `show chassis-module status` | ||
""" | ||
cmd = " ".join([CMD_SHOW_CHASSIS_MODULE, "status"]) | ||
logging.info("verifying output of cli command {}".format(cmd)) | ||
duthost = duthosts[enum_dut_hostname] | ||
exp_headers = ["Name", "Description", "Physical-Slot", "Oper-Status", "Admin-Status"] | ||
|
||
output = duthost.command(cmd) | ||
res = parse_chassis_module(output['stdout_lines'], exp_headers) | ||
|
||
# by default will assume all modules should be shown online except in skip_module_list | ||
for mod_idx in res.keys(): | ||
if mod_idx in skip_module_list: | ||
pytest_assert(res[mod_idx]['Oper-Status'] == 'Empty', | ||
"Oper-status for slot {} should be Empty but it is {}".format( | ||
mod_idx, res[mod_idx]['Oper-Status'])) | ||
else: | ||
pytest_assert(res[mod_idx]['Oper-Status'] == 'Online', | ||
"Oper-status for slot {} should be Online but it is {}".format( | ||
mod_idx, res[mod_idx]['Oper-Status'])) | ||
|
||
|
||
def test_show_chassis_module_midplane_status(duthosts, enum_dut_hostname, skip_module_list): | ||
""" | ||
@summary: Verify output of `show chassis-module midplane-status` | ||
""" | ||
cmd = " ".join([CMD_SHOW_CHASSIS_MODULE, "midplane-status"]) | ||
logging.info("verifying output of cli command {}".format(cmd)) | ||
expected_headers = ["Name", "IP-Address", "Reachability"] | ||
|
||
duthost = duthosts[enum_dut_hostname] | ||
output = duthost.command(cmd) | ||
res_mid_status = parse_chassis_module(output['stdout_lines'], expected_headers) | ||
|
||
if duthost.is_supervisor_node(): | ||
logging.info("supervisor node is {}".format(duthost.hostname)) | ||
# on supervisor check all applicable line cards are reachable except any modules from skip_module_list | ||
for mod_idx in res_mid_status: | ||
mod_mid_status = res_mid_status[mod_idx]['Reachability'] | ||
if mod_idx in skip_module_list: | ||
pytest_assert(res_mid_status[mod_idx]['Reachability'] == "False", | ||
"reachability of line card {} expected false but is {}".format(mod_idx, mod_mid_status)) | ||
else: | ||
pytest_assert(mod_mid_status == "True", | ||
"midplane reachability of line card {} expected true but is {}".format(mod_idx, | ||
mod_mid_status)) | ||
# for line card only supervisor is shown so do not need to check skip | ||
elif duthost.is_frontend_node(): | ||
for mod_idx in res_mid_status: | ||
mod_mid_status = res_mid_status[mod_idx]['Reachability'] | ||
pytest_assert(mod_mid_status == "True", "reachability should be true for {}".format(mod_idx)) | ||
else: | ||
pytest.skip("test is valid on supervisor or fronend node of chassis") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters