@@ -54,47 +54,39 @@ class TC_DGGEN_2_1_Py(MatterBaseTest):
5454 - NetworkInterfaces validated in code
5555 - TotalOperationalHours: verify >2 (manual precondition) and post-factory reset <=1
5656 """
57+ DEFAULT_NODE_ID = 0x12344321
5758
5859 def desc_TC_DGGEN_2_1_Py (self ) -> str :
59- return "[TC-DGGEN-2.1] Attributes (Server) — Pythonized + tweaks - REQUIRES device running >2h without factory reset"
60+ return "[TC-DGGEN-2.1] Attributes (Server) — Python version + tweaks - REQUIRES device running >2h without factory reset"
6061
6162 def pics_TC_DGGEN_2_1_Py (self ):
6263 return ["DGGEN.S" ]
6364
6465 def steps_TC_DGGEN_2_1_Py (self ) -> List [TestStep ]:
6566 return [
66- TestStep (0 , "Manual pre-check: Device in use >2h without factory reset (tester confirms)" ),
6767 TestStep (1 , "Read TotalOperationalHours and verify >2" ),
6868 TestStep (2 , "Step 2a mod: Read and save RebootCount (boot_count1)" ),
6969 TestStep (3 , "Step 4a/4b: Read UpTime (uptime1), wait 10s, read UpTime (uptime2) and verify uptime2 >= uptime1" ),
7070 TestStep (4 , "Step 4c: Reboot DUT (manual/automated according to your environment), wait for reconnection" ),
7171 TestStep (5 , "Step 2b mod: Read RebootCount and verify boot_count == boot_count1 + 1" ),
7272 TestStep (6 , "UpTime post-reboot (uptime3) < uptime2" ),
7373 TestStep (7 , "Step 3 mod: Programmatically validate NetworkInterfaces" ),
74- TestStep (8 , "Factory reset (manual), re-commission, verify TotalOperationalHours <= 1" , is_commissioning = True ),
74+ TestStep (8 , "Factory reset (manual), re-commission, verify TotalOperationalHours <= 1" ),
7575 ]
7676
7777 # ------- helpers -------
7878
79- async def _read_attr (self , dev_ctrl , cluster_attr , endpoint = None , node_id = None ):
80- return await self .read_single_attribute (
81- dev_ctrl = dev_ctrl ,
82- node_id = node_id if node_id is not None else self .req_node_id ,
83- endpoint = endpoint if endpoint is not None else self .endpoint ,
84- attribute = cluster_attr
85- )
86-
8779 async def _read_reboot_count (self , dev_ctrl ) -> int :
88- return int ( await self ._read_attr (dev_ctrl , Clusters .GeneralDiagnostics .Attributes .RebootCount ) )
80+ return await self .read_single_attribute_check_success (dev_ctrl , Clusters .GeneralDiagnostics .Attributes .RebootCount )
8981
9082 async def _read_uptime (self , dev_ctrl ) -> int :
91- return int ( await self ._read_attr (dev_ctrl , Clusters .GeneralDiagnostics .Attributes .UpTime ) )
83+ return await self .read_single_attribute_check_success (dev_ctrl , Clusters .GeneralDiagnostics .Attributes .UpTime )
9284
9385 async def _read_total_hrs (self , dev_ctrl ) -> int :
94- return int ( await self ._read_attr (dev_ctrl , Clusters .GeneralDiagnostics .Attributes .TotalOperationalHours ) )
86+ return await self .read_single_attribute_check_success (dev_ctrl , Clusters .GeneralDiagnostics .Attributes .TotalOperationalHours )
9587
9688 async def _read_net_ifaces (self , dev_ctrl ):
97- return await self ._read_attr (dev_ctrl , Clusters .GeneralDiagnostics .Attributes .NetworkInterfaces )
89+ return await self .read_single_attribute_check_success (dev_ctrl , Clusters .GeneralDiagnostics .Attributes .NetworkInterfaces )
9890
9991 async def _wait_for_commissionee (self , node_id = None , timeout_s = 120 ):
10092 # If your harness has a specific helper, replace this.
@@ -151,52 +143,27 @@ def _validate_network_interfaces(self, interfaces) -> None:
151143 @async_test_body
152144 async def test_TC_DGGEN_2_1_Py (self ):
153145 self .endpoint = self .get_endpoint (0 )
154- self .req_node_id = self .user_params .get ('req_node_id' , 0x12344321 )
146+ self .req_node_id = self .user_params .get ('req_node_id' , self . DEFAULT_NODE_ID )
155147
156148 ctrl = self .default_controller
157149
158- # IMPORTANT: This test requires the device to have been running for >2 hours without factory reset
159- logging .info ("=" * 80 )
160- logging .info ("IMPORTANT PRECONDITION: This test requires the device to have been running" )
161- logging .info ("for MORE THAN 2 HOURS without factory reset. If this condition is not met," )
162- logging .info ("the test will FAIL. You can run other tests in the meantime as long as" )
163- logging .info ("you don't factory reset the device." )
164- logging .info ("=" * 80 )
165-
166150 # CI-specific setup: Set uptime > 2 hours for CI testing
167151 if self .is_pics_sdk_ci_only :
168152 logging .info ("CI environment detected - setting uptime > 2 hours via named pipe" )
169153 # Set TotalOperationalHours to 3 hours for CI testing
170154 self .write_to_app_pipe ({"Name" : "SetTotalOperationalHours" , "Hours" : 3 })
171155 logging .info ("Uptime manipulation completed for CI" )
172156
173- # Wait a moment for the command to be processed
174- await asyncio .sleep (5.0 )
175-
176- # Verify the setting worked - this is critical for the test
177- total_hrs_check = await self ._read_total_hrs (ctrl )
178- logging .info (f"TotalOperationalHours after setting: { total_hrs_check } " )
179- if total_hrs_check < 2 :
180- logging .error ("CRITICAL: Failed to set TotalOperationalHours via named pipe!" )
181- logging .error ("The SetTotalOperationalHours command handler may not be implemented in the app." )
182- logging .error ("This test requires the device to have been running for >2 hours." )
183- logging .error ("Please ensure the all-clusters-app has the SetTotalOperationalHours command handler." )
184- asserts .fail ("Failed to set TotalOperationalHours via named pipe - command handler not working" )
185-
186- # Step 0: Manual precondition
187- self .step (0 )
188- logging .info (
189- "[Manual] Confirm: the DUT was in use >2h WITHOUT recent factory reset. "
190- "If not, retry later."
191- )
192-
193157 # Step 1: TotalOperationalHours > 2
194158 self .step (1 )
195159 total_hrs = await self ._read_total_hrs (ctrl )
196160 logging .info (f"TotalOperationalHours (pre): { total_hrs } " )
197-
198- # This assertion MUST pass - the test is designed to verify devices that have been running >2 hours
199- assert total_hrs > 2 , f"Precondition not met: TotalOperationalHours={ total_hrs } <= 2. Device must have been in use for more than 2 hours without factory reset."
161+ asserts .assert_greater (total_hrs , 2 , (
162+ f"Precondition not met: TotalOperationalHours={ total_hrs } <= 2. "
163+ "This test requires the device to have been running for MORE THAN 2 HOURS "
164+ "without factory reset. If this condition is not met, the test will FAIL. "
165+ "You can run other tests in the meantime as long as you don't factory reset the device."
166+ ))
200167 logging .info ("Precondition met: TotalOperationalHours > 2" )
201168
202169 # Step 2: 2a mod — save RebootCount (without requiring value)
@@ -223,8 +190,7 @@ async def test_TC_DGGEN_2_1_Py(self):
223190
224191 # After manual reboot, expire previous sessions so that we can re-establish connections
225192 logging .info ("Expiring sessions after manual device reboot" )
226- self .th1 .ExpireSessions (self .dut_node_id )
227- self .th2 .ExpireSessions (self .dut_node_id )
193+ self .default_controller .ExpireSessions (self .dut_node_id )
228194 logging .info ("Manual device reboot completed" )
229195
230196 else :
@@ -239,8 +205,7 @@ async def test_TC_DGGEN_2_1_Py(self):
239205 time .sleep (1 )
240206
241207 # Expire sessions and re-establish connections
242- self .th1 .ExpireSessions (self .dut_node_id )
243- self .th2 .ExpireSessions (self .dut_node_id )
208+ self .default_controller .ExpireSessions (self .dut_node_id )
244209
245210 logging .info ("App restart completed successfully" )
246211
@@ -268,11 +233,12 @@ async def test_TC_DGGEN_2_1_Py(self):
268233
269234 # Step 8: Factory reset (manual), re-commission, TotalOperationalHours <= 1
270235 self .step (8 )
271- logging .info (
272- "[Required action] Perform Factory Reset of the DUT and re-commission it in this fabric. "
273- "Then continue; the test will wait for the DUT to be accessible."
274- )
275- await self ._wait_for_commissionee (timeout_s = 240 )
236+ self .wait_for_user_input (prompt_msg = "Perform Factory Reset of the DUT, then press Enter to continue." )
237+
238+ # Re-commission the device after factory reset
239+ logging .info ("Re-commissioning DUT after factory reset" )
240+ commissioned = await self .commission_devices ()
241+ asserts .assert_true (commissioned , "Failed to re-commission DUT after factory reset" )
276242
277243 total_hrs_after_fr = await self ._read_total_hrs (ctrl )
278244 logging .info (f"TotalOperationalHours post-factory-reset: { total_hrs_after_fr } " )
0 commit comments