From b046a7be85ae39d4ba9eafff71dadcd4e7bf95f7 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 7 May 2024 15:43:46 +0200 Subject: [PATCH] Make TestSubscriptionResumptionCapacityStep2 an async test Eliminate use of ZCLSubscribeAttribute and embrace asyncio. --- src/controller/python/test/test_scripts/base.py | 9 +++++---- .../subscription_resumption_capacity_test_ctrl2.py | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/controller/python/test/test_scripts/base.py b/src/controller/python/test/test_scripts/base.py index c23d443d6b3143..884a1a2ae58305 100644 --- a/src/controller/python/test/test_scripts/base.py +++ b/src/controller/python/test/test_scripts/base.py @@ -1453,8 +1453,8 @@ async def TestSubscriptionResumptionCapacityStep1(self, nodeid: int, endpoint: i return True - def TestSubscriptionResumptionCapacityStep2(self, nodeid: int, endpoint: int, remote_ip: str, ssh_port: int, - remote_server_app: str, subscription_capacity: int): + async def TestSubscriptionResumptionCapacityStep2(self, nodeid: int, endpoint: int, remote_ip: str, ssh_port: int, + remote_server_app: str, subscription_capacity: int): try: self.logger.info("Restart remote deivce") extra_agrs = f"--thread --discriminator 3840 --subscription-capacity {subscription_capacity}" @@ -1468,8 +1468,9 @@ def TestSubscriptionResumptionCapacityStep2(self, nodeid: int, endpoint: int, re self.logger.info("Send a new subscription request from the second controller") # Close previous session so that the second controller will res-establish the session with the remote device self.devCtrl.CloseSession(nodeid) - 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) if restartRemoteThread.is_alive(): # Thread join timed out diff --git a/src/controller/python/test/test_scripts/subscription_resumption_capacity_test_ctrl2.py b/src/controller/python/test/test_scripts/subscription_resumption_capacity_test_ctrl2.py index 2f3058afcd3bca..ac449a9f5478ac 100755 --- a/src/controller/python/test/test_scripts/subscription_resumption_capacity_test_ctrl2.py +++ b/src/controller/python/test/test_scripts/subscription_resumption_capacity_test_ctrl2.py @@ -19,6 +19,7 @@ # Commissioning test. +import asyncio import os import sys from optparse import OptionParser @@ -125,8 +126,9 @@ def main(): "Failed on on-network commissioing") FailIfNot( - test.TestSubscriptionResumptionCapacityStep2(options.nodeid, TEST_ENDPOINT_ID, options.deviceAddress, - TEST_SSH_PORT, options.remoteServerApp, options.subscriptionCapacity), + asyncio.run( + test.TestSubscriptionResumptionCapacityStep2(options.nodeid, TEST_ENDPOINT_ID, options.deviceAddress, + TEST_SSH_PORT, options.remoteServerApp, options.subscriptionCapacity)), "Failed on testing subscription resumption capacity") timeoutTicker.stop()