Skip to content

Commit

Permalink
[Python] Re-enable multi fabric tests (project-chip#16700)
Browse files Browse the repository at this point in the history
* [Python] Re-enable multi fabric tests

* Fix

* Fix
  • Loading branch information
erjiaqing authored Mar 29, 2022
1 parent 514af46 commit a19de20
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
16 changes: 8 additions & 8 deletions src/controller/python/test/test_scripts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,14 @@ async def TestMultiFabric(self, ip: str, setuppin: int, nodeid: int):
await self.devCtrl.SendCommand(nodeid, 0, Clusters.AdministratorCommissioning.Commands.OpenBasicCommissioningWindow(100), timedRequestTimeoutMs=10000)

self.logger.info("Creating 2nd Fabric Admin")
fabricAdmin2 = chip.FabricAdmin.FabricAdmin(fabricId=2, fabricIndex=2)
self.fabricAdmin2 = chip.FabricAdmin.FabricAdmin(
fabricId=2, fabricIndex=2)

self.logger.info("Creating Device Controller on 2nd Fabric")
devCtrl2 = fabricAdmin2.NewController(
self.devCtrl2 = self.fabricAdmin2.NewController(
self.controllerNodeId, self.paaTrustStorePath)

if not devCtrl2.CommissionIP(ip.encode("utf-8"), setuppin, nodeid):
if not self.devCtrl2.CommissionIP(ip.encode("utf-8"), setuppin, nodeid):
self.logger.info(
"Failed to finish key exchange with device {}".format(ip))
return False
Expand Down Expand Up @@ -303,16 +304,15 @@ async def TestMultiFabric(self, ip: str, setuppin: int, nodeid: int):
data2 = await self.devCtrl2.ReadAttribute(nodeid, [(Clusters.OperationalCredentials.Attributes.CurrentFabricIndex)], fabricFiltered=False)

# Read out current fabric from each fabric, and both should be different.
currentFabric1 = data1[0][Clusters.OperationalCredentials][Clusters.OperationalCredentials.Attributes.CurrentFabricIndex]
currentFabric2 = data2[0][Clusters.OperationalCredentials][Clusters.OperationalCredentials.Attributes.CurrentFabricIndex]
self.currentFabric1 = data1[0][Clusters.OperationalCredentials][
Clusters.OperationalCredentials.Attributes.CurrentFabricIndex]
self.currentFabric2 = data2[0][Clusters.OperationalCredentials][
Clusters.OperationalCredentials.Attributes.CurrentFabricIndex]
if (self.currentFabric1 == self.currentFabric2):
self.logger.error(
"Got back fabric indices that match for two different fabrics!")
return False

# devCtrl2.Shutdown()
# fabricAdmin2.Shutdown()

return True

async def TestFabricSensitive(self, nodeid: int):
Expand Down
7 changes: 3 additions & 4 deletions src/controller/python/test/test_scripts/cluster_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import chip.interaction_model
import asyncio
import time
import sys

import base

Expand Down Expand Up @@ -258,12 +259,10 @@ async def TestReadAttributeRequests(cls, devCtrl):
res = await devCtrl.ReadAttribute(nodeid=NODE_ID, attributes=[(0, Clusters.OperationalCredentials.Attributes.CurrentFabricIndex)])
fabricIndex = res[0][Clusters.OperationalCredentials][Clusters.OperationalCredentials.Attributes.CurrentFabricIndex]

#
# TODO: Enable this back once Issue #15688 has been resolved.
#
# Note: ListFabricScoped is an empty list for now. We should re-enable this test after we make it return expected data.
# logger.info("8: Read without fabric filter")
# res = await devCtrl.ReadAttribute(nodeid=NODE_ID, attributes=[(1, Clusters.TestCluster.Attributes.ListFabricScoped)], fabricFiltered=False)
# if len(res[1][Clusters.TestCluster][Clusters.TestCluster.Attributes.ListFabricScoped]) != 1:
# if len(res[1][Clusters.TestCluster][Clusters.TestCluster.Attributes.ListFabricScoped]) == 1:
# raise AssertionError("Expect more elements in the response")
# logger.info("9: Read with fabric filter")
# res = await devCtrl.ReadAttribute(nodeid=NODE_ID, attributes=[(1, Clusters.TestCluster.Attributes.ListFabricScoped)], fabricFiltered=True)
Expand Down
16 changes: 5 additions & 11 deletions src/controller/python/test/test_scripts/mobile-device-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,9 @@ def ethernet_commissioning(test: BaseTestHelper, discriminator: int, setup_pin:
nodeid=device_nodeid),
"Failed to finish key exchange")

#
# Disable this test for now since it's exposing some bugs
# in the underlying minimal mDNS component on Linux and triggering crashes.
#
# Issue: #15688
#
# asyncio.run(test.TestMultiFabric(ip=address.decode("utf-8"),
# setuppin=20202021,
# nodeid=1))
asyncio.run(test.TestMultiFabric(ip=address,
setuppin=20202021,
nodeid=1))
#
# The server will crash if we are aborting / closing it too fast.
# Issue: #15987
Expand Down Expand Up @@ -149,8 +143,8 @@ def TestDatamodel(test: BaseTestHelper, device_nodeid: int):
endpoint=LIGHTING_ENDPOINT_ID,
group=GROUP_ID), "Failed to test on off cluster")

# logger.info("Testing writing/reading fabric sensitive data")
# asyncio.run(test.TestFabricSensitive(nodeid=device_nodeid))
logger.info("Testing writing/reading fabric sensitive data")
asyncio.run(test.TestFabricSensitive(nodeid=device_nodeid))


def do_tests(controller_nodeid, device_nodeid, address, timeout, discriminator, setup_pin, paa_trust_store_path):
Expand Down

0 comments on commit a19de20

Please sign in to comment.