Skip to content

TC-ELDIST-2.2: Add Python automation test script for Electrical Distribution Cluster (Fixed-by-Manufacturer Quality)#72321

Draft
dcj wants to merge 8 commits into
project-chip:masterfrom
dcj:dcj/tc-eldist-2-2-python-test
Draft

TC-ELDIST-2.2: Add Python automation test script for Electrical Distribution Cluster (Fixed-by-Manufacturer Quality)#72321
dcj wants to merge 8 commits into
project-chip:masterfrom
dcj:dcj/tc-eldist-2-2-python-test

Conversation

@dcj

@dcj dcj commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds TC_ELDIST_2_2.py implementing TC-ELDIST-2.2 ("Fixed-by-Manufacturer Quality Verification with Server as DUT") from the Electrical Distribution Cluster test plan.

This is the Python automation companion to TC-ELDIST-2.2 in chip-test-plans #6156. Filed as a sibling to the in-flight TC-ELDIST-2.1 PR #72278.

What the script tests

  • Within-boot stability: re-read of MaxContinuousCurrent must equal the initial read (per the Fixed-by-Manufacturer (X) quality).
  • Write rejection: writes to MaxVoltage, NumberOfPoles, and ServiceEntranceRated must each return UNSUPPORTED_WRITE (complements PR TC-ELDIST-2.1: Add Python automation test script for Electrical Distribution Cluster #72278's write probe on MaxContinuousCurrent).
  • Persistence across reboot: after operator-driven power cycle, all five mandatory attributes must read back to the same values they had pre-reboot (including null staying null).

Uses the modern @run_if_endpoint_matches(has_cluster(Clusters.ElectricalDistribution)) decorator for proper self-skip behavior when no endpoint hosts the cluster.

Related issues / PRs

Testing

Filed as Draft because no example app currently integrates the Electrical Distribution cluster server on a non-root endpoint; the script will run cleanly under CI once an example app (anticipated electrical-protection-app) provides ELDIST. A not_automated entry in test_metadata.yaml keeps CI green in the interim.

Readability checklist

  • PR title is descriptive
  • Apply the "When in Rome…" rule (coding style)
  • PR size is short (1 new test file + 1 metadata entry)
  • Try to avoid "squashing" and "force-update" in commit history
  • CI time didn't increase (test is not_automated until app integration)

…turer Quality Verification

Adds TC_ELDIST_2_2.py implementing TC-ELDIST-2.2 from the Electrical
Distribution Cluster test plan (chip-test-plans project-chip#6156): verifies all five
mandatory ELDIST server attributes (MaxContinuousCurrent, MaxVoltage,
NumberOfPoles, EndOfLife, ServiceEntranceRated) honor the Fixed-by-
Manufacturer (X) quality across a single boot (re-read stability), reject
writes (UNSUPPORTED_WRITE on three representative attributes), and persist
unchanged across a DUT reboot.

Uses the modern @run_if_endpoint_matches(has_cluster(...)) decorator for
proper self-skip behavior when no endpoint hosts the ElectricalDistribution
cluster.

Adds a not_automated entry to test_metadata.yaml; this script will be
enabled in CI once an example app provides an ELDIST server on a non-root
endpoint (anticipated via the upcoming electrical-protection-app).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the tests label Jun 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new Python test script, TC_ELDIST_2_2.py, to verify that the mandatory attributes of the Electrical Distribution Cluster maintain their values across reboots. It also adds this test to the not_automated list in test_metadata.yaml since the cluster is not yet integrated into any example app. The review feedback correctly points out that in the Matter Python SDK, attempting to write to read-only attributes raises an InteractionModelError rather than returning a status list. The feedback suggests importing InteractionModelError and wrapping the write operations in try-except blocks to properly assert the expected UnsupportedWrite status.

Comment thread src/python_testing/TC_ELDIST_2_2.py
Comment thread src/python_testing/TC_ELDIST_2_2.py Outdated
Comment thread src/python_testing/TC_ELDIST_2_2.py Outdated
Comment thread src/python_testing/TC_ELDIST_2_2.py Outdated
dcj added a commit to dcj/connectedhomeip that referenced this pull request Jun 2, 2026
…ionModelError

The Matter Python SDK raises InteractionModelError on writes to read-only
attributes rather than returning a status list. Wrap the step 7 write
attempt in try/except and assert e.status == UnsupportedWrite.

Flagged by Gemini code review on PR project-chip#72321 (sibling TC-ELDIST-2.2 which
inherited the same buggy pattern from the v5 matter_rag output).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
dcj and others added 4 commits June 2, 2026 12:00
…ionModelError

The Matter Python SDK raises InteractionModelError on writes to read-only
attributes rather than returning a status list. Wrap each of the three
write attempts (MaxVoltage, NumberOfPoles, ServiceEntranceRated) in
try/except and assert e.status == UnsupportedWrite.

Flagged by Gemini code review on initial submission.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…he three read-only write probes

Replaces the try/except InteractionModelError pattern from the previous
fix-up with the canonical write_single_attribute helper across all three
write probes (MaxVoltage, NumberOfPoles, ServiceEntranceRated). Same
semantic (asserts UnsupportedWrite on each read-only attribute) but
matches the idiom used across the rest of src/python_testing/. Drops
the now-unused InteractionModelError import.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… steps

Two changes, both prompted by today's review pass:

1. Per @andy31415 review on project-chip#72324 pointing to TC_ACL_2_2 as the
   canonical baseline, drops the separated steps_TC_ELDIST_2_2 /
   desc_TC_ELDIST_2_2 / pics_TC_ELDIST_2_2 methods in favor of:
   - @pics('ELDIST.S') decorator on the test method
   - Method-level docstring replacing desc_TC_*
   - Inline self.step(N, "description") calls

2. Wraps the operator reboot (step 7) and post-reboot persistence
   verification (step 8) in is_pics_sdk_ci_only dispatch, mirroring the
   pattern in project-chip#72324. The script is currently in not_automated, but the
   dual-mode wrapping makes it CI-safe when it eventually comes out of
   not_automated alongside an example app that hosts ELDIST.

TestStep import dropped; pics added to the decorators import.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

PR #72321: Size comparison from ca3e67c to 016d49e

Full report (35 builds for bl602, bl616, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, psoc6, qpg, realtek, stm32, telink)
platform target config section ca3e67c 016d49e change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1094324 1094324 0 0.0
RAM 144882 144882 0 0.0
bl616 lighting-app bl616+thread FLASH 1105636 1105636 0 0.0
RAM 104280 104280 0 0.0
bl616+wifi+shell FLASH 1593424 1593424 0 0.0
RAM 98176 98176 0 0.0
bl702 lighting-app bl702+eth FLASH 1057326 1057326 0 0.0
RAM 108509 108509 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 896162 896162 0 0.0
RAM 105884 105884 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 776976 776976 0 0.0
RAM 103388 103388 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 789744 789744 0 0.0
RAM 108676 108676 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 738868 738868 0 0.0
RAM 97596 97596 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 719032 719032 0 0.0
RAM 97636 97636 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 568818 568818 0 0.0
RAM 205056 205056 0 0.0
lock CC3235SF_LAUNCHXL FLASH 596298 596298 0 0.0
RAM 205256 205256 0 0.0
efr32 lock-app BRD4187C FLASH 994188 994188 0 0.0
RAM 131288 131288 0 0.0
BRD4338a FLASH 798741 798741 0 0.0
RAM 243424 243424 0 0.0
window-app BRD4187C FLASH 1100608 1100608 0 0.0
RAM 130360 130360 0 0.0
esp32 all-clusters-app c3devkit DRAM 99716 99716 0 0.0
FLASH 1621642 1621642 0 0.0
IRAM 94776 94776 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 834276 834276 0 0.0
RAM 157540 157540 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1733676 1733676 0 0.0
RAM 215260 215260 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1622756 1622756 0 0.0
RAM 211548 211548 0 0.0
light cy8ckit_062s2_43012 FLASH 1469988 1469988 0 0.0
RAM 197420 197420 0 0.0
lock cy8ckit_062s2_43012 FLASH 1503428 1503428 0 0.0
RAM 225252 225252 0 0.0
qpg lighting-app qpg6200+debug FLASH 844200 844200 0 0.0
RAM 127948 127948 0 0.0
lock-app qpg6200+debug FLASH 782276 782276 0 0.0
RAM 118856 118856 0 0.0
realtek light-switch-app rtl8777g FLASH 688760 688760 0 0.0
RAM 101764 101764 0 0.0
lighting-app rtl8777g FLASH 729712 729712 0 0.0
RAM 102044 102044 0 0.0
stm32 light STM32WB5MM-DK FLASH 478416 478416 0 0.0
RAM 141476 141476 0 0.0
telink all-devices-app tl7218x FLASH 813116 813116 0 0.0
RAM 97196 97196 0 0.0
tlsr9118bdk40d FLASH 606574 606574 0 0.0
RAM 120152 120152 0 0.0
bridge-app tl7218x FLASH 731480 731480 0 0.0
RAM 95864 95864 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 851824 851824 0 0.0
RAM 44332 44332 0 0.0
tl7218x FLASH 843152 843152 0 0.0
RAM 99656 99656 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 731974 731974 0 0.0
RAM 55980 55980 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 795200 795200 0 0.0
RAM 75164 75164 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 731904 731904 0 0.0
RAM 33468 33468 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 614610 614610 0 0.0
RAM 118496 118496 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 841268 841272 4 0.0
RAM 97364 97364 0 0.0

@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.09%. Comparing base (7f8ee55) to head (edb7f56).
⚠️ Report is 145 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #72321      +/-   ##
==========================================
+ Coverage   55.55%   56.09%   +0.53%     
==========================================
  Files        1630     1640      +10     
  Lines      111148   112429    +1281     
  Branches    13410    13307     -103     
==========================================
+ Hits        61753    63071    +1318     
+ Misses      49395    49358      -37     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

dcj and others added 3 commits June 3, 2026 06:08
The @pics() + @run_if_endpoint_matches() stack is an untested
combination: the test gets silently skipped, then --fail-on-skipped
converts that to a failure. Zero scripts in master combine these two.

Aligns this script with TC_ACL_2_2 (the canonical @pics() baseline
Andrei called out in PR review feedback) and with the fix validated
on project-chip#72324.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per EMTT 2026-06-11 discussion, NV-persistence across reboot is
testable via the framework helper rather than the older
is_pics_sdk_ci_only + wait_for_user_input("Reboot...") dispatch.
Canonical reference pattern: TC_AVSUM_2_9.py.

Changes:
- Add app-ready-pattern: "APP STATUS: Starting event loop" to the
  CI block (required for request_device_reboot()).
- Replace the step 7 dispatch with await self.request_device_reboot().
- Drop the step 8 is_pics_sdk_ci_only guard -- verification is now
  unconditional (always runs in both CI and manual modes).
- Update docstring to reference the framework helper + TC_AVSUM_2_9.py
  instead of the old dispatch.
CI on PR project-chip#72321 flagged the pre-reboot diagnostic log.info() call as
G004 ("Logging statement uses f-string"). Switch to lazy %-style
positional formatting, which is the upstream-preferred shape.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants