Skip to content

Commit

Permalink
Make TestSubscriptionResumptionCapacityStep2 an async test
Browse files Browse the repository at this point in the history
Eliminate use of ZCLSubscribeAttribute and embrace asyncio.
  • Loading branch information
agners committed May 7, 2024
1 parent c7cc3d8 commit b046a7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/controller/python/test/test_scripts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

# Commissioning test.

import asyncio
import os
import sys
from optparse import OptionParser
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit b046a7b

Please sign in to comment.