Skip to content

Commit

Permalink
Check fabric-sync application with MCORE-FS tests on CI (project-chip…
Browse files Browse the repository at this point in the history
…#36810)

* Check fabric-sync application with MCORE-FS tests on CI

* Add test with new fabric-sync for MCORE-FS-1.5

* Use async-friendly sleep
  • Loading branch information
arkq authored Dec 12, 2024
1 parent 506f493 commit 5a88b60
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 22 deletions.
15 changes: 15 additions & 0 deletions src/python_testing/TC_MCORE_FS_1_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
# quiet: true
# run2:
# app: ${FABRIC_SYNC_APP}
# app-args: --discriminator=1234
# app-stdin-pipe: dut-fsa-stdin
# script-args: >
# --PICS src/app/tests/suites/certification/ci-pics-values
# --storage-path admin_storage.json
# --commissioning-method on-network
# --discriminator 1234
# --passcode 20202021
# --string-arg th_server_app_path:${ALL_CLUSTERS_APP}
# --trace-to json:${TRACE_TEST_JSON}.json
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
# quiet: true
# === END CI TEST ARGUMENTS ===

import logging
Expand Down
25 changes: 22 additions & 3 deletions src/python_testing/TC_MCORE_FS_1_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
# quiet: true
# run2:
# app: ${FABRIC_SYNC_APP}
# app-args: --discriminator=1234
# app-stdin-pipe: dut-fsa-stdin
# script-args: >
# --PICS src/app/tests/suites/certification/ci-pics-values
# --storage-path admin_storage.json
# --commissioning-method on-network
# --discriminator 1234
# --passcode 20202021
# --bool-arg unified_fabric_sync_app:true
# --string-arg th_server_app_path:${ALL_CLUSTERS_APP}
# --string-arg dut_fsa_stdin_pipe:dut-fsa-stdin
# --trace-to json:${TRACE_TEST_JSON}.json
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
# quiet: true
# === END CI TEST ARGUMENTS ===

import asyncio
Expand Down Expand Up @@ -182,8 +199,10 @@ async def test_TC_MCORE_FS_1_2(self):
if not self.is_pics_sdk_ci_only:
self._ask_for_vendor_commissioning_ux_operation(self.th_server_setup_params)
else:
self.dut_fsa_stdin.write(
f"pairing onnetwork 2 {self.th_server_setup_params.passcode}\n")
if self.user_params.get("unified_fabric_sync_app"):
self.dut_fsa_stdin.write(f"app pair-device 2 {self.th_server_setup_params.qr_code}\n")
else:
self.dut_fsa_stdin.write(f"pairing onnetwork 2 {self.th_server_setup_params.passcode}\n")
self.dut_fsa_stdin.flush()
# Wait for the commissioning to complete.
await asyncio.sleep(5)
Expand Down Expand Up @@ -250,7 +269,7 @@ async def test_TC_MCORE_FS_1_2(self):
bridged_info_for_th_server = dut_read[newly_added_endpoint][Clusters.BridgedDeviceBasicInformation]
basic_info_attr = Clusters.BasicInformation.Attributes
bridged_device_info_attr = Clusters.BridgedDeviceBasicInformation.Attributes
Clusters.BasicInformation.Attributes

asserts.assert_equal(th_server_basic_info[basic_info_attr.VendorName],
bridged_info_for_th_server[bridged_device_info_attr.VendorName], "VendorName incorrectly reported by DUT")
asserts.assert_equal(th_server_basic_info[basic_info_attr.VendorID],
Expand Down
23 changes: 21 additions & 2 deletions src/python_testing/TC_MCORE_FS_1_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
# quiet: true
# run2:
# app: ${FABRIC_SYNC_APP}
# app-args: --discriminator=1234
# app-stdin-pipe: dut-fsa-stdin
# script-args: >
# --PICS src/app/tests/suites/certification/ci-pics-values
# --storage-path admin_storage.json
# --commissioning-method on-network
# --discriminator 1234
# --passcode 20202021
# --bool-arg unified_fabric_sync_app:true
# --string-arg th_server_no_uid_app_path:${LIGHTING_APP_NO_UNIQUE_ID}
# --string-arg dut_fsa_stdin_pipe:dut-fsa-stdin
# --trace-to json:${TRACE_TEST_JSON}.json
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
# quiet: true
# === END CI TEST ARGUMENTS ===

import asyncio
Expand Down Expand Up @@ -193,8 +210,10 @@ async def test_TC_MCORE_FS_1_3(self):
f"If using FabricSync Admin, you may type:\n"
f">>> pairing onnetwork <desired_node_id> {params.setupPinCode}")
else:
self.dut_fsa_stdin.write(
f"pairing onnetwork 10 {params.setupPinCode}\n")
if self.user_params.get("unified_fabric_sync_app"):
self.dut_fsa_stdin.write(f"app pair-device 10 {params.setupQRCode}\n")
else:
self.dut_fsa_stdin.write(f"pairing onnetwork 10 {params.setupPinCode}\n")
self.dut_fsa_stdin.flush()
# Wait for the commissioning to complete.
await asyncio.sleep(5)
Expand Down
32 changes: 29 additions & 3 deletions src/python_testing/TC_MCORE_FS_1_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,25 @@
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
# quiet: true
# run2:
# app: ${FABRIC_SYNC_APP}
# app-args: --discriminator=1234
# app-stdin-pipe: dut-fsa-stdin
# script-args: >
# --PICS src/app/tests/suites/certification/ci-pics-values
# --storage-path admin_storage.json
# --commissioning-method on-network
# --discriminator 1234 --passcode 20202021
# --bool-arg unified_fabric_sync_app:true
# --string-arg th_fsa_app_path:examples/fabric-admin/scripts/fabric-sync-app.py
# --string-arg th_fsa_admin_path:${FABRIC_ADMIN_APP}
# --string-arg th_fsa_bridge_path:${FABRIC_BRIDGE_APP}
# --string-arg th_server_no_uid_app_path:${LIGHTING_APP_NO_UNIQUE_ID}
# --string-arg dut_fsa_stdin_pipe:dut-fsa-stdin
# --trace-to json:${TRACE_TEST_JSON}.json
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
# quiet: true
# === END CI TEST ARGUMENTS ===

import asyncio
Expand Down Expand Up @@ -322,8 +341,12 @@ async def test_TC_MCORE_FS_1_4(self):
f"If using FabricSync Admin, you may type:\n"
f">>> fabricsync add-bridge <desired_node_id> {params.setupPinCode} <th_host_ip> {self.th_fsa_bridge_port}")
else:
self.dut_fsa_stdin.write(
f"fabricsync add-bridge 10 {params.setupPinCode} {self.th_fsa_bridge_address} {self.th_fsa_bridge_port}\n")
if self.user_params.get("unified_fabric_sync_app"):
self.dut_fsa_stdin.write(
f"app add-bridge 10 {params.setupPinCode} {self.th_fsa_bridge_address} {self.th_fsa_bridge_port}\n")
else:
self.dut_fsa_stdin.write(
f"fabricsync add-bridge 10 {params.setupPinCode} {self.th_fsa_bridge_address} {self.th_fsa_bridge_port}\n")
self.dut_fsa_stdin.flush()
# Wait for the commissioning to complete.
await asyncio.sleep(5)
Expand All @@ -347,7 +370,10 @@ async def test_TC_MCORE_FS_1_4(self):
f"If using FabricSync Admin, you may type:\n"
f">>> fabricsync sync-device {th_fsa_bridge_th_server_endpoint}")
else:
self.dut_fsa_stdin.write(f"fabricsync sync-device {th_fsa_bridge_th_server_endpoint}\n")
if self.user_params.get("unified_fabric_sync_app"):
self.dut_fsa_stdin.write(f"app sync-device {th_fsa_bridge_th_server_endpoint}\n")
else:
self.dut_fsa_stdin.write(f"fabricsync sync-device {th_fsa_bridge_th_server_endpoint}\n")
self.dut_fsa_stdin.flush()
# Wait for the synchronization to complete.
await asyncio.sleep(5)
Expand Down
48 changes: 34 additions & 14 deletions src/python_testing/TC_MCORE_FS_1_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
# quiet: true
# run2:
# app: ${FABRIC_SYNC_APP}
# app-args: --discriminator=1234
# app-stdin-pipe: dut-fsa-stdin
# script-args: >
# --PICS src/app/tests/suites/certification/ci-pics-values
# --storage-path admin_storage.json
# --commissioning-method on-network
# --discriminator 1234
# --passcode 20202021
# --bool-arg unified_fabric_sync_app:true
# --string-arg th_server_app_path:${ALL_CLUSTERS_APP}
# --string-arg dut_fsa_stdin_pipe:dut-fsa-stdin
# --trace-to json:${TRACE_TEST_JSON}.json
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
# quiet: true
# === END CI TEST ARGUMENTS ===

