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