Skip to content

[GCU E2E test] add stop pfcwd test #7308

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

Merged
merged 9 commits into from
Feb 1, 2023
38 changes: 37 additions & 1 deletion tests/generic_config_updater/test_pfcwd_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,49 @@ def get_new_interval(duthost, is_valid):
return min(detection_time, restoration_time) + 10


def test_stop_pfcwd(duthost, ensure_dut_readiness):
start_pfcwd = duthost.shell('config pfcwd start_default')
pytest_assert(not start_pfcwd['rc'], "Failed to start default pfcwd config")
pfcwd_config = duthost.shell("show pfcwd config")
pytest_assert(not pfcwd_config['rc'], "Unable to read pfcwd config")

for line in pfcwd_config['stdout_lines']:
if line.startswith('Ethernet'):
interface = line.split()[0]

json_patch = [
{
"op": "remove",
"path": "/PFC_WD/{}/detection_time".format(interface),
},
{
"op": "remove",
"path": "/PFC_WD/{}/restoration_time".format(interface),
},
{
"op": "remove",
"path": "/PFC_WD/{}/action".format(interface)
}
]

try:
tmpfile = generate_tmpfile(duthost)
output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
expect_op_success(duthost, output)
pfcwd_updated_config = duthost.shell("show pfcwd config")
pytest_assert(not pfcwd_config['rc'], "Unable to read updated pfcwd config")
pytest_assert(interface not in pfcwd_updated_config['stdout'].split(), "pfcwd unexpectedly still running on interface {}".format(interface))
finally:
delete_tmpfile(duthost, tmpfile)
Comment on lines +136 to +159
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whole code needs to be indented. Needs to move under the 'for' block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test only intends to test one interface, as the flow would be the same for all interfaces. I added a break statement to the for loop to stop once the first interface is identified for test



@pytest.mark.parametrize("operation", ["add", "replace"])
@pytest.mark.parametrize("field_pre_status", ["existing", "nonexistent"])
@pytest.mark.parametrize("is_valid_config_update", [True, False])
def test_pfcwd_interval_config_updates(duthost, ensure_dut_readiness, operation, field_pre_status, is_valid_config_update):
new_interval = get_new_interval(duthost, is_valid_config_update)

operation_to_new_value_map = {"add": "{}".format(new_interval), "replace": "{}".format(new_interval), "remove": ""}
operation_to_new_value_map = {"add": "{}".format(new_interval), "replace": "{}".format(new_interval)}
detection_time, restoration_time = get_detection_restoration_times(duthost)
pre_status = max(detection_time, restoration_time)
field_pre_status_to_value_map = {"existing": "{}".format(pre_status), "nonexistent": ""}
Expand Down