Skip to content

Commit

Permalink
test: Close commissioner session to properly cleanup resources
Browse files Browse the repository at this point in the history
Add explicit CloseSession calls in TC_CGEN_2_8 and TC_CGEN_2_9 to ensure
proper cleanup of commissioner library resources. This fixes an issue where
subsequent commissioner sessions could not be established due to lingering
resources from previous test runs.

Bug: Commissioner session establishment failures in subsequent test runs
Fix: Add explicit session cleanup after commissioning operations

Testing:
- Set PICS_USER_PROMPT=1 for manual intervention testing
- Verified with terms-and-conditions-app test harness
- Confirmed proper cleanup by:
  1. Running initial commissioning
  2. Performing factory reset (process kill + KVS cleanup)
  3. Successfully re-establishing commissioner session
- Test passes with manual intervention at factory reset and commissioning prompts
  • Loading branch information
swan-amazon committed Feb 11, 2025
1 parent 7d67dc9 commit 44b571b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/python_testing/TC_CGEN_2_8.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ async def test_TC_CGEN_2_8(self):
"First CommissioningComplete failed",
)

# Close the commissioner session with the device to clean up resources
commissioner.CloseSession(nodeid=self.dut_node_id)

# Step 5: Factory reset is handled by test operator
self.step(5)
if not self.check_pics('PICS_USER_PROMPT'):
Expand Down
3 changes: 3 additions & 0 deletions src/python_testing/TC_CGEN_2_9.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ async def test_TC_CGEN_2_9(self):
self.step(5)
await self.remove_commissioner_fabric()

# Close the commissioner session with the device to clean up resources
commissioner.CloseSession(nodeid=self.dut_node_id)

# Step 6: Put device in commissioning mode (requiring user input, so skip in CI)
self.step(6)
if not self.check_pics('PICS_USER_PROMPT'):
Expand Down

0 comments on commit 44b571b

Please sign in to comment.