From e1632f4a62b259019524be98be958168847aa5ff Mon Sep 17 00:00:00 2001 From: Song GUO Date: Tue, 29 Mar 2022 14:06:20 +0800 Subject: [PATCH] [Python] Re-enable multi fabric tests (#16700) * [Python] Re-enable multi fabric tests * Fix * Fix --- src/controller/python/test/test_scripts/base.py | 16 ++++++++-------- .../python/test/test_scripts/cluster_objects.py | 7 +++---- .../test/test_scripts/mobile-device-test.py | 16 +++++----------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/controller/python/test/test_scripts/base.py b/src/controller/python/test/test_scripts/base.py index b6cb22093a7955..b1dd8bd8dd6365 100644 --- a/src/controller/python/test/test_scripts/base.py +++ b/src/controller/python/test/test_scripts/base.py @@ -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 @@ -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): diff --git a/src/controller/python/test/test_scripts/cluster_objects.py b/src/controller/python/test/test_scripts/cluster_objects.py index 2586c1865a6f5f..8548a2e2bf0247 100644 --- a/src/controller/python/test/test_scripts/cluster_objects.py +++ b/src/controller/python/test/test_scripts/cluster_objects.py @@ -23,6 +23,7 @@ import chip.interaction_model import asyncio import time +import sys import base @@ -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) diff --git a/src/controller/python/test/test_scripts/mobile-device-test.py b/src/controller/python/test/test_scripts/mobile-device-test.py index 140633e0af0fa2..532cdea13e70a2 100755 --- a/src/controller/python/test/test_scripts/mobile-device-test.py +++ b/src/controller/python/test/test_scripts/mobile-device-test.py @@ -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 @@ -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):