From c7cc3d87ad08f3b2c253528f1219063278734e38 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 7 May 2024 15:42:20 +0200 Subject: [PATCH] Make TestSubscriptionResumptionCapacityStep1 an async test Eliminate use of ZCLSubscribeAttribute and embrace asyncio. --- src/controller/python/test/test_scripts/base.py | 11 ++++++----- .../subscription_resumption_capacity_test_ctrl1.py | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/controller/python/test/test_scripts/base.py b/src/controller/python/test/test_scripts/base.py index 0dd5186775b7c4..c23d443d6b3143 100644 --- a/src/controller/python/test/test_scripts/base.py +++ b/src/controller/python/test/test_scripts/base.py @@ -1425,25 +1425,26 @@ def OnValueReport(path: Attribute.TypedAttributePath, transaction: Attribute.Sub controller 1 in container 1 while the Step2 is executed in controller 2 in container 2 ''' - def TestSubscriptionResumptionCapacityStep1(self, nodeid: int, endpoint: int, passcode: int, subscription_capacity: int): + async def TestSubscriptionResumptionCapacityStep1(self, nodeid: int, endpoint: int, passcode: int, subscription_capacity: int): try: # BasicInformation Cluster, NodeLabel Attribute for i in range(subscription_capacity): - self.devCtrl.ZCLSubscribeAttribute( - "BasicInformation", "NodeLabel", nodeid, endpoint, 1, 50, keepSubscriptions=True, autoResubscribe=False) + await self.devCtrl.ReadAttribute(nodeid, [(endpoint, Clusters.BasicInformation.Attributes.NodeLabel)], None, + False, reportInterval=(1, 50), + keepSubscriptions=True, autoResubscribe=False) logger.info("Send OpenCommissioningWindow command on fist controller") discriminator = 3840 salt = secrets.token_bytes(16) iterations = 2000 verifier = GenerateVerifier(passcode, salt, iterations) - asyncio.run(self.devCtrl.SendCommand( + await self.devCtrl.SendCommand( nodeid, 0, Clusters.AdministratorCommissioning.Commands.OpenCommissioningWindow( commissioningTimeout=180, PAKEPasscodeVerifier=verifier, discriminator=discriminator, iterations=iterations, - salt=salt), timedRequestTimeoutMs=10000)) + salt=salt), timedRequestTimeoutMs=10000) return True except Exception as ex: diff --git a/src/controller/python/test/test_scripts/subscription_resumption_capacity_test_ctrl1.py b/src/controller/python/test/test_scripts/subscription_resumption_capacity_test_ctrl1.py index 19065b8a35396a..e02564e293c04a 100755 --- a/src/controller/python/test/test_scripts/subscription_resumption_capacity_test_ctrl1.py +++ b/src/controller/python/test/test_scripts/subscription_resumption_capacity_test_ctrl1.py @@ -19,6 +19,7 @@ # Commissioning test. +import asyncio import os import sys from optparse import OptionParser @@ -113,8 +114,8 @@ def main(): "Failed on on-network commissioing") FailIfNot( - test.TestSubscriptionResumptionCapacityStep1( - options.nodeid, TEST_ENDPOINT_ID, options.setuppin, options.subscriptionCapacity), + asyncio.run(test.TestSubscriptionResumptionCapacityStep1( + options.nodeid, TEST_ENDPOINT_ID, options.setuppin, options.subscriptionCapacity)), "Failed on step 1 of testing subscription resumption capacity") timeoutTicker.stop()