Skip to content

Commit 5f0ebed

Browse files
authored
Set timeout in JF test cases (project-chip#40019)
* Add timout in all send functions; set a global timeout for send function of 5 minutes * Shutdown controller in test cases; fix JCM_1_2 timeout error
1 parent 76c78b2 commit 5f0ebed

File tree

5 files changed

+27
-20
lines changed

5 files changed

+27
-20
lines changed

src/python_testing/TC_JCM_1_1.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ async def setup_class(self):
123123
# Commission JF-ADMIN app with JF-Controller on Fabric A
124124
self.fabric_a_ctrl.send(
125125
message=f"pairing onnetwork 1 {self.jfadmin_fabric_a_passcode} --anchor true",
126-
expected_output="[JF] Anchor Administrator commissioned with sucess")
126+
expected_output="[JF] Anchor Administrator commissioned with sucess",
127+
timeout=10)
127128

128129
# Extract the Ecosystem A certificates and inject them in the storage that will be provided to a new Python Controller later
129130
jfcStorage = ConfigParser()
@@ -182,7 +183,8 @@ async def setup_class(self):
182183
# Commission JF-ADMIN app with JF-Controller on Fabric B
183184
self.fabric_b_ctrl.send(
184185
message=f"pairing onnetwork 11 {self.jfadmin_fabric_b_passcode} --anchor true",
185-
expected_output="[JF] Anchor Administrator commissioned with sucess")
186+
expected_output="[JF] Anchor Administrator commissioned with sucess",
187+
timeout=10)
186188

187189
# Extract the Ecosystem B certificates and inject them in the storage that will be provided to a new Python Controller later
188190
jfcStorage = ConfigParser()
@@ -397,6 +399,10 @@ async def test_TC_JCM_1_1(self):
397399
response[0][Clusters.AccessControl].acl[0].subjects[0],
398400
"EcoA Server App Subjects field has wrong value")
399401

402+
# Shutdown the Python Controllers start at the begining
403+
devCtrlEcoA.Shutdown()
404+
devCtrlEcoB.Shutdown()
405+
400406

401407
if __name__ == "__main__":
402408
default_matter_test_main()

src/python_testing/TC_JCM_1_2.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ async def setup_class(self):
126126
# Commission JF-ADMIN app with JF-Controller on Fabric A
127127
self.fabric_a_ctrl.send(
128128
message=f"pairing onnetwork 1 {self.jfadmin_fabric_a_passcode} --anchor true",
129-
expected_output="[JF] Anchor Administrator commissioned with sucess")
129+
expected_output="[JF] Anchor Administrator commissioned with sucess",
130+
timeout=10)
130131

131132
# Extract the Ecosystem A certificates and inject them in the storage that will be provided to a new Python Controller later
132133
jfcStorage = ConfigParser()
@@ -186,7 +187,8 @@ async def setup_class(self):
186187
# Commission JF-ADMIN app with JF-Controller on Fabric B
187188
self.fabric_b_ctrl.send(
188189
message=f"pairing onnetwork 11 {self.jfadmin_fabric_b_passcode} --anchor true",
189-
expected_output="[JF] Anchor Administrator commissioned with sucess")
190+
expected_output="[JF] Anchor Administrator commissioned with sucess",
191+
timeout=10)
190192

191193
# Extract the Ecosystem B certificates and inject them in the storage that will be provided to a new Python Controller later
192194
jfcStorage = ConfigParser()
@@ -292,8 +294,7 @@ async def _joint_commission_EcoB_admin(self, devCtrl, nodeid, passcode, endpoint
292294
logging.info(f"Starting Joint Commissioning of Ecosystem B jfa-app with node ID {nodeid}")
293295

294296
devCtrl.send(
295-
message=f"pairing onnetwork {nodeid} {passcode} --execute-jcm true",
296-
expected_output="")
297+
message=f"pairing onnetwork {nodeid} {passcode} --execute-jcm true")
297298

298299
logging.info(f"Joint Commissioning completed successfully for node {nodeid}")
299300

