@@ -120,13 +120,52 @@ def get_new_interval(duthost, is_valid):
120
120
return min (detection_time , restoration_time ) + 10
121
121
122
122
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
+
123
162
@pytest .mark .parametrize ("operation" , ["add" , "replace" ])
124
163
@pytest .mark .parametrize ("field_pre_status" , ["existing" , "nonexistent" ])
125
164
@pytest .mark .parametrize ("is_valid_config_update" , [True , False ])
126
165
def test_pfcwd_interval_config_updates (duthost , ensure_dut_readiness , operation , field_pre_status , is_valid_config_update ):
127
166
new_interval = get_new_interval (duthost , is_valid_config_update )
128
167
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 )}
130
169
detection_time , restoration_time = get_detection_restoration_times (duthost )
131
170
pre_status = max (detection_time , restoration_time )
132
171
field_pre_status_to_value_map = {"existing" : "{}" .format (pre_status ), "nonexistent" : "" }
0 commit comments