From 644008067385aef3b8aade90d8cc62d239abfde2 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Tue, 6 Aug 2024 14:22:04 -0400 Subject: [PATCH 01/18] Add ICDM 5.1 Automated Test Script --- .github/workflows/tests.yaml | 92 ++++++++---- src/app/tests/suites/manualTests.json | 3 +- src/python_testing/TC_ICDM_5_1.py | 202 ++++++++++++++++++++++++++ 3 files changed, 267 insertions(+), 30 deletions(-) create mode 100644 src/python_testing/TC_ICDM_5_1.py diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 70f40efc502234..02c2902edb479b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -17,13 +17,14 @@ name: Tests on: push: branches-ignore: - - 'dependabot/**' + - "dependabot/**" pull_request: merge_group: workflow_dispatch: concurrency: - group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == + group: + ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }} cancel-in-progress: true @@ -42,7 +43,9 @@ jobs: env: BUILD_VARIANT: ${{matrix.build_variant}} CHIP_TOOL_VARIANT: ${{matrix.chip_tool}} - TSAN_OPTIONS: "halt_on_error=1 suppressions=scripts/tests/chiptest/tsan-linux-suppressions.txt" + TSAN_OPTIONS: + "halt_on_error=1 + suppressions=scripts/tests/chiptest/tsan-linux-suppressions.txt" LSAN_OPTIONS: detect_leaks=1 if: github.actor != 'restyled-io[bot]' @@ -50,7 +53,8 @@ jobs: container: image: ghcr.io/project-chip/chip-build:54 - options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 + options: + --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" steps: @@ -68,9 +72,12 @@ jobs: - name: Checkout submodules & Bootstrap uses: ./.github/actions/checkout-submodules-and-bootstrap with: - platform: linux - bootstrap-log-name: bootstrap-logs-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }} - - name: Try to ensure the directories for core dumping exist and we + platform: linux + bootstrap-log-name: + bootstrap-logs-linux-${{ matrix.build_variant }}${{ + matrix.chip_tool }} + - name: + Try to ensure the directories for core dumping exist and we can write them. run: | mkdir /tmp/cores || true @@ -231,7 +238,9 @@ jobs: --copy-artifacts-to objdir-clone \ " - - name: Run Tests using the python parser sending commands to chip-tool + - name: + Run Tests using the python parser sending commands to + chip-tool run: | ./scripts/run_in_build_env.sh \ "./scripts/tests/run_test_suite.py \ @@ -252,7 +261,9 @@ jobs: --network-manager-app ./out/linux-x64-network-manager-${BUILD_VARIANT}/matter-network-manager-app \ " - - name: Run purposeful failure tests using the python parser sending commands to chip-tool + - name: + Run purposeful failure tests using the python parser sending + commands to chip-tool run: | ./scripts/run_in_build_env.sh \ "./scripts/tests/run_test_suite.py \ @@ -317,7 +328,9 @@ jobs: uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} with: - name: crash-core-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }} + name: + crash-core-linux-${{ matrix.build_variant }}${{ + matrix.chip_tool }} path: /tmp/cores/ # Cores are big; don't hold on to them too long. retention-days: 5 @@ -325,7 +338,9 @@ jobs: uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} with: - name: crash-objdir-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }} + name: + crash-objdir-linux-${{ matrix.build_variant }}${{ + matrix.chip_tool }} path: objdir-clone/ # objdirs are big; don't hold on to them too long. retention-days: 5 @@ -341,7 +356,9 @@ jobs: BUILD_VARIANT: ${{matrix.build_variant}} CHIP_TOOL_VARIANT: ${{matrix.chip_tool}} TSAN_OPTIONS: "halt_on_error=1" - LSAN_OPTIONS: detect_leaks=1 suppressions=scripts/tests/chiptest/lsan-mac-suppressions.txt + LSAN_OPTIONS: + detect_leaks=1 + suppressions=scripts/tests/chiptest/lsan-mac-suppressions.txt if: github.actor != 'restyled-io[bot]' runs-on: macos-13 @@ -362,9 +379,10 @@ jobs: - name: Checkout submodules & Bootstrap uses: ./.github/actions/checkout-submodules-and-bootstrap with: - platform: darwin - bootstrap-log-name: bootstrap-logs-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} - + platform: darwin + bootstrap-log-name: + bootstrap-logs-darwin-${{ matrix.build_variant }}${{ + matrix.chip_tool }} - name: Build Apps run: | @@ -385,7 +403,9 @@ jobs: --copy-artifacts-to objdir-clone \ " - - name: Run Tests using the python parser sending commands to chip-tool + - name: + Run Tests using the python parser sending commands to + chip-tool run: | ./scripts/run_in_build_env.sh \ "./scripts/tests/run_test_suite.py \ @@ -407,7 +427,9 @@ jobs: --network-manager-app ./out/darwin-x64-network-manager-${BUILD_VARIANT}/matter-network-manager-app \ " - - name: Run purposeful failure tests using the python parser sending commands to chip-tool + - name: + Run purposeful failure tests using the python parser sending + commands to chip-tool run: | ./scripts/run_in_build_env.sh \ "./scripts/tests/run_test_suite.py \ @@ -426,7 +448,9 @@ jobs: uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} with: - name: crash-core-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} + name: + crash-core-darwin-${{ matrix.build_variant }}${{ + matrix.chip_tool }} path: /cores/ # Cores are big; don't hold on to them too long. retention-days: 5 @@ -434,13 +458,17 @@ jobs: uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} with: - name: crash-log-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} + name: + crash-log-darwin-${{ matrix.build_variant }}${{ + matrix.chip_tool }} path: ~/Library/Logs/DiagnosticReports/ - name: Uploading objdir for debugging uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} with: - name: crash-objdir-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} + name: + crash-objdir-darwin-${{ matrix.build_variant }}${{ + matrix.chip_tool }} path: objdir-clone/ # objdirs are big; don't hold on to them too long. retention-days: 5 @@ -449,14 +477,17 @@ jobs: name: REPL Tests - Linux env: - TSAN_OPTIONS: "halt_on_error=1 suppressions=scripts/tests/chiptest/tsan-linux-suppressions.txt" + TSAN_OPTIONS: + "halt_on_error=1 + suppressions=scripts/tests/chiptest/tsan-linux-suppressions.txt" if: github.actor != 'restyled-io[bot]' runs-on: ubuntu-latest container: image: ghcr.io/project-chip/chip-build:66 - options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 + options: + --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" steps: @@ -465,9 +496,12 @@ jobs: - name: Checkout submodules & Bootstrap uses: ./.github/actions/checkout-submodules-and-bootstrap with: - platform: linux - bootstrap-log-name: bootstrap-logs-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }} - - name: Try to ensure the directories for core dumping exist and we + platform: linux + bootstrap-log-name: + bootstrap-logs-linux-${{ matrix.build_variant }}${{ + matrix.chip_tool }} + - name: + Try to ensure the directories for core dumping exist and we can write them. run: | mkdir /tmp/cores || true @@ -552,6 +586,7 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ICDM_2_1.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ICDM_3_1.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ICDM_3_3.py' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ICDM_5_1.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ICDManagementCluster.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_IDM_1_2.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_IDM_1_4.py' @@ -623,7 +658,6 @@ jobs: scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/test_testing/test_TC_SC_7_1.py' scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/test_testing/TestDecorators.py' - - name: Uploading core files uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} @@ -670,8 +704,10 @@ jobs: - name: Checkout submodules & Bootstrap uses: ./.github/actions/checkout-submodules-and-bootstrap with: - platform: darwin - bootstrap-log-name: bootstrap-logs-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} + platform: darwin + bootstrap-log-name: + bootstrap-logs-darwin-${{ matrix.build_variant }}${{ + matrix.chip_tool }} - name: Build Python REPL and example apps run: | diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index bbb86f7092b715..09ef8e3bfaf9f9 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -119,8 +119,7 @@ "Identify": ["Test_TC_I_3_2"], "IcdManagement": [ "Test_TC_ICDM_3_2", - "Test_TC_ICDM_4_1", - "Test_TC_ICDM_5_1" + "Test_TC_ICDM_4_1" ], "IlluminanceMeasurement": [], "InteractionDataModel": [ diff --git a/src/python_testing/TC_ICDM_5_1.py b/src/python_testing/TC_ICDM_5_1.py new file mode 100644 index 00000000000000..987bbfbfb4e613 --- /dev/null +++ b/src/python_testing/TC_ICDM_5_1.py @@ -0,0 +1,202 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${LIT_ICD_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === + +import logging +from dataclasses import dataclass + +import chip.clusters as Clusters +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts +from chip.interaction_model import InteractionModelError, Status +from mdns_discovery import mdns_discovery + +cluster = Clusters.Objects.IcdManagement +commands = cluster.Commands +attributes = cluster.Attributes +modes = cluster.Enums.OperatingModeEnum +ClientTypeEnum = cluster.Enums.ClientTypeEnum + + +@dataclass +class Client: + checkInNodeID: int + subjectId: int + key: bytes + clientType: ClientTypeEnum + + +logger = logging.getLogger(__name__) +kRootEndpointId = 0 + +client1 = Client( + checkInNodeID=1, + subjectId=1, + key=b"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", + clientType=ClientTypeEnum.kEphemeral +) + + +class TC_ICDM_5_1(MatterBaseTest): + + # + # Class Helper functions + # + + async def _read_icdm_attribute_expect_success(self, attribute): + return await self.read_single_attribute_check_success(endpoint=kRootEndpointId, cluster=cluster, attribute=attribute) + + async def _send_single_icdm_command(self, command): + return await self.send_single_cmd(command, endpoint=kRootEndpointId) + + async def _get_icd_txt_record(self): + discovery = mdns_discovery.MdnsDiscovery() + localCompressedNodeId = hex(self.default_controller.GetCompressedFabricId()) + dutNodeId = hex(self.dut_node_id) + + services = await discovery.get_all_services(log_output=False) + icdTxtRecord = modes.kUnknownEnumValue.value + + for service in services[mdns_discovery.MdnsServiceType.OPERATIONAL.value]: + + # Generate hex for the compressedFabric and NodeId + serviceName = service.instance_name.split("-") + compressedFabric = hex(int(serviceName[0], 16)) + nodeId = hex(int(serviceName[1], 16)) + + # Find the correct MdnsServiceEntry + if localCompressedNodeId == compressedFabric and dutNodeId == nodeId: + icdTxtRecord = service.txt_record['ICD'] + + return icdTxtRecord + + # + # Test Harness Helpers + # + + def desc_TC_ICDM_5_1(self) -> str: + """Returns a description of this test""" + return "[TC-ICDM-5.1] Operating Mode with DUT as Server" + + def steps_TC_ICDM_5_1(self) -> list[TestStep]: + steps = [ + TestStep(0, "Commissioning, already done", is_commissioning=True), + TestStep(1, "TH reads from the DUT the RegisteredClients attribute"), + TestStep("2a", "TH reads from the DUT the OperatingMode attribute."), + TestStep("2b", "Verify that the ICD DNS-SD TXT key is present."), + TestStep("3a", "TH sends RegisterClient command."), + TestStep("3b", "TH reads from the DUT the OperatingMode attribute."), + TestStep("3c", "Verify that mDNS is advertising ICD key."), + TestStep(4, "TH sends UnregisterClient command with CheckInNodeID1."), + TestStep("5a", "TH reads from the DUT the OperatingMode attribute."), + TestStep("5b", "Verify that the ICD DNS-SD TXT key is present."), + ] + return steps + + def pics_TC_ICDM_5_1(self) -> list[str]: + """ This function returns a list of PICS for this test case that must be True for the test to be run""" + pics = [ + "ICDM.S", + "ICDM.S.F02", + ] + return pics + + # + # ICDM 5.1 Test Body + # + + @async_test_body + async def test_TC_ICDM_5_1(self): + + # Commissioning + self.step(0) + + try: + self.step(1) + registeredClients = await self._read_icdm_attribute_expect_success( + attributes.RegisteredClients) + + for client in registeredClients: + try: + await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=client.checkInNodeID)) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.Success, "Unexpected error returned") + + self.step("2a") + operatingMode = await self._read_icdm_attribute_expect_success(attributes.OperatingMode) + asserts.assert_equal(operatingMode, modes.kSit.value) + + self.step("2b") + icdTxtRecord = await self._get_icd_txt_record() + asserts.assert_equal(int(icdTxtRecord), modes.kSit.value, "OperatingMode Is not in SIT mode.") + + self.step("3a") + try: + await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=client1.checkInNodeID, monitoredSubject=client1.subjectId, key=client1.key, clientType=client1.clientType)) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.Success, "Unexpected error returned") + + self.step("3b") + operatingMode = await self._read_icdm_attribute_expect_success(attributes.OperatingMode) + asserts.assert_equal(operatingMode, modes.kLit.value) + + self.step("3c") + icdTxtRecord = await self._get_icd_txt_record() + asserts.assert_equal(int(icdTxtRecord), modes.kLit.value, "OperatingMode Is not in Lit mode.") + + self.step(4) + try: + await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=client1.checkInNodeID)) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.Success, "Unexpected error returned") + + self.step("5a") + operatingMode = await self._read_icdm_attribute_expect_success(attributes.OperatingMode) + asserts.assert_equal(operatingMode, modes.kSit.value) + + self.step("5b") + icdTxtRecord = await self._get_icd_txt_record() + asserts.assert_equal(int(icdTxtRecord), modes.kSit.value, "OperatingMode Is not in SIT mode.") + + finally: + registeredClients = await self._read_icdm_attribute_expect_success( + attributes.RegisteredClients) + + for client in registeredClients: + try: + await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=client.checkInNodeID)) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.Success, "Unexpected error returned") + + +if __name__ == "__main__": + default_matter_test_main() From 5d791a5284f99a27b5ca43f7bb45844def60371d Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Tue, 6 Aug 2024 14:22:47 -0400 Subject: [PATCH 02/18] fix restyle --- .github/workflows/tests.yaml | 91 +++++++++++------------------------- 1 file changed, 28 insertions(+), 63 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 02c2902edb479b..1d67eaa1fa74a9 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -17,14 +17,13 @@ name: Tests on: push: branches-ignore: - - "dependabot/**" + - 'dependabot/**' pull_request: merge_group: workflow_dispatch: concurrency: - group: - ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == + group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }} cancel-in-progress: true @@ -43,9 +42,7 @@ jobs: env: BUILD_VARIANT: ${{matrix.build_variant}} CHIP_TOOL_VARIANT: ${{matrix.chip_tool}} - TSAN_OPTIONS: - "halt_on_error=1 - suppressions=scripts/tests/chiptest/tsan-linux-suppressions.txt" + TSAN_OPTIONS: "halt_on_error=1 suppressions=scripts/tests/chiptest/tsan-linux-suppressions.txt" LSAN_OPTIONS: detect_leaks=1 if: github.actor != 'restyled-io[bot]' @@ -53,8 +50,7 @@ jobs: container: image: ghcr.io/project-chip/chip-build:54 - options: - --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 + options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" steps: @@ -72,12 +68,9 @@ jobs: - name: Checkout submodules & Bootstrap uses: ./.github/actions/checkout-submodules-and-bootstrap with: - platform: linux - bootstrap-log-name: - bootstrap-logs-linux-${{ matrix.build_variant }}${{ - matrix.chip_tool }} - - name: - Try to ensure the directories for core dumping exist and we + platform: linux + bootstrap-log-name: bootstrap-logs-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }} + - name: Try to ensure the directories for core dumping exist and we can write them. run: | mkdir /tmp/cores || true @@ -238,9 +231,7 @@ jobs: --copy-artifacts-to objdir-clone \ " - - name: - Run Tests using the python parser sending commands to - chip-tool + - name: Run Tests using the python parser sending commands to chip-tool run: | ./scripts/run_in_build_env.sh \ "./scripts/tests/run_test_suite.py \ @@ -261,9 +252,7 @@ jobs: --network-manager-app ./out/linux-x64-network-manager-${BUILD_VARIANT}/matter-network-manager-app \ " - - name: - Run purposeful failure tests using the python parser sending - commands to chip-tool + - name: Run purposeful failure tests using the python parser sending commands to chip-tool run: | ./scripts/run_in_build_env.sh \ "./scripts/tests/run_test_suite.py \ @@ -328,9 +317,7 @@ jobs: uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} with: - name: - crash-core-linux-${{ matrix.build_variant }}${{ - matrix.chip_tool }} + name: crash-core-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: /tmp/cores/ # Cores are big; don't hold on to them too long. retention-days: 5 @@ -338,9 +325,7 @@ jobs: uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} with: - name: - crash-objdir-linux-${{ matrix.build_variant }}${{ - matrix.chip_tool }} + name: crash-objdir-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: objdir-clone/ # objdirs are big; don't hold on to them too long. retention-days: 5 @@ -356,9 +341,7 @@ jobs: BUILD_VARIANT: ${{matrix.build_variant}} CHIP_TOOL_VARIANT: ${{matrix.chip_tool}} TSAN_OPTIONS: "halt_on_error=1" - LSAN_OPTIONS: - detect_leaks=1 - suppressions=scripts/tests/chiptest/lsan-mac-suppressions.txt + LSAN_OPTIONS: detect_leaks=1 suppressions=scripts/tests/chiptest/lsan-mac-suppressions.txt if: github.actor != 'restyled-io[bot]' runs-on: macos-13 @@ -379,10 +362,9 @@ jobs: - name: Checkout submodules & Bootstrap uses: ./.github/actions/checkout-submodules-and-bootstrap with: - platform: darwin - bootstrap-log-name: - bootstrap-logs-darwin-${{ matrix.build_variant }}${{ - matrix.chip_tool }} + platform: darwin + bootstrap-log-name: bootstrap-logs-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} + - name: Build Apps run: | @@ -403,9 +385,7 @@ jobs: --copy-artifacts-to objdir-clone \ " - - name: - Run Tests using the python parser sending commands to - chip-tool + - name: Run Tests using the python parser sending commands to chip-tool run: | ./scripts/run_in_build_env.sh \ "./scripts/tests/run_test_suite.py \ @@ -427,9 +407,7 @@ jobs: --network-manager-app ./out/darwin-x64-network-manager-${BUILD_VARIANT}/matter-network-manager-app \ " - - name: - Run purposeful failure tests using the python parser sending - commands to chip-tool + - name: Run purposeful failure tests using the python parser sending commands to chip-tool run: | ./scripts/run_in_build_env.sh \ "./scripts/tests/run_test_suite.py \ @@ -448,9 +426,7 @@ jobs: uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} with: - name: - crash-core-darwin-${{ matrix.build_variant }}${{ - matrix.chip_tool }} + name: crash-core-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: /cores/ # Cores are big; don't hold on to them too long. retention-days: 5 @@ -458,17 +434,13 @@ jobs: uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} with: - name: - crash-log-darwin-${{ matrix.build_variant }}${{ - matrix.chip_tool }} + name: crash-log-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: ~/Library/Logs/DiagnosticReports/ - name: Uploading objdir for debugging uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} with: - name: - crash-objdir-darwin-${{ matrix.build_variant }}${{ - matrix.chip_tool }} + name: crash-objdir-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: objdir-clone/ # objdirs are big; don't hold on to them too long. retention-days: 5 @@ -477,17 +449,14 @@ jobs: name: REPL Tests - Linux env: - TSAN_OPTIONS: - "halt_on_error=1 - suppressions=scripts/tests/chiptest/tsan-linux-suppressions.txt" + TSAN_OPTIONS: "halt_on_error=1 suppressions=scripts/tests/chiptest/tsan-linux-suppressions.txt" if: github.actor != 'restyled-io[bot]' runs-on: ubuntu-latest container: image: ghcr.io/project-chip/chip-build:66 - options: - --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 + options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" steps: @@ -496,12 +465,9 @@ jobs: - name: Checkout submodules & Bootstrap uses: ./.github/actions/checkout-submodules-and-bootstrap with: - platform: linux - bootstrap-log-name: - bootstrap-logs-linux-${{ matrix.build_variant }}${{ - matrix.chip_tool }} - - name: - Try to ensure the directories for core dumping exist and we + platform: linux + bootstrap-log-name: bootstrap-logs-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }} + - name: Try to ensure the directories for core dumping exist and we can write them. run: | mkdir /tmp/cores || true @@ -658,6 +624,7 @@ jobs: scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/test_testing/test_TC_SC_7_1.py' scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/test_testing/TestDecorators.py' + - name: Uploading core files uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} @@ -704,10 +671,8 @@ jobs: - name: Checkout submodules & Bootstrap uses: ./.github/actions/checkout-submodules-and-bootstrap with: - platform: darwin - bootstrap-log-name: - bootstrap-logs-darwin-${{ matrix.build_variant }}${{ - matrix.chip_tool }} + platform: darwin + bootstrap-log-name: bootstrap-logs-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} - name: Build Python REPL and example apps run: | From 22b980ae3fa59a5823a9fd342a5acc125d82b656 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 6 Aug 2024 18:23:48 +0000 Subject: [PATCH 03/18] Restyled by prettier-json --- src/app/tests/suites/manualTests.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index 09ef8e3bfaf9f9..857c68f07a5b84 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -117,10 +117,7 @@ "GeneralCommissioning": ["Test_TC_CGEN_2_2"], "GeneralDiagnostics": ["Test_TC_DGGEN_2_2"], "Identify": ["Test_TC_I_3_2"], - "IcdManagement": [ - "Test_TC_ICDM_3_2", - "Test_TC_ICDM_4_1" - ], + "IcdManagement": ["Test_TC_ICDM_3_2", "Test_TC_ICDM_4_1"], "IlluminanceMeasurement": [], "InteractionDataModel": [ "Test_TC_IDM_1_1", From d84f9c81e2261fcf068492fe8c7384e345a5fa82 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 6 Aug 2024 18:23:51 +0000 Subject: [PATCH 04/18] Restyled by isort --- src/python_testing/TC_ICDM_5_1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python_testing/TC_ICDM_5_1.py b/src/python_testing/TC_ICDM_5_1.py index 987bbfbfb4e613..659ad50d7a4269 100644 --- a/src/python_testing/TC_ICDM_5_1.py +++ b/src/python_testing/TC_ICDM_5_1.py @@ -31,10 +31,10 @@ from dataclasses import dataclass import chip.clusters as Clusters -from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main -from mobly import asserts from chip.interaction_model import InteractionModelError, Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mdns_discovery import mdns_discovery +from mobly import asserts cluster = Clusters.Objects.IcdManagement commands = cluster.Commands From 70890f09004b1859e53d7cb6c464fc63101b825d Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Tue, 6 Aug 2024 18:07:51 -0400 Subject: [PATCH 05/18] Increase discovery timeout --- .../certification/Test_TC_ICDM_5_1.yaml | 145 ------------------ src/python_testing/TC_ICDM_5_1.py | 5 +- 2 files changed, 4 insertions(+), 146 deletions(-) delete mode 100644 src/app/tests/suites/certification/Test_TC_ICDM_5_1.yaml diff --git a/src/app/tests/suites/certification/Test_TC_ICDM_5_1.yaml b/src/app/tests/suites/certification/Test_TC_ICDM_5_1.yaml deleted file mode 100644 index 0e4e0c6b1e793a..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_ICDM_5_1.yaml +++ /dev/null @@ -1,145 +0,0 @@ -# Copyright (c) 2024 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default - -name: 217.2.7. [TC-ICDM-5.1] Functionality with DUT as Client - -PICS: - - ICDM.C - -config: - nodeId: 0x12344321 - cluster: "Basic Information" - endpoint: 0 - -tests: - - label: - "Step 1: DUT issues an C_REGISTER_CLIENT command to the Test Harness." - PICS: ICDM.S.C00.Tx - verification: | - From DUT: - ./chip-tool icdmanagement register-client 1 1 hex:1234567890abcdef1234567890abcdef 1 0 --VerificationKey hex:abcdef1234567890abcdef1234567890 - - From TH: lit-icd-app - [1704407463921] [48858:527745] [DMG] InvokeRequestMessage = - [1704407463921] [48858:527745] [DMG] { - [1704407463921] [48858:527745] [DMG] suppressResponse = false, - [1704407463921] [48858:527745] [DMG] timedRequest = false, - [1704407463921] [48858:527745] [DMG] InvokeRequests = - [1704407463921] [48858:527745] [DMG] [ - [1704407463921] [48858:527745] [DMG] CommandDataIB = - [1704407463921] [48858:527745] [DMG] { - [1704407463921] [48858:527745] [DMG] CommandPathIB = - [1704407463921] [48858:527745] [DMG] { - [1704407463921] [48858:527745] [DMG] EndpointId = 0x0, - [1704407463921] [48858:527745] [DMG] ClusterId = 0x46, - [1704407463921] [48858:527745] [DMG] CommandId = 0x0, - [1704407463921] [48858:527745] [DMG] }, - [1704407463921] [48858:527745] [DMG] - [1704407463921] [48858:527745] [DMG] CommandFields = - [1704407463921] [48858:527745] [DMG] { - [1704407463921] [48858:527745] [DMG] 0x0 = 1, - [1704407463921] [48858:527745] [DMG] 0x1 = 1, - [1704407463921] [48858:527745] [DMG] 0x2 = [ - [1704407463921] [48858:527745] [DMG] 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef, 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef, - [1704407463921] [48858:527745] [DMG] ] (16 bytes) - [1704407463921] [48858:527745] [DMG] 0x3 = [ - [1704407463921] [48858:527745] [DMG] 0xab, 0xcd, 0xef, 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef, 0x12, 0x34, 0x56, 0x78, 0x90, - [1704407463921] [48858:527745] [DMG] ] (16 bytes) - [1704407463921] [48858:527745] [DMG] }, - [1704407463921] [48858:527745] [DMG] }, - [1704407463921] [48858:527745] [DMG] - [1704407463921] [48858:527745] [DMG] ], - [1704407463921] [48858:527745] [DMG] - [1704407463921] [48858:527745] [DMG] InteractionModelRevision = 11 - [1704407463921] [48858:527745] [DMG] }, - disabled: true - - - label: - "Step 2: DUT issues an C_UNREGISTER_CLIENT command to the Test - Harness." - PICS: ICDM.S.C02.Tx - verification: | - From DUT: - ./chip-tool icdmanagement unregister-client 1 1 0 --VerificationKey hex:abcdef1234567890abcdef1234567890 - - From TH: lit-icd-app - [1704407560687] [49015:529245] [DMG] InvokeRequestMessage = - [1704407560687] [49015:529245] [DMG] { - [1704407560687] [49015:529245] [DMG] suppressResponse = false, - [1704407560687] [49015:529245] [DMG] timedRequest = false, - [1704407560687] [49015:529245] [DMG] InvokeRequests = - [1704407560687] [49015:529245] [DMG] [ - [1704407560687] [49015:529245] [DMG] CommandDataIB = - [1704407560687] [49015:529245] [DMG] { - [1704407560687] [49015:529245] [DMG] CommandPathIB = - [1704407560687] [49015:529245] [DMG] { - [1704407560687] [49015:529245] [DMG] EndpointId = 0x0, - [1704407560687] [49015:529245] [DMG] ClusterId = 0x46, - [1704407560687] [49015:529245] [DMG] CommandId = 0x2, - [1704407560687] [49015:529245] [DMG] }, - [1704407560687] [49015:529245] [DMG] - [1704407560687] [49015:529245] [DMG] CommandFields = - [1704407560687] [49015:529245] [DMG] { - [1704407560687] [49015:529245] [DMG] 0x0 = 1, - [1704407560687] [49015:529245] [DMG] 0x1 = [ - [1704407560687] [49015:529245] [DMG] 0xab, 0xcd, 0xef, 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef, 0x12, 0x34, 0x56, 0x78, 0x90, - [1704407560687] [49015:529245] [DMG] ] (16 bytes) - [1704407560687] [49015:529245] [DMG] }, - [1704407560687] [49015:529245] [DMG] }, - [1704407560687] [49015:529245] [DMG] - [1704407560687] [49015:529245] [DMG] ], - [1704407560687] [49015:529245] [DMG] - [1704407560687] [49015:529245] [DMG] InteractionModelRevision = 11 - [1704407560687] [49015:529245] [DMG] }, - disabled: true - - - label: - "Step 3: DUT issues an C_STAY_ACTIVE_REQUEST command to the Test - Harness." - PICS: ICDM.S.C03.Tx - verification: | - From DUT: - ./chip-tool icdmanagement stay-active-request 1 0 - - From TH: lit-icd-app - [1704406259650] [46741:509053] [DMG] InvokeRequestMessage = - [1704406259650] [46741:509053] [DMG] { - [1704406259650] [46741:509053] [DMG] suppressResponse = false, - [1704406259650] [46741:509053] [DMG] timedRequest = false, - [1704406259650] [46741:509053] [DMG] InvokeRequests = - [1704406259650] [46741:509053] [DMG] [ - [1704406259650] [46741:509053] [DMG] CommandDataIB = - [1704406259650] [46741:509053] [DMG] { - [1704406259650] [46741:509053] [DMG] CommandPathIB = - [1704406259650] [46741:509053] [DMG] { - [1704406259650] [46741:509053] [DMG] EndpointId = 0x0, - [1704406259650] [46741:509053] [DMG] ClusterId = 0x46, - [1704406259650] [46741:509053] [DMG] CommandId = 0x3, - [1704406259650] [46741:509053] [DMG] }, - [1704406259650] [46741:509053] [DMG] - [1704406259650] [46741:509053] [DMG] CommandFields = - [1704406259650] [46741:509053] [DMG] { - [1704406259650] [46741:509053] [DMG] }, - [1704406259650] [46741:509053] [DMG] }, - [1704406259650] [46741:509053] [DMG] - [1704406259650] [46741:509053] [DMG] ], - [1704406259650] [46741:509053] [DMG] - [1704406259650] [46741:509053] [DMG] InteractionModelRevision = 11 - [1704406259650] [46741:509053] [DMG] }, - [1704406259650] [46741:509053] [DMG] AccessControl: checking f=1 a=c s=0x000000000001B669 t= c=0x0000_0046 e=0 p=m - [1704406259650] [46741:509053] [DMG] AccessControl: allowed - [1704406259650] [46741:509053] [DMG] Received command for Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0003 - [1704406259650] [46741:509053] [DMG] Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0003 status 0x81 (UNSUPPORTED_COMMAND) (no additional context) - disabled: true diff --git a/src/python_testing/TC_ICDM_5_1.py b/src/python_testing/TC_ICDM_5_1.py index 659ad50d7a4269..1d303af88e556f 100644 --- a/src/python_testing/TC_ICDM_5_1.py +++ b/src/python_testing/TC_ICDM_5_1.py @@ -79,9 +79,12 @@ async def _get_icd_txt_record(self): localCompressedNodeId = hex(self.default_controller.GetCompressedFabricId()) dutNodeId = hex(self.dut_node_id) - services = await discovery.get_all_services(log_output=False) + services = await discovery.get_all_services(log_output=False, discovery_timeout_sec=120) icdTxtRecord = modes.kUnknownEnumValue.value + asserts.assert_true(mdns_discovery.MdnsServiceType.OPERATIONAL.value in services, + "Could not find ICD operational service information.") + for service in services[mdns_discovery.MdnsServiceType.OPERATIONAL.value]: # Generate hex for the compressedFabric and NodeId From ce456e80b93cc0fc1d3b2565001c6aa256ccfd14 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Wed, 7 Aug 2024 08:51:50 -0400 Subject: [PATCH 06/18] Set log to true to debug CI --- src/python_testing/TC_ICDM_5_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_ICDM_5_1.py b/src/python_testing/TC_ICDM_5_1.py index 1d303af88e556f..8db3a9e3058074 100644 --- a/src/python_testing/TC_ICDM_5_1.py +++ b/src/python_testing/TC_ICDM_5_1.py @@ -79,7 +79,7 @@ async def _get_icd_txt_record(self): localCompressedNodeId = hex(self.default_controller.GetCompressedFabricId()) dutNodeId = hex(self.dut_node_id) - services = await discovery.get_all_services(log_output=False, discovery_timeout_sec=120) + services = await discovery.get_all_services(log_output=True, discovery_timeout_sec=120) icdTxtRecord = modes.kUnknownEnumValue.value asserts.assert_true(mdns_discovery.MdnsServiceType.OPERATIONAL.value in services, From d89f2ceb172743e49836761ad2004ab138a28dd6 Mon Sep 17 00:00:00 2001 From: yunhanw-google Date: Mon, 19 Aug 2024 10:40:58 -0700 Subject: [PATCH 07/18] Update tests.yaml --- .github/workflows/tests.yaml | 107 ----------------------------------- 1 file changed, 107 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index abbd217698acbf..dbbda0aa36580f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -506,113 +506,6 @@ jobs: run: | mkdir -p out/trace_data scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/controller/python/test/test_scripts/mobile-device-test.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ACE_1_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ACE_1_3.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ACE_1_4.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ACE_1_5.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_AccessChecker.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_CC_2_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_CC_10_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_CADMIN_1_9.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_CGEN_2_4.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_CNET_1_4.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DA_1_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DA_1_5.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DA_1_7.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DGGEN_2_4.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DRLK_2_12.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DRLK_2_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DRLK_2_3.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DeviceBasicComposition.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DeviceConformance.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DEM_2_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DEM_2_3.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DEM_2_4.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DEM_2_5.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DEM_2_6.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DEM_2_7.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DEM_2_8.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DEM_2_9.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_EEM_2_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_EEM_2_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_EEM_2_3.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_EEM_2_4.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_EEM_2_5.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_EEVSE_2_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_EEVSE_2_3.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_EEVSE_2_4.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_EEVSE_2_5.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_EPM_2_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_EPM_2_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_FAN_3_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_FAN_3_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_FAN_3_3.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_FAN_3_4.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_FAN_3_5.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ICDM_2_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ICDM_3_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ICDM_3_3.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ICDM_5_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ICDManagementCluster.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_IDM_1_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_IDM_1_4.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_IDM_4_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_PWRTL_2_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_RR_1_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_SC_3_6.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TIMESYNC_2_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TIMESYNC_2_10.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TIMESYNC_2_11.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TIMESYNC_2_12.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TIMESYNC_2_13.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TIMESYNC_2_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TIMESYNC_2_4.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TIMESYNC_2_5.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TIMESYNC_2_6.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TIMESYNC_2_7.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TIMESYNC_2_8.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TIMESYNC_2_9.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TIMESYNC_3_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TestEventTrigger.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TestBatchInvoke.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TestGroupTableReports.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OCC_2_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OCC_2_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OCC_2_3.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OPCREDS_3_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OPCREDS_3_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OPSTATE_2_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OPSTATE_2_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OPSTATE_2_3.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OPSTATE_2_4.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OPSTATE_2_5.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OPSTATE_2_6.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OVENOPSTATE_2_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OVENOPSTATE_2_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OVENOPSTATE_2_3.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OVENOPSTATE_2_4.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OVENOPSTATE_2_5.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_MWOCTRL_2_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_MWOCTRL_2_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_MWOCTRL_2_4.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_MWOM_1_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_PS_2_3.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_RVCRUNM_1_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_RVCRUNM_2_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_RVCRUNM_2_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_RVCCLEANM_1_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_RVCCLEANM_2_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_RVCCLEANM_2_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_RVCOPSTATE_2_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_RVCOPSTATE_2_3.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_RVCOPSTATE_2_4.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_SC_7_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_SWTCH.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_WHM_1_2.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_WHM_2_1.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_LVL_2_3.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TCP_Tests.py' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestConformanceSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/execute_python_tests.py --env-file /tmp/test_env.yaml --search-directory src/python_testing' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestMatterTestingSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestSpecParsingSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' From 4ef62e7b6d017269a62c70a6aa3e6d7c3ab98963 Mon Sep 17 00:00:00 2001 From: yunhanw-google Date: Thu, 22 Aug 2024 14:28:25 -0700 Subject: [PATCH 08/18] Increase discovery timeout --- src/python_testing/TC_ICDM_5_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_ICDM_5_1.py b/src/python_testing/TC_ICDM_5_1.py index 8db3a9e3058074..ad3ad9f7a69dd4 100644 --- a/src/python_testing/TC_ICDM_5_1.py +++ b/src/python_testing/TC_ICDM_5_1.py @@ -79,7 +79,7 @@ async def _get_icd_txt_record(self): localCompressedNodeId = hex(self.default_controller.GetCompressedFabricId()) dutNodeId = hex(self.dut_node_id) - services = await discovery.get_all_services(log_output=True, discovery_timeout_sec=120) + services = await discovery.get_all_services(log_output=True, discovery_timeout_sec=240) icdTxtRecord = modes.kUnknownEnumValue.value asserts.assert_true(mdns_discovery.MdnsServiceType.OPERATIONAL.value in services, From 5d4bdc2f617a9a98b3c3da36efbb6f0a69cdd850 Mon Sep 17 00:00:00 2001 From: yunhanw-google Date: Tue, 27 Aug 2024 10:48:48 -0700 Subject: [PATCH 09/18] Update manualTests.json --- src/app/tests/suites/manualTests.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index 57a3553ea14a61..3b0b354840e1c6 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -117,7 +117,7 @@ "GeneralCommissioning": ["Test_TC_CGEN_2_2"], "GeneralDiagnostics": ["Test_TC_DGGEN_2_2"], "Identify": ["Test_TC_I_3_2"], - "IcdManagement": ["Test_TC_ICDM_4_1"], + "IcdManagement": [], "IlluminanceMeasurement": [], "InteractionDataModel": [ "Test_TC_IDM_1_1", From c731dbcb80bbb29793c270ee8e7e31942295de5a Mon Sep 17 00:00:00 2001 From: yunhanw-google Date: Tue, 27 Aug 2024 13:55:11 -0700 Subject: [PATCH 10/18] debugging TC_ICDM_5_1.py --- src/python_testing/TC_ICDM_5_1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/python_testing/TC_ICDM_5_1.py b/src/python_testing/TC_ICDM_5_1.py index ad3ad9f7a69dd4..bfce8ca0fc86f0 100644 --- a/src/python_testing/TC_ICDM_5_1.py +++ b/src/python_testing/TC_ICDM_5_1.py @@ -81,7 +81,8 @@ async def _get_icd_txt_record(self): services = await discovery.get_all_services(log_output=True, discovery_timeout_sec=240) icdTxtRecord = modes.kUnknownEnumValue.value - + print("debugging mdns") + print(services) asserts.assert_true(mdns_discovery.MdnsServiceType.OPERATIONAL.value in services, "Could not find ICD operational service information.") From c4184e2b5a71fafac9652c5eb5c3c398c919a47f Mon Sep 17 00:00:00 2001 From: yunhanw-google Date: Fri, 30 Aug 2024 15:43:22 -0700 Subject: [PATCH 11/18] dump ufw for mdns discovery in ci --- .github/workflows/tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index dbbda0aa36580f..261472fcd36a8a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -76,6 +76,7 @@ jobs: mkdir /tmp/cores || true sysctl -w kernel.core_pattern=/tmp/cores/core.%u.%p.%t || true mkdir objdir-clone || true + cat /etc/default/ufw || true - name: Validate that xml are parsable # The sub-items being run here are the same as the input XMLs listed From 93f2c9910552902ae7460095d843a1a207987b91 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 5 Sep 2024 16:39:51 -0400 Subject: [PATCH 12/18] Apply fixes for style and dnssd logic --- src/python_testing/TC_ICDM_5_1.py | 75 ++++++++----------- .../mdns_discovery/mdns_discovery.py | 56 ++++++-------- 2 files changed, 57 insertions(+), 74 deletions(-) diff --git a/src/python_testing/TC_ICDM_5_1.py b/src/python_testing/TC_ICDM_5_1.py index bfce8ca0fc86f0..60380473d02060 100644 --- a/src/python_testing/TC_ICDM_5_1.py +++ b/src/python_testing/TC_ICDM_5_1.py @@ -27,6 +27,7 @@ # test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # === END CI TEST ARGUMENTS === +import asyncio import logging from dataclasses import dataclass @@ -36,11 +37,11 @@ from mdns_discovery import mdns_discovery from mobly import asserts -cluster = Clusters.Objects.IcdManagement -commands = cluster.Commands -attributes = cluster.Attributes -modes = cluster.Enums.OperatingModeEnum -ClientTypeEnum = cluster.Enums.ClientTypeEnum +Cluster = Clusters.Objects.IcdManagement +Commands = Cluster.Commands +Attributes = Cluster.Attributes +OperatingModeEnum = Cluster.Enums.OperatingModeEnum +ClientTypeEnum = Cluster.Enums.ClientTypeEnum @dataclass @@ -68,34 +69,22 @@ class TC_ICDM_5_1(MatterBaseTest): # Class Helper functions # - async def _read_icdm_attribute_expect_success(self, attribute): - return await self.read_single_attribute_check_success(endpoint=kRootEndpointId, cluster=cluster, attribute=attribute) + async def _read_icdm_attribute_expect_success(self, attribute) -> OperatingModeEnum: + return await self.read_single_attribute_check_success(endpoint=kRootEndpointId, cluster=Cluster, attribute=attribute) async def _send_single_icdm_command(self, command): return await self.send_single_cmd(command, endpoint=kRootEndpointId) - async def _get_icd_txt_record(self): + async def _get_icd_txt_record(self) -> OperatingModeEnum: discovery = mdns_discovery.MdnsDiscovery() - localCompressedNodeId = hex(self.default_controller.GetCompressedFabricId()) - dutNodeId = hex(self.dut_node_id) + service = await discovery.get_operational_service( + node_id=self.dut_node_id, + compressed_fabric_id=self.default_controller.GetCompressedFabricId(), + log_output=True, discovery_timeout_sec=240) - services = await discovery.get_all_services(log_output=True, discovery_timeout_sec=240) - icdTxtRecord = modes.kUnknownEnumValue.value - print("debugging mdns") - print(services) - asserts.assert_true(mdns_discovery.MdnsServiceType.OPERATIONAL.value in services, - "Could not find ICD operational service information.") - - for service in services[mdns_discovery.MdnsServiceType.OPERATIONAL.value]: - - # Generate hex for the compressedFabric and NodeId - serviceName = service.instance_name.split("-") - compressedFabric = hex(int(serviceName[0], 16)) - nodeId = hex(int(serviceName[1], 16)) - - # Find the correct MdnsServiceEntry - if localCompressedNodeId == compressedFabric and dutNodeId == nodeId: - icdTxtRecord = service.txt_record['ICD'] + icdTxtRecord = OperatingModeEnum(int(service.txt_record['ICD'])) + if icdTxtRecord.value != int(service.txt_record['ICD']): + raise AttributeError(f'Not a known ICD type: {service.txt_record["ICD"]}') return icdTxtRecord @@ -143,60 +132,62 @@ async def test_TC_ICDM_5_1(self): try: self.step(1) registeredClients = await self._read_icdm_attribute_expect_success( - attributes.RegisteredClients) + Attributes.RegisteredClients) for client in registeredClients: try: - await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=client.checkInNodeID)) + await self._send_single_icdm_command(Commands.UnregisterClient(checkInNodeID=client.checkInNodeID)) except InteractionModelError as e: asserts.assert_equal( e.status, Status.Success, "Unexpected error returned") self.step("2a") - operatingMode = await self._read_icdm_attribute_expect_success(attributes.OperatingMode) - asserts.assert_equal(operatingMode, modes.kSit.value) + operatingMode = await self._read_icdm_attribute_expect_success(Attributes.OperatingMode) + asserts.assert_equal(operatingMode, OperatingModeEnum.kSit) self.step("2b") icdTxtRecord = await self._get_icd_txt_record() - asserts.assert_equal(int(icdTxtRecord), modes.kSit.value, "OperatingMode Is not in SIT mode.") + asserts.assert_equal(icdTxtRecord, OperatingModeEnum.kSit, "OperatingMode Is not in SIT mode.") self.step("3a") try: - await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=client1.checkInNodeID, monitoredSubject=client1.subjectId, key=client1.key, clientType=client1.clientType)) + await self._send_single_icdm_command(Commands.RegisterClient(checkInNodeID=client1.checkInNodeID, monitoredSubject=client1.subjectId, key=client1.key, clientType=client1.clientType)) except InteractionModelError as e: asserts.assert_equal( e.status, Status.Success, "Unexpected error returned") self.step("3b") - operatingMode = await self._read_icdm_attribute_expect_success(attributes.OperatingMode) - asserts.assert_equal(operatingMode, modes.kLit.value) + operatingMode = await self._read_icdm_attribute_expect_success(Attributes.OperatingMode) + asserts.assert_equal(operatingMode, OperatingModeEnum.kLit) + + # await asyncio.sleep(1) self.step("3c") icdTxtRecord = await self._get_icd_txt_record() - asserts.assert_equal(int(icdTxtRecord), modes.kLit.value, "OperatingMode Is not in Lit mode.") + asserts.assert_equal(icdTxtRecord, OperatingModeEnum.kLit, "OperatingMode Is not in Lit mode.") self.step(4) try: - await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=client1.checkInNodeID)) + await self._send_single_icdm_command(Commands.UnregisterClient(checkInNodeID=client1.checkInNodeID)) except InteractionModelError as e: asserts.assert_equal( e.status, Status.Success, "Unexpected error returned") self.step("5a") - operatingMode = await self._read_icdm_attribute_expect_success(attributes.OperatingMode) - asserts.assert_equal(operatingMode, modes.kSit.value) + operatingMode = await self._read_icdm_attribute_expect_success(Attributes.OperatingMode) + asserts.assert_equal(operatingMode, OperatingModeEnum.kSit) self.step("5b") icdTxtRecord = await self._get_icd_txt_record() - asserts.assert_equal(int(icdTxtRecord), modes.kSit.value, "OperatingMode Is not in SIT mode.") + asserts.assert_equal(icdTxtRecord, OperatingModeEnum.kSit, "OperatingMode Is not in SIT mode.") finally: registeredClients = await self._read_icdm_attribute_expect_success( - attributes.RegisteredClients) + Attributes.RegisteredClients) for client in registeredClients: try: - await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=client.checkInNodeID)) + await self._send_single_icdm_command(Commands.UnregisterClient(checkInNodeID=client.checkInNodeID)) except InteractionModelError as e: asserts.assert_equal( e.status, Status.Success, "Unexpected error returned") diff --git a/src/python_testing/mdns_discovery/mdns_discovery.py b/src/python_testing/mdns_discovery/mdns_discovery.py index 86661d65729da3..26ba8e08978406 100644 --- a/src/python_testing/mdns_discovery/mdns_discovery.py +++ b/src/python_testing/mdns_discovery/mdns_discovery.py @@ -99,6 +99,9 @@ def __init__(self): # A list of service types self._service_types = [] + # Filtering to apply for received data items + self._name_filter = None + # An asyncio Event to signal when a service has been discovered self._event = asyncio.Event() @@ -116,6 +119,7 @@ async def get_commissioner_service(self, log_output: bool = False, Returns: Optional[MdnsServiceInfo]: An instance of MdnsServiceInfo or None if timeout reached. """ + self._name_filter = None return await self._get_service(MdnsServiceType.COMMISSIONER, log_output, discovery_timeout_sec) async def get_commissionable_service(self, log_output: bool = False, @@ -131,10 +135,12 @@ async def get_commissionable_service(self, log_output: bool = False, Returns: Optional[MdnsServiceInfo]: An instance of MdnsServiceInfo or None if timeout reached. """ + self._name_filter = None return await self._get_service(MdnsServiceType.COMMISSIONABLE, log_output, discovery_timeout_sec) - async def get_operational_service(self, service_name: str = None, - service_type: str = None, + async def get_operational_service(self, + node_id: Optional[int] = None, + compressed_fabric_id: Optional[int] = None, discovery_timeout_sec: float = DISCOVERY_TIMEOUT_SEC, log_output: bool = False ) -> Optional[MdnsServiceInfo]: @@ -144,35 +150,16 @@ async def get_operational_service(self, service_name: str = None, Args: log_output (bool): Logs the discovered services to the console. Defaults to False. discovery_timeout_sec (float): Defaults to 15 seconds. - service_name (str): The unique name of the mDNS service. Defaults to None. - service_type (str): The service type of the service. Defaults to None. + node_id: the node id to create the service name from + compressed_fabric_id: the fabric id to create the service name from Returns: Optional[MdnsServiceInfo]: An instance of MdnsServiceInfo or None if timeout reached. """ # Validation to ensure both or none of the parameters are provided - if (service_name is None) != (service_type is None): - raise ValueError("Both service_name and service_type must be provided together or not at all.") - - mdns_service_info = None - - if service_name is None and service_type is None: - mdns_service_info = await self._get_service(MdnsServiceType.OPERATIONAL, log_output, discovery_timeout_sec) - else: - print(f"Looking for MDNS service type '{service_type}', service name '{service_name}'") - - # Get service info - service_info = AsyncServiceInfo(service_type, service_name) - is_discovered = await service_info.async_request(self._zc, 3000) - if is_discovered: - mdns_service_info = self._to_mdns_service_info_class(service_info) - self._discovered_services = {} - self._discovered_services[service_type] = [mdns_service_info] - if log_output: - self._log_output() - - return mdns_service_info + self._name_filter = f'{compressed_fabric_id:016x}-{node_id:016x}.{MdnsServiceType.OPERATIONAL.value}'.upper() + return await self._get_service(MdnsServiceType.OPERATIONAL, log_output, discovery_timeout_sec) async def get_border_router_service(self, log_output: bool = False, discovery_timeout_sec: float = DISCOVERY_TIMEOUT_SEC @@ -276,13 +263,18 @@ def _on_service_state_change( Returns: None: This method does not return any value. """ - if state_change.value == ServiceStateChange.Added.value: - self._event.set() - asyncio.ensure_future(self._query_service_info( - zeroconf, - service_type, - name) - ) + if state_change.value == ServiceStateChange.Removed.value: + return + + if self._name_filter is not None and name.upper() != self._name_filter: + return + + self._event.set() + asyncio.ensure_future(self._query_service_info( + zeroconf, + service_type, + name) + ) async def _query_service_info(self, zeroconf: Zeroconf, service_type: str, service_name: str) -> None: """ From ee1331fb01e2052b59eddcaedbfd18585c821146 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 5 Sep 2024 16:41:53 -0400 Subject: [PATCH 13/18] Remove some debug code --- src/python_testing/TC_ICDM_5_1.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/python_testing/TC_ICDM_5_1.py b/src/python_testing/TC_ICDM_5_1.py index 60380473d02060..6f4d3ffb54bcb8 100644 --- a/src/python_testing/TC_ICDM_5_1.py +++ b/src/python_testing/TC_ICDM_5_1.py @@ -27,7 +27,6 @@ # test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # === END CI TEST ARGUMENTS === -import asyncio import logging from dataclasses import dataclass @@ -160,8 +159,6 @@ async def test_TC_ICDM_5_1(self): operatingMode = await self._read_icdm_attribute_expect_success(Attributes.OperatingMode) asserts.assert_equal(operatingMode, OperatingModeEnum.kLit) - # await asyncio.sleep(1) - self.step("3c") icdTxtRecord = await self._get_icd_txt_record() asserts.assert_equal(icdTxtRecord, OperatingModeEnum.kLit, "OperatingMode Is not in Lit mode.") From 3f044d10f1c7dba9403580c4c77a543bb327a263 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 5 Sep 2024 16:43:05 -0400 Subject: [PATCH 14/18] Undo ufw change --- .github/workflows/tests.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 40607b42121c96..a99cc0a24d1f98 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -76,7 +76,6 @@ jobs: mkdir /tmp/cores || true sysctl -w kernel.core_pattern=/tmp/cores/core.%u.%p.%t || true mkdir objdir-clone || true - cat /etc/default/ufw || true - name: Validate that xml are parsable # The sub-items being run here are the same as the input XMLs listed From 029cf7db16baa3fdd6e5e79851b2d56497796a92 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 5 Sep 2024 16:44:00 -0400 Subject: [PATCH 15/18] One more readability update now that I update this file --- src/python_testing/TC_ICDM_5_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_ICDM_5_1.py b/src/python_testing/TC_ICDM_5_1.py index 6f4d3ffb54bcb8..e0417ff52bf1dc 100644 --- a/src/python_testing/TC_ICDM_5_1.py +++ b/src/python_testing/TC_ICDM_5_1.py @@ -57,7 +57,7 @@ class Client: client1 = Client( checkInNodeID=1, subjectId=1, - key=b"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", + key=bytes([x for x in range(0x10, 0x20)]), clientType=ClientTypeEnum.kEphemeral ) From 63631e262cf862d2e0572283771b58b4216c137f Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 5 Sep 2024 20:14:40 -0400 Subject: [PATCH 16/18] Better error message on service not found --- src/python_testing/TC_ICDM_5_1.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/python_testing/TC_ICDM_5_1.py b/src/python_testing/TC_ICDM_5_1.py index e0417ff52bf1dc..16da6e20d5c9e7 100644 --- a/src/python_testing/TC_ICDM_5_1.py +++ b/src/python_testing/TC_ICDM_5_1.py @@ -81,6 +81,9 @@ async def _get_icd_txt_record(self) -> OperatingModeEnum: compressed_fabric_id=self.default_controller.GetCompressedFabricId(), log_output=True, discovery_timeout_sec=240) + asserts.assert_is_not_none( + service, f"Failed to get operational node service information for {self.dut_node_id} on {self.default_controller.GetCompressedFabricId()}") + icdTxtRecord = OperatingModeEnum(int(service.txt_record['ICD'])) if icdTxtRecord.value != int(service.txt_record['ICD']): raise AttributeError(f'Not a known ICD type: {service.txt_record["ICD"]}') From 1ea443206a336cc818c5045a41df16b23a2d8474 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 5 Sep 2024 20:30:22 -0400 Subject: [PATCH 17/18] A few more updates for logging and logic when to unlock events --- src/python_testing/TC_ICDM_5_1.py | 2 +- .../mdns_discovery/mdns_discovery.py | 42 +++++++++++++++---- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/python_testing/TC_ICDM_5_1.py b/src/python_testing/TC_ICDM_5_1.py index 16da6e20d5c9e7..f9c081b6fe56ce 100644 --- a/src/python_testing/TC_ICDM_5_1.py +++ b/src/python_testing/TC_ICDM_5_1.py @@ -75,7 +75,7 @@ async def _send_single_icdm_command(self, command): return await self.send_single_cmd(command, endpoint=kRootEndpointId) async def _get_icd_txt_record(self) -> OperatingModeEnum: - discovery = mdns_discovery.MdnsDiscovery() + discovery = mdns_discovery.MdnsDiscovery(verbose_logging=True) service = await discovery.get_operational_service( node_id=self.dut_node_id, compressed_fabric_id=self.default_controller.GetCompressedFabricId(), diff --git a/src/python_testing/mdns_discovery/mdns_discovery.py b/src/python_testing/mdns_discovery/mdns_discovery.py index 26ba8e08978406..4e935ba899510c 100644 --- a/src/python_testing/mdns_discovery/mdns_discovery.py +++ b/src/python_testing/mdns_discovery/mdns_discovery.py @@ -17,7 +17,9 @@ import asyncio +import logging import json + from dataclasses import asdict, dataclass from enum import Enum from typing import Dict, List, Optional @@ -25,6 +27,7 @@ from zeroconf import IPVersion, ServiceStateChange, Zeroconf from zeroconf.asyncio import AsyncServiceBrowser, AsyncServiceInfo, AsyncZeroconfServiceTypes +logger = logging.getLogger(__name__) @dataclass class MdnsServiceInfo: @@ -79,7 +82,7 @@ class MdnsDiscovery: DISCOVERY_TIMEOUT_SEC = 15 - def __init__(self): + def __init__(self, verbose_logging:bool=False): """ Initializes the MdnsDiscovery instance. @@ -105,6 +108,9 @@ def __init__(self): # An asyncio Event to signal when a service has been discovered self._event = asyncio.Event() + # Verbose logging + self._verbose_logging = verbose_logging + # Public methods async def get_commissioner_service(self, log_output: bool = False, discovery_timeout_sec: float = DISCOVERY_TIMEOUT_SEC @@ -224,7 +230,7 @@ async def _discover(self, if all_services: self._service_types = list(await AsyncZeroconfServiceTypes.async_find()) - print(f"Browsing for MDNS service(s) of type: {self._service_types}") + logger.info(f"Browsing for MDNS service(s) of type: {self._service_types}") aiobrowser = AsyncServiceBrowser(zeroconf=self._zc, type_=self._service_types, @@ -234,7 +240,7 @@ async def _discover(self, try: await asyncio.wait_for(self._event.wait(), timeout=discovery_timeout_sec) except asyncio.TimeoutError: - print(f"MDNS service discovery timed out after {discovery_timeout_sec} seconds.") + logger.error("MDNS service discovery timed out after %d seconds.", discovery_timeout_sec) finally: await aiobrowser.async_cancel() @@ -263,13 +269,20 @@ def _on_service_state_change( Returns: None: This method does not return any value. """ + if self._verbose_logging: + logger.info("Service state change: %s on %s/%s", state_change, name, service_type) + if state_change.value == ServiceStateChange.Removed.value: return if self._name_filter is not None and name.upper() != self._name_filter: + if self._verbose_logging: + logger.info(" Name does NOT match %s", self._name_filter) return - self._event.set() + if self._verbose_logging: + logger.info("Received service data. Unlocking service information") + asyncio.ensure_future(self._query_service_info( zeroconf, service_type, @@ -296,12 +309,19 @@ async def _query_service_info(self, zeroconf: Zeroconf, service_type: str, servi service_info.async_clear_cache() if is_service_discovered: + if self._verbose_logging: + logger.warning("Service discovered for %s/%s.", service_name, service_type) + mdns_service_info = self._to_mdns_service_info_class(service_info) if service_type not in self._discovered_services: self._discovered_services[service_type] = [mdns_service_info] else: self._discovered_services[service_type].append(mdns_service_info) + elif self._verbose_logging: + logger.warning("Service information not found.") + + self._event.set() def _to_mdns_service_info_class(self, service_info: AsyncServiceInfo) -> MdnsServiceInfo: """ @@ -347,21 +367,25 @@ async def _get_service(self, service_type: MdnsServiceType, any. Returns None if no service of the specified type is discovered within the timeout period. """ - mdns_service_info = None self._service_types = [service_type.value] await self._discover(discovery_timeout_sec, log_output) + + if self._verbose_logging: + logger.info("Getting service from discovered services: %s", self._discovered_services) + if service_type.value in self._discovered_services: - mdns_service_info = self._discovered_services[service_type.value][0] + return self._discovered_services[service_type.value][0] + else: + return None - return mdns_service_info def _log_output(self) -> str: """ - Converts the discovered services to a JSON string and prints it. + Converts the discovered services to a JSON string and log it. The method is intended to be used for debugging or informational purposes, providing a clear and comprehensive view of all services discovered during the mDNS service discovery process. """ converted_services = {key: [asdict(item) for item in value] for key, value in self._discovered_services.items()} json_str = json.dumps(converted_services, indent=4) - print(json_str) + logger.info("Discovery data:\n%s", json_str) From 260cfab842b2618a174cf8e57c679bbb32845016 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 5 Sep 2024 20:30:40 -0400 Subject: [PATCH 18/18] Restyle --- src/python_testing/mdns_discovery/mdns_discovery.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/python_testing/mdns_discovery/mdns_discovery.py b/src/python_testing/mdns_discovery/mdns_discovery.py index 4e935ba899510c..f8c9d46d70760a 100644 --- a/src/python_testing/mdns_discovery/mdns_discovery.py +++ b/src/python_testing/mdns_discovery/mdns_discovery.py @@ -17,9 +17,8 @@ import asyncio -import logging import json - +import logging from dataclasses import asdict, dataclass from enum import Enum from typing import Dict, List, Optional @@ -29,6 +28,7 @@ logger = logging.getLogger(__name__) + @dataclass class MdnsServiceInfo: # The unique name of the mDNS service. @@ -82,7 +82,7 @@ class MdnsDiscovery: DISCOVERY_TIMEOUT_SEC = 15 - def __init__(self, verbose_logging:bool=False): + def __init__(self, verbose_logging: bool = False): """ Initializes the MdnsDiscovery instance. @@ -378,7 +378,6 @@ async def _get_service(self, service_type: MdnsServiceType, else: return None - def _log_output(self) -> str: """ Converts the discovered services to a JSON string and log it.