[HOTFIX] Fix hermeticity of TC-CGEN scripts in CI (#38551)
* Fix hermeticity of TC-CGEN scripts in CI
- The scripts did not factory reset properly so they were
impacted by lack of hermeticity, causing a failure of CGEN-2.9
after unrelated master changes.
- The method to find "commissioner's fabric" before some fabric
removal was wrong in CGEN-2.9. Fixed the method to use CurrentFabricIndex
* Add logging
* Restyled by autopep8
* Update src/python_testing/TC_CGEN_2_9.py
---------
Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/src/python_testing/TC_CGEN_2_10.py b/src/python_testing/TC_CGEN_2_10.py
index 6bc7e1b..e574bb3 100644
--- a/src/python_testing/TC_CGEN_2_10.py
+++ b/src/python_testing/TC_CGEN_2_10.py
@@ -31,7 +31,7 @@
# --tc-user-response-to-simulate 1
# --qr-code MT:-24J0AFN00KA0648G00
# --trace-to json:log
-# factoryreset: True
+# factory-reset: true
# quiet: True
# === END CI TEST ARGUMENTS ===
diff --git a/src/python_testing/TC_CGEN_2_11.py b/src/python_testing/TC_CGEN_2_11.py
index f5c32cf..b7e5370 100644
--- a/src/python_testing/TC_CGEN_2_11.py
+++ b/src/python_testing/TC_CGEN_2_11.py
@@ -32,7 +32,7 @@
# --int-arg PIXIT.CGEN.TCRevision:1
# --qr-code MT:-24J0AFN00KA0648G00
# --trace-to json:log
-# factoryreset: True
+# factory-reset: true
# quiet: True
# === END CI TEST ARGUMENTS ===
diff --git a/src/python_testing/TC_CGEN_2_5.py b/src/python_testing/TC_CGEN_2_5.py
index e5b8fc5..29fe600 100644
--- a/src/python_testing/TC_CGEN_2_5.py
+++ b/src/python_testing/TC_CGEN_2_5.py
@@ -32,7 +32,7 @@
# --int-arg PIXIT.CGEN.TCRevision:1
# --qr-code MT:-24J0AFN00KA0648G00
# --trace-to json:log
-# factoryreset: True
+# factory-reset: true
# quiet: True
# === END CI TEST ARGUMENTS ===
diff --git a/src/python_testing/TC_CGEN_2_6.py b/src/python_testing/TC_CGEN_2_6.py
index b9e4c3d..f94b240 100644
--- a/src/python_testing/TC_CGEN_2_6.py
+++ b/src/python_testing/TC_CGEN_2_6.py
@@ -29,7 +29,7 @@
# --in-test-commissioning-method on-network
# --qr-code MT:-24J0AFN00KA0648G00
# --trace-to json:log
-# factoryreset: True
+# factory-reset: true
# quiet: True
# === END CI TEST ARGUMENTS ===
diff --git a/src/python_testing/TC_CGEN_2_7.py b/src/python_testing/TC_CGEN_2_7.py
index dbc8aa3..1bcc193 100644
--- a/src/python_testing/TC_CGEN_2_7.py
+++ b/src/python_testing/TC_CGEN_2_7.py
@@ -32,7 +32,7 @@
# --int-arg PIXIT.CGEN.TCRevision:1
# --qr-code MT:-24J0AFN00KA0648G00
# --trace-to json:log
-# factoryreset: True
+# factory-reset: true
# quiet: True
# === END CI TEST ARGUMENTS ===
diff --git a/src/python_testing/TC_CGEN_2_8.py b/src/python_testing/TC_CGEN_2_8.py
index feed2ff..8067856 100644
--- a/src/python_testing/TC_CGEN_2_8.py
+++ b/src/python_testing/TC_CGEN_2_8.py
@@ -32,7 +32,7 @@
# --int-arg PIXIT.CGEN.TCRevision:1
# --qr-code MT:-24J0AFN00KA0648G00
# --trace-to json:log
-# factoryreset: True
+# factory-reset: true
# quiet: True
# === END CI TEST ARGUMENTS ===
diff --git a/src/python_testing/TC_CGEN_2_9.py b/src/python_testing/TC_CGEN_2_9.py
index cc2cbec..c18a781 100644
--- a/src/python_testing/TC_CGEN_2_9.py
+++ b/src/python_testing/TC_CGEN_2_9.py
@@ -32,10 +32,12 @@
# --int-arg PIXIT.CGEN.TCRevision:1
# --qr-code MT:-24J0AFN00KA0648G00
# --trace-to json:log
-# factoryreset: True
+# factory-reset: true
# quiet: True
# === END CI TEST ARGUMENTS ===
+import logging
+
import chip.clusters as Clusters
from chip import ChipDeviceCtrl
from chip.commissioning import ROOT_ENDPOINT_ID
@@ -48,18 +50,27 @@
async def remove_commissioner_fabric(self):
commissioner: ChipDeviceCtrl.ChipDeviceController = self.default_controller
+ commissioner_fabric_index_on_dut = await self.read_single_attribute(
+ dev_ctrl=commissioner,
+ node_id=self.dut_node_id,
+ endpoint=ROOT_ENDPOINT_ID,
+ attribute=Clusters.OperationalCredentials.Attributes.CurrentFabricIndex)
+ logging.info(f"Commissioner's fabricIndex on DUT: {commissioner_fabric_index_on_dut}")
+
fabrics: list[Clusters.OperationalCredentials.Structs.FabricDescriptorStruct] = await self.read_single_attribute(
dev_ctrl=commissioner,
node_id=self.dut_node_id,
endpoint=ROOT_ENDPOINT_ID,
attribute=Clusters.OperationalCredentials.Attributes.Fabrics)
+ logging.info(f"Fabrics table on DUT: {fabrics}")
# Re-order the list of fabrics so that the test harness admin fabric is removed last
- commissioner_fabric = next((fabric for fabric in fabrics if fabric.fabricIndex == commissioner.fabricId), None)
+ commissioner_fabric = next((fabric for fabric in fabrics if fabric.fabricIndex == commissioner_fabric_index_on_dut), None)
fabrics.remove(commissioner_fabric)
fabrics.append(commissioner_fabric)
for fabric in fabrics:
+ logging.info(f"Removing fabric at fabricIndex {fabric.fabricIndex}")
response: Clusters.OperationalCredentials.Commands.NOCResponse = await commissioner.SendCommand(
nodeid=self.dut_node_id,
endpoint=ROOT_ENDPOINT_ID,