Skip to content

Commit 825f90c

Browse files
XuChen-MSFTCopilot
andcommitted
refactor: unify result analysis pattern across PfcXoff and IngressDrop executors
PfcXoff used explicit all_true/all_false/all_equal pattern (8 lines). IngressDrop used concise set-dedup pattern (3 lines). Both produce identical outcomes for all input combinations. Unified to the concise pattern with descriptive comment: return_result = (True, results[0]) # Multiple attempts: check consistency (set dedup detects mixed True/False) if len(results) > 1 and len(set(results)) > 1: return_result = (False, False) UT coverage: PR sonic-net#22545 (e2fca74) — 12 new tests covering all 6 input combinations for both executors. Addresses @StormLiangMS review: inconsistent result patterns. Co-authored-by: Copilot <[email protected]> Signed-off-by: Xu Chen <[email protected]>
1 parent 003c1c5 commit 825f90c

2 files changed

Lines changed: 7 additions & 22 deletions

File tree

tests/saitests/probe/ingress_drop_probing_executor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,7 @@ def check(self, src_port: int, dst_port: int, value: int, attempts: int = 1,
272272

273273
# ===== Result analysis based on attempts =====
274274
return_result = (True, results[0])
275-
# Multiple attempts: check consistency
276-
# Inconsistent results indicate noise/error
275+
# Multiple attempts: check consistency (set dedup detects mixed True/False)
277276
if len(results) > 1 and len(set(results)) > 1:
278277
return_result = (False, False)
279278

tests/saitests/probe/pfc_xoff_probing_executor.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -176,31 +176,17 @@ def check(self, src_port: int, dst_port: int, value: int, attempts: int = 1,
176176
f"pfc_triggered={pfc_triggered}")
177177

178178
# Result analysis based on attempts
179-
if attempts == 1:
180-
# Single attempt: direct result
181-
detected = results[0]
182-
success = True
183-
else:
184-
# Multiple attempts: require consistent results for reliable detection
185-
all_true = all(results)
186-
all_false = not any(results)
187-
all_equal = all_true or all_false
188-
189-
if all_equal:
190-
# Verification successful - consistent results
191-
detected = results[0] # Any result since they're all the same
192-
success = True
193-
else:
194-
# Verification failed - inconsistent results indicate noise/error
195-
detected = False
196-
success = False
179+
return_result = (True, results[0])
180+
# Multiple attempts: check consistency (set dedup detects mixed True/False)
181+
if len(results) > 1 and len(set(results)) > 1:
182+
return_result = (False, False)
197183

198184
if self.verbose and self.observer:
199185
self.observer.trace(
200186
f"[PFC Xoff Executor] Check complete: value={value}, attempts={attempts}, "
201-
f"results={results}, final_detected={detected}, success={success}")
187+
f"results={results}, final_detected={return_result[1]}, success={return_result[0]}")
202188

203-
return success, detected
189+
return return_result
204190

205191
except Exception as e:
206192
if self.verbose and self.observer:

0 commit comments

Comments
 (0)