import asyncio
Expand Down Expand Up @@ -139,17 +156,18 @@ def _ask_for_vendor_commissioning_ux_operation(self, setup_params: SetupParamete
f">>> pairing onnetwork 111 {setup_params.passcode}")

def steps_TC_MCORE_FS_1_5(self) -> list[TestStep]:
steps = [TestStep(1, "TH subscribes to PartsList attribute of the Descriptor cluster of DUT_FSA endpoint 0."),
TestStep(2, "Follow manufacturer provided instructions to have DUT_FSA commission TH_SERVER"),
TestStep(3, "TH waits up to 30 seconds for subscription report from the PartsList attribute of the Descriptor to contain new endpoint"),
TestStep(4, "TH uses DUT to open commissioning window to TH_SERVER"),
TestStep(5, "TH commissions TH_SERVER"),
TestStep(6, "TH subscribes to AdministratorCommissioning attributes on DUT_FSA for the newly added endpoint identified in step 3"),
TestStep(7, "TH opens commissioning window to TH_SERVER directly (not using DUT)"),
TestStep(8, "TH reads CurrentFabricIndex attributes on OperationalCredentials cluster from TH_SERVER directly (not using DUT_FSA)"),
TestStep(9, "TH reads AdministratorCommissioning from TH_SERVER directly (not using DUT)"),
TestStep(10, "TH waits up to 10 seconds for subscription report from the AdministratorCommissioning attribute (from step 6) to reflect values from previous step")]
return steps
return [
TestStep(1, "TH subscribes to PartsList attribute of the Descriptor cluster of DUT_FSA endpoint 0."),
TestStep(2, "Follow manufacturer provided instructions to have DUT_FSA commission TH_SERVER"),
TestStep(3, "TH waits up to 30 seconds for subscription report from the PartsList attribute of the Descriptor to contain new endpoint"),
TestStep(4, "TH uses DUT to open commissioning window to TH_SERVER"),
TestStep(5, "TH commissions TH_SERVER"),
TestStep(6, "TH subscribes to AdministratorCommissioning attributes on DUT_FSA for the newly added endpoint identified in step 3"),
TestStep(7, "TH opens commissioning window to TH_SERVER directly (not using DUT)"),
TestStep(8, "TH reads CurrentFabricIndex attributes on OperationalCredentials cluster from TH_SERVER directly (not using DUT_FSA)"),
TestStep(9, "TH reads AdministratorCommissioning from TH_SERVER directly (not using DUT)"),
TestStep(10, "TH waits up to 10 seconds for subscription report from the AdministratorCommissioning attribute (from step 6) to reflect values from previous step"),
]