@@ -306,17 +307,6 @@ async def _joint_commission_EcoB_admin(self, devCtrl, nodeid, passcode, endpoint
306307
@async_test_body
307308
async def test_TC_JCM_1_2(self):
308309

309-
# Creating a Controller for Ecosystem A
310-
_fabric_a_persistent_storage = PersistentStorage(jsonData=self.ecoACtrlStorage)
311-
_certAuthorityManagerA = CertificateAuthority.CertificateAuthorityManager(
312-
chipStack=self.matter_stack._chip_stack,
313-
persistentStorage=_fabric_a_persistent_storage)
314-
_certAuthorityManagerA.LoadAuthoritiesFromStorage()
315-
_devCtrlEcoA = _certAuthorityManagerA.activeCaList[0].adminList[0].NewController(
316-
nodeId=101,
317-
paaTrustStorePath=str(self.matter_test_config.paa_trust_store_path),
318-
catTags=[int(self.ecoACATs, 16)])
319-
320310
# Creating a Controller for Ecosystem B
321311
_fabric_b_persistent_storage = PersistentStorage(jsonData=self.ecoBCtrlStorage)
322312
_certAuthorityManagerB = CertificateAuthority.CertificateAuthorityManager(
@@ -376,6 +366,9 @@ async def test_TC_JCM_1_2(self):
376366
asserts.assert_true(_admin_cat_found, "Administrator CAT not found in Admin App NOC on Ecosystem B")
377367
asserts.assert_true(_anchor_cat_found, "Anchor CAT not found in Admin App NOC on Ecosystem B")
378368

369+
# Shutdown the Python Controllers start at the begining
370+
devCtrlEcoB.Shutdown()
371+
379372

380373
if __name__ == "__main__":
381374
default_matter_test_main()

src/python_testing/TC_JFDS_2_1.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ async def setup_class(self):
108108
# Commission JF-ADMIN app with JF-Controller on Fabric A
109109
self.fabric_a_ctrl.send(
110110
message=f"pairing onnetwork 1 {self.jfadmin_fabric_a_passcode} --anchor true",
111-
expected_output="[JF] Anchor Administrator commissioned with sucess")
111+
expected_output="[JF] Anchor Administrator commissioned with sucess",
112+
timeout=10)
112113

113114
# Extract the Ecosystem A certificates and inject them in the storage that will be provided to a new Python Controller later
114115
jfcStorage = ConfigParser()
@@ -188,6 +189,9 @@ async def test_TC_JFDS_2_1(self):
188189
returnClusterObject=True)
189190
asserts.assert_greater_equal(response[1][Clusters.JointFabricDatastore].anchorVendorID, 0)
190191

192+
# Shutdown the Python Controllers start at the begining
193+
devCtrlEcoA.Shutdown()
194+
191195

192196
if __name__ == "__main__":
193197
default_matter_test_main()

src/python_testing/TC_JFDS_2_2.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ async def setup_class(self):
109109
# Commission JF-ADMIN app with JF-Controller on Fabric A
110110
self.fabric_a_ctrl.send(
111111
message=f"pairing onnetwork 1 {self.jfadmin_fabric_a_passcode} --anchor true",
112-
expected_output="[JF] Anchor Administrator commissioned with sucess")
112+
expected_output="[JF] Anchor Administrator commissioned with sucess",
113+
timeout=10)
113114

114115
# Extract the Ecosystem A certificates and inject them in the storage that will be provided to a new Python Controller later
115116
jfcStorage = ConfigParser()
@@ -281,6 +282,9 @@ async def test_TC_JFDS_2_2(self):
281282
# else:
282283
# asserts.assert_true(False, 'Expected InteractionModelError with CONSTRANT_ERROR, but no exception occurred!')
283284

285+
# Shutdown the Python Controllers start at the begining
286+
devCtrlEcoA.Shutdown()
287+
284288

285289
if __name__ == "__main__":
286290
default_matter_test_main()

src/python_testing/matter_testing_infrastructure/chip/testing/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def start(self,
134134

135135
def send(self, message: str, end: str = "\n",
136136
expected_output: Optional[Union[str, re.Pattern]] = None,
137-
timeout: Optional[float] = None):
137+
timeout: float = 300):
138138
"""Send a message to a process and optionally wait for a response."""
139139

140140
if expected_output is not None:

0 commit comments

Comments
 (0)