[Fabric Sync] Update test to run a little faster (#36082)
diff --git a/src/python_testing/TC_CCTRL_2_2.py b/src/python_testing/TC_CCTRL_2_2.py
index a2e7b15..1bc403a 100644
--- a/src/python_testing/TC_CCTRL_2_2.py
+++ b/src/python_testing/TC_CCTRL_2_2.py
@@ -138,8 +138,7 @@
TestStep(24, "Reading Event CommissioningRequestResult from DUT, confirm one new event"),
TestStep(25, "Send CommissionNode command to DUT with CASE session, with valid parameters"),
TestStep(26, "Send OpenCommissioningWindow command on Administrator Commissioning Cluster sent to TH_SERVER"),
- TestStep(27, "Wait for DUT to successfully commission TH_SERVER, 30 seconds"),
- TestStep(28, "Get number of fabrics from TH_SERVER, verify DUT successfully commissioned TH_SERVER")]
+ TestStep(27, "Get number of fabrics from TH_SERVER, verify DUT successfully commissioned TH_SERVER (up to 30 seconds)")]
return steps
@@ -317,15 +316,22 @@
await self.send_single_cmd(cmd, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, timedRequestTimeoutMs=5000)
self.step(27)
- if not self.is_pics_sdk_ci_only:
- time.sleep(30)
+ max_wait_time_sec = 30
+ start_time = time.time()
+ elapsed = 0
+ time_remaining = max_wait_time_sec
+ previous_number_th_server_fabrics = len(th_server_fabrics_new)
- self.step(28)
- th_server_fabrics_new = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.Fabrics, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, fabric_filtered=False)
- # TODO: this should be mocked too.
- if not self.is_pics_sdk_ci_only:
- asserts.assert_equal(len(th_server_fabrics) + 1, len(th_server_fabrics_new),
- "Unexpected number of fabrics on TH_SERVER")
+ while time_remaining > 0:
+ time.sleep(2)
+ th_server_fabrics_new = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.Fabrics, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, fabric_filtered=False)
+ if previous_number_th_server_fabrics != len(th_server_fabrics_new):
+ break
+ elapsed = time.time() - start_time
+ time_remaining = max_wait_time_sec - elapsed
+
+ asserts.assert_equal(previous_number_th_server_fabrics + 1, len(th_server_fabrics_new),
+ "Unexpected number of fabrics on TH_SERVER")
if __name__ == "__main__":
diff --git a/src/python_testing/TC_CCTRL_2_3.py b/src/python_testing/TC_CCTRL_2_3.py
index fe7ed3d..83c2529 100644
--- a/src/python_testing/TC_CCTRL_2_3.py
+++ b/src/python_testing/TC_CCTRL_2_3.py
@@ -122,8 +122,7 @@
TestStep(8, "Send CommissionNode command to DUT with CASE session, with valid parameters"),
TestStep(9, "Send another CommissionNode command to DUT with CASE session, with with same RequestId as the previous one"),
TestStep(10, "Send OpenCommissioningWindow command on Administrator Commissioning Cluster sent to TH_SERVER"),
- TestStep(11, "Wait for DUT to successfully commission TH_SERVER, 30 seconds"),
- TestStep(12, "Get number of fabrics from TH_SERVER, verify DUT successfully commissioned TH_SERVER")]
+ TestStep(11, "Get number of fabrics from TH_SERVER, verify DUT successfully commissioned TH_SERVER (up to 30 seconds)")]
return steps
@@ -196,11 +195,23 @@
await self.send_single_cmd(cmd, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, timedRequestTimeoutMs=5000)
self.step(11)
- time.sleep(5 if self.is_pics_sdk_ci_only else 30)
+ max_wait_time_sec = 30
+ start_time = time.time()
+ elapsed = 0
+ time_remaining = max_wait_time_sec
+ previous_number_th_server_fabrics = len(th_server_fabrics)
- self.step(12)
- th_server_fabrics_new = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.Fabrics, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, fabric_filtered=False)
- asserts.assert_equal(len(th_server_fabrics) + 1, len(th_server_fabrics_new),
+ th_server_fabrics_new = None
+ while time_remaining > 0:
+ time.sleep(2)
+ th_server_fabrics_new = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.Fabrics, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, fabric_filtered=False)
+ if previous_number_th_server_fabrics != len(th_server_fabrics_new):
+ break
+ elapsed = time.time() - start_time
+ time_remaining = max_wait_time_sec - elapsed
+
+ asserts.assert_not_equal(th_server_fabrics_new, None, "Failed to read Fabrics attribute")
+ asserts.assert_equal(previous_number_th_server_fabrics + 1, len(th_server_fabrics_new),
"Unexpected number of fabrics on TH_SERVER")
diff --git a/src/python_testing/TC_MCORE_FS_1_1.py b/src/python_testing/TC_MCORE_FS_1_1.py
index 995a80c..780089b 100755
--- a/src/python_testing/TC_MCORE_FS_1_1.py
+++ b/src/python_testing/TC_MCORE_FS_1_1.py
@@ -199,14 +199,24 @@
await self.send_single_cmd(cmd, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, timedRequestTimeoutMs=5000)
self.step("3c")
- if not self.is_pics_sdk_ci_only:
- time.sleep(30)
+ max_wait_time_sec = 30
+ start_time = time.time()
+ elapsed = 0
+ time_remaining = max_wait_time_sec
+ previous_number_th_server_fabrics = len(th_fsa_server_fabrics)
- th_fsa_server_fabrics_new = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.Fabrics, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, fabric_filtered=False)
- # TODO: this should be mocked too.
- if not self.is_pics_sdk_ci_only:
- asserts.assert_equal(len(th_fsa_server_fabrics) + 1, len(th_fsa_server_fabrics_new),
- "Unexpected number of fabrics on TH_SERVER")
+ th_fsa_server_fabrics_new = None
+ while time_remaining > 0:
+ time.sleep(2)
+ th_fsa_server_fabrics_new = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.Fabrics, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, fabric_filtered=False)
+ if previous_number_th_server_fabrics != len(th_fsa_server_fabrics_new):
+ break
+ elapsed = time.time() - start_time
+ time_remaining = max_wait_time_sec - elapsed
+
+ asserts.assert_not_equal(th_fsa_server_fabrics_new, None, "Failed to read Fabrics attribute")
+ asserts.assert_equal(previous_number_th_server_fabrics + 1, len(th_fsa_server_fabrics_new),
+ "Unexpected number of fabrics on TH_SERVER")
if __name__ == "__main__":