# This test has some manual steps, so we need a longer timeout. Test typically runs under 1 mins so 3 mins should
# be enough time for test to run
Expand Down Expand Up @@ -189,8 +207,10 @@ async def test_TC_MCORE_FS_1_5(self):
if not self.is_pics_sdk_ci_only:
self._ask_for_vendor_commissioning_ux_operation(self.th_server_setup_params)
else:
self.dut_fsa_stdin.write(
f"pairing onnetwork 2 {self.th_server_setup_params.passcode}\n")
if self.user_params.get("unified_fabric_sync_app"):
self.dut_fsa_stdin.write(f"app pair-device 2 {self.th_server_setup_params.qr_code}\n")
else:
self.dut_fsa_stdin.write(f"pairing onnetwork 2 {self.th_server_setup_params.passcode}\n")
self.dut_fsa_stdin.flush()
# Wait for the commissioning to complete.
await asyncio.sleep(5)
Expand Down Expand Up @@ -265,7 +285,7 @@ async def test_TC_MCORE_FS_1_5(self):
cadmin_attribute_handler = AttributeChangeAccumulator(
name=self.default_controller.name, expected_attribute=Clusters.AdministratorCommissioning.Attributes.WindowStatus, output=cadmin_queue)
self._cadmin_subscription.SetAttributeUpdateCallback(cadmin_attribute_handler)
time.sleep(1)
await asyncio.sleep(1)

self.step(7)
await self.default_controller.OpenCommissioningWindow(nodeid=self.th_server_local_nodeid, timeout=180, iteration=1000, discriminator=3840, option=1)
Expand Down

0 comments on commit 5a88b60

Please sign in to comment.