Skip to content

Commit 9cdc4fc

Browse files
authored
[GCU E2E test] add stop pfcwd test (#7308)
1 parent b921a1a commit 9cdc4fc

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

tests/generic_config_updater/test_pfcwd_interval.py

+40-1
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,52 @@ def get_new_interval(duthost, is_valid):
120120
return min(detection_time, restoration_time) + 10
121121

122122

123+
def test_stop_pfcwd(duthost, ensure_dut_readiness):
124+
start_pfcwd = duthost.shell('config pfcwd start_default')
125+
pytest_assert(not start_pfcwd['rc'], "Failed to start default pfcwd config")
126+
pfcwd_config = duthost.shell("show pfcwd config")
127+
pytest_assert(not pfcwd_config['rc'], "Unable to read pfcwd config")
128+
129+
for line in pfcwd_config['stdout_lines']:
130+
if line.startswith('Ethernet'):
131+
interface = line.split()[0]
132+
break
133+
else:
134+
pytest_assert(False, "No interface found running pfcwd - unable to run test")
135+
136+
json_patch = [
137+
{
138+
"op": "remove",
139+
"path": "/PFC_WD/{}/detection_time".format(interface),
140+
},
141+
{
142+
"op": "remove",
143+
"path": "/PFC_WD/{}/restoration_time".format(interface),
144+
},
145+
{
146+
"op": "remove",
147+
"path": "/PFC_WD/{}/action".format(interface)
148+
}
149+
]
150+
151+
try:
152+
tmpfile = generate_tmpfile(duthost)
153+
output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
154+
expect_op_success(duthost, output)
155+
pfcwd_updated_config = duthost.shell("show pfcwd config")
156+
pytest_assert(not pfcwd_config['rc'], "Unable to read updated pfcwd config")
157+
pytest_assert(interface not in pfcwd_updated_config['stdout'].split(), "pfcwd unexpectedly still running on interface {}".format(interface))
158+
finally:
159+
delete_tmpfile(duthost, tmpfile)
160+
161+
123162
@pytest.mark.parametrize("operation", ["add", "replace"])
124163
@pytest.mark.parametrize("field_pre_status", ["existing", "nonexistent"])
125164
@pytest.mark.parametrize("is_valid_config_update", [True, False])
126165
def test_pfcwd_interval_config_updates(duthost, ensure_dut_readiness, operation, field_pre_status, is_valid_config_update):
127166
new_interval = get_new_interval(duthost, is_valid_config_update)
128167

129-
operation_to_new_value_map = {"add": "{}".format(new_interval), "replace": "{}".format(new_interval), "remove": ""}
168+
operation_to_new_value_map = {"add": "{}".format(new_interval), "replace": "{}".format(new_interval)}
130169
detection_time, restoration_time = get_detection_restoration_times(duthost)
131170
pre_status = max(detection_time, restoration_time)
132171
field_pre_status_to_value_map = {"existing": "{}".format(pre_status), "nonexistent": ""}

0 commit comments

Comments
 (0)