@@ -1337,7 +1337,7 @@ def TestFabricScopedCommandDuringPase(self, nodeid: int):
1337
1337
1338
1338
return status == IM .Status .UnsupportedAccess
1339
1339
1340
- def TestSubscriptionResumption (self , nodeid : int , endpoint : int , remote_ip : str , ssh_port : int , remote_server_app : str ):
1340
+ async def TestSubscriptionResumption (self , nodeid : int , endpoint : int , remote_ip : str , ssh_port : int , remote_server_app : str ):
1341
1341
'''
1342
1342
This test validates that the device can resume the subscriptions after restarting.
1343
1343
It is executed in Linux Cirque tests and the steps of this test are:
@@ -1346,42 +1346,40 @@ def TestSubscriptionResumption(self, nodeid: int, endpoint: int, remote_ip: str,
1346
1346
3. Validate that the controller can receive a report from the remote server app
1347
1347
'''
1348
1348
desiredPath = None
1349
- receivedUpdate = False
1350
- updateLock = threading .Lock ()
1351
- updateCv = threading .Condition (updateLock )
1349
+ updateEvent = asyncio .Event ()
1350
+ loop = asyncio .get_running_loop ()
1352
1351
1353
1352
def OnValueReport (path : Attribute .TypedAttributePath , transaction : Attribute .SubscriptionTransaction ) -> None :
1354
- nonlocal desiredPath , updateCv , updateLock , receivedUpdate
1353
+ nonlocal desiredPath , updateEvent , receivedUpdate
1355
1354
if path .Path != desiredPath :
1356
1355
return
1357
1356
1358
1357
data = transaction .GetAttribute (path )
1359
1358
logger .info (
1360
1359
f"Received report from server: path: { path .Path } , value: { data } " )
1361
- with updateLock :
1362
- receivedUpdate = True
1363
- updateCv .notify_all ()
1360
+ loop .call_soon_threadsafe (updateEvent .set )
1364
1361
1365
1362
try :
1366
1363
desiredPath = Clusters .Attribute .AttributePath (
1367
1364
EndpointId = 0 , ClusterId = 0x28 , AttributeId = 5 )
1368
1365
# BasicInformation Cluster, NodeLabel Attribute
1369
- subscription = self .devCtrl .ZCLSubscribeAttribute (
1370
- "BasicInformation" , "NodeLabel" , nodeid , endpoint , 1 , 50 , keepSubscriptions = True , autoResubscribe = False )
1366
+ subscription = await self .devCtrl .ReadAttribute ( nodeid , [( endpoint , Clusters . BasicInformation . Attributes . NodeLabel )], None , False , reportInterval = ( 1 , 50 ),
1367
+ keepSubscriptions = True , autoResubscribe = False )
1371
1368
subscription .SetAttributeUpdateCallback (OnValueReport )
1372
1369
1373
- self .logger .info ("Restart remote deivce " )
1370
+ self .logger .info ("Restart remote device " )
1374
1371
restartRemoteThread = restartRemoteDevice (
1375
1372
remote_ip , ssh_port , "root" , "admin" , remote_server_app , "--thread --discriminator 3840" )
1376
1373
restartRemoteThread .start ()
1377
1374
# After device restarts, the attribute will be set dirty so the subscription can receive
1378
1375
# the update
1379
- with updateCv :
1380
- while receivedUpdate is False :
1381
- if not updateCv .wait (10.0 ):
1382
- self .logger .error (
1383
- "Failed to receive subscription resumption report" )
1384
- break
1376
+ receivedUpdate = False
1377
+ try :
1378
+ await asyncio .wait_for (updateEvent .wait (), 10 )
1379
+ receivedUpdate = True
1380
+ except TimeoutError :
1381
+ self .logger .error (
1382
+ "Failed to receive subscription resumption report" )
1385
1383
1386
1384
restartRemoteThread .join (10.0 )
1387
1385
0 commit comments