Skip to content

Commit b90334a

Browse files
authored
[Fabric Sync] Update test to run a little faster (project-chip#36082)
1 parent 34d633c commit b90334a

File tree

3 files changed

+52
-25
lines changed

3 files changed

+52
-25
lines changed

src/python_testing/TC_CCTRL_2_2.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ def steps_TC_CCTRL_2_2(self) -> list[TestStep]:
138138
TestStep(24, "Reading Event CommissioningRequestResult from DUT, confirm one new event"),
139139
TestStep(25, "Send CommissionNode command to DUT with CASE session, with valid parameters"),
140140
TestStep(26, "Send OpenCommissioningWindow command on Administrator Commissioning Cluster sent to TH_SERVER"),
141-
TestStep(27, "Wait for DUT to successfully commission TH_SERVER, 30 seconds"),
142-
TestStep(28, "Get number of fabrics from TH_SERVER, verify DUT successfully commissioned TH_SERVER")]
141+
TestStep(27, "Get number of fabrics from TH_SERVER, verify DUT successfully commissioned TH_SERVER (up to 30 seconds)")]
143142

144143
return steps
145144

@@ -317,15 +316,22 @@ async def test_TC_CCTRL_2_2(self):
317316
await self.send_single_cmd(cmd, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, timedRequestTimeoutMs=5000)
318317

319318
self.step(27)
320-
if not self.is_pics_sdk_ci_only:
321-
time.sleep(30)
322-
323-
self.step(28)
324-
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)
325-
# TODO: this should be mocked too.
326-
if not self.is_pics_sdk_ci_only:
327-
asserts.assert_equal(len(th_server_fabrics) + 1, len(th_server_fabrics_new),
328-
"Unexpected number of fabrics on TH_SERVER")
319+
max_wait_time_sec = 30
320+
start_time = time.time()
321+
elapsed = 0
322+
time_remaining = max_wait_time_sec
323+
previous_number_th_server_fabrics = len(th_server_fabrics_new)
324+
325+
while time_remaining > 0:
326+
time.sleep(2)
327+
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)
328+
if previous_number_th_server_fabrics != len(th_server_fabrics_new):
329+
break
330+
elapsed = time.time() - start_time
331+
time_remaining = max_wait_time_sec - elapsed
332+
333+
asserts.assert_equal(previous_number_th_server_fabrics + 1, len(th_server_fabrics_new),
334+
"Unexpected number of fabrics on TH_SERVER")
329335

330336

331337
if __name__ == "__main__":

src/python_testing/TC_CCTRL_2_3.py

+18-7
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ def steps_TC_CCTRL_2_3(self) -> list[TestStep]:
122122
TestStep(8, "Send CommissionNode command to DUT with CASE session, with valid parameters"),
123123
TestStep(9, "Send another CommissionNode command to DUT with CASE session, with with same RequestId as the previous one"),
124124
TestStep(10, "Send OpenCommissioningWindow command on Administrator Commissioning Cluster sent to TH_SERVER"),
125-
TestStep(11, "Wait for DUT to successfully commission TH_SERVER, 30 seconds"),
126-
TestStep(12, "Get number of fabrics from TH_SERVER, verify DUT successfully commissioned TH_SERVER")]
125+
TestStep(11, "Get number of fabrics from TH_SERVER, verify DUT successfully commissioned TH_SERVER (up to 30 seconds)")]
127126

128127
return steps
129128

@@ -196,11 +195,23 @@ async def test_TC_CCTRL_2_3(self):
196195
await self.send_single_cmd(cmd, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, timedRequestTimeoutMs=5000)
197196

198197
self.step(11)
199-
time.sleep(5 if self.is_pics_sdk_ci_only else 30)
200-
201-
self.step(12)
202-
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)
203-
asserts.assert_equal(len(th_server_fabrics) + 1, len(th_server_fabrics_new),
198+
max_wait_time_sec = 30
199+
start_time = time.time()
200+
elapsed = 0
201+
time_remaining = max_wait_time_sec
202+
previous_number_th_server_fabrics = len(th_server_fabrics)
203+
204+
th_server_fabrics_new = None
205+
while time_remaining > 0:
206+
time.sleep(2)
207+
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)
208+
if previous_number_th_server_fabrics != len(th_server_fabrics_new):
209+
break
210+
elapsed = time.time() - start_time
211+
time_remaining = max_wait_time_sec - elapsed
212+
213+
asserts.assert_not_equal(th_server_fabrics_new, None, "Failed to read Fabrics attribute")
214+
asserts.assert_equal(previous_number_th_server_fabrics + 1, len(th_server_fabrics_new),
204215
"Unexpected number of fabrics on TH_SERVER")
205216

206217

src/python_testing/TC_MCORE_FS_1_1.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,24 @@ async def test_TC_MCORE_FS_1_1(self):
199199
await self.send_single_cmd(cmd, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, timedRequestTimeoutMs=5000)
200200

201201
self.step("3c")
202-
if not self.is_pics_sdk_ci_only:
203-
time.sleep(30)
202+
max_wait_time_sec = 30
203+
start_time = time.time()
204+
elapsed = 0
205+
time_remaining = max_wait_time_sec
206+
previous_number_th_server_fabrics = len(th_fsa_server_fabrics)
207+
208+
th_fsa_server_fabrics_new = None
209+
while time_remaining > 0:
210+
time.sleep(2)
211+
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)
212+
if previous_number_th_server_fabrics != len(th_fsa_server_fabrics_new):
213+
break
214+
elapsed = time.time() - start_time
215+
time_remaining = max_wait_time_sec - elapsed
204216

205-
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)
206-
# TODO: this should be mocked too.
207-
if not self.is_pics_sdk_ci_only:
208-
asserts.assert_equal(len(th_fsa_server_fabrics) + 1, len(th_fsa_server_fabrics_new),
209-
"Unexpected number of fabrics on TH_SERVER")
217+
asserts.assert_not_equal(th_fsa_server_fabrics_new, None, "Failed to read Fabrics attribute")
218+
asserts.assert_equal(previous_number_th_server_fabrics + 1, len(th_fsa_server_fabrics_new),
219+
"Unexpected number of fabrics on TH_SERVER")
210220

211221

212222
if __name__ == "__main__":

0 commit comments

Comments
 (0)