Skip to content

Commit

Permalink
Make TestSubscriptionResumptionCapacityStep1 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 c9b88fe commit c7cc3d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/controller/python/test/test_scripts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
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 @@ -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()
Expand Down

0 comments on commit c7cc3d8

Please sign in to comment.