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
Merged
Changes from 4 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
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):
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]
break

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:
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_lines'].split(), "pfcwd unexpectedly still running on interface {}".format(interface))
finally:
delete_tmpfile(duthost, tmpfile)


@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