From 27681931d6225e581b8b84aec8f33335a50ebf36 Mon Sep 17 00:00:00 2001 From: William Date: Sat, 10 Aug 2024 00:21:06 +0100 Subject: [PATCH] Fix test 1.3 and 1.4 (#34911) * Updated the golabl data type's XMLs, removing the cluster entries. * Zap generated after XML update. * Fixed namespaces used of global structs. * Restyled by clang-format * Renamed LocationInfoStruct to AreaInfoStruct. * Zap generated after XML update. * Renamed LocationStruct to AreaStruct and its LocationID and LocationDesc fields. * Zap generated after XML update. * Updated SDK and example code to match the new naming. * Updated the ProgressStruct's LocationID name to AreaID. * Zap generated after XML update. * Updated the SDK code following name changes. * Updated the SelectLocationsStatus and SkipLocationStatus enum names and some of their enums. * Zap generated after XML update. * Updated the SelectLocationsStatus and SkipCurrentLocationStatus names and their enum names. * Updated the names of the SupportedLocations, SelectedLocations and CurrentLocation attributes. * Zap generated after XML update. * Updated the changed names in the SDK. * Updated the service area command names in XML. * Zap generated after XML update. * Updated the service area command names in the SDK. * Updated the rvc-example zap file. * Refactored LocationStructureWrapper to AreaStructureWrapper. * Restyled by clang-format * Regenerated zap files due to changes upsteram. * Removed unused generated file. * Updated the Service Area XML marking previously nullabel attributes as not-nullable. * Zap generated after XML update. * Updated the attribute encoding and some server logic following the romoval of the nullable quality for some attributes. * Explicitly set the Service Area version. * Zap generated after XML update. * Updated the service area features in the XML to match the current spec. * Zap generated after XML update. * Updated the SupportedArea validation logic as if the MAPS feature is not supported, the Delegate may choose not to implement map related methods. * Change the type of the MapID to uint32 to match the spec. * Added the SkippedArea arg to the SkipArea command. * Zap generated after XML update. * Updated the Service Area server code to handle the new SkippedArea command arg. * Updated the service area XML to match the current spec. This includes the addition of the LandmarkInfoStruct and updates of AreaInfoStruct, SelectAreasStatus. * Zap generated after XML update. * Updated SDK server code and rvc-example after changes to the XML. * Restyled by whitespace * added vector include. * spacing changes form zap regen. * Fixed minor mistake during merge. * Restyled by clang-format * Applied suggestions from review. * Restyled by whitespace * Updated the LondmarkInfoSturct PositionTag type. * Zap generated after XML update. * Fixed SDK following update to the position type. * Restyled by clang-format * Updated the AeraStructWrapper to not contain methods with a large number of params. Updated some relate Instance and Delegate methods. * Restyled by whitespace * Restyled by clang-format * Missed a submudule update. * Made the setters reture a ref to the sturct to allow chaining. * simplified the = oporator and add the == operator. * Restyled by clang-format * Added methods to set the SupportedMaps and SupproctedAreas. * Updated the RVC app to provide a way to defined service area methods that interacte with other clusters in the RvcDevice class. * Fixed typo. * minor change to get restyler going. * Restyled by clang-format * Fixed status text referance issue. * Fixed issue casued by a change in the way that registrations are made. * Fixed styling and minor bug in IsValidSupportedArea. * Implemented the IsValidSelectAreasSet method. * implemented SaHandleSkipCurrentArea. * Restyled by clang-format * Added methods to updated the service area current area and progress attributes when the device starts operating. * Updated the handle skip area method to use the GoToNextArea method. * Added the AreaComplete out-of-band message. * updated the reset evet handler to reset the service area attributes. * minor shifing of responsibilites. * Restyled by clang-format * reverted to adding the PID to the fifo name. * Updated readme and pics files. * Restyled by prettier-markdown * Fixed tests 1.3 and 1.4. Updated the readme and the pics. * Restyled by prettier-markdown --------- Co-authored-by: Restyled.io --- examples/rvc-app/README.md | 20 ++++++++++ .../rvc-common/pics/rvc-app-pics-values | 2 +- src/python_testing/TC_SEAR_1_3.py | 37 +++++++++++-------- src/python_testing/TC_SEAR_1_4.py | 4 -- 4 files changed, 43 insertions(+), 20 deletions(-) diff --git a/examples/rvc-app/README.md b/examples/rvc-app/README.md index 7431c663efe4f9..1be714fb437850 100644 --- a/examples/rvc-app/README.md +++ b/examples/rvc-app/README.md @@ -136,3 +136,23 @@ to transition to the required states. After commissioning the device, all the yaml tests can be run by running the `run_all_yaml_tests.sh` script from the root dir with the node ID that the device was commissioned with. + +### Service Area Cluster + +### TC 1.2 + +Example command: +`./scripts/tests/run_python_test.py --script src/python_testing/TC_SEAR_1_2.py --script-args "--storage-path admin_storage.json --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1"` + +### TC 1.3 + +todo once the +[test plan issue](https://github.com/CHIP-Specifications/chip-test-plans/issues/4454) +is resolved, add the required PIXIT and set the +PICS`SEAR.S.M.VALID_STATE_FOR_SELECT_AREAS=1`. PIXIT: `` Example command: +`./scripts/tests/run_python_test.py --script src/python_testing/TC_SEAR_1_3.py --script-args "--storage-path admin_storage.json --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1` + +### TC 1.4 + +Example command: +`./scripts/tests/run_python_test.py --script src/python_testing/TC_SEAR_1_4.py --script-args "--storage-path admin_storage.json --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1` diff --git a/examples/rvc-app/rvc-common/pics/rvc-app-pics-values b/examples/rvc-app/rvc-common/pics/rvc-app-pics-values index b158de538ed547..24558915f6fed0 100644 --- a/examples/rvc-app/rvc-common/pics/rvc-app-pics-values +++ b/examples/rvc-app/rvc-common/pics/rvc-app-pics-values @@ -70,7 +70,7 @@ SEAR.S.M.ADD_AREA=0 SEAR.S.M.REMOVE_MAP=0 SEAR.S.M.ADD_MAP=0 SEAR.S.M.INVALID_STATE_FOR_SELECT_AREAS=1 -SEAR.S.M.VALID_STATE_FOR_SELECT_AREAS=1 +SEAR.S.M.VALID_STATE_FOR_SELECT_AREAS=0 SEAR.S.M.SELECT_AREAS_WHILE_NON_IDLE=1 SEAR.S.M.HAS_MANUAL_SELAREA_STATE_CONTROL=1 SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL=1 diff --git a/src/python_testing/TC_SEAR_1_3.py b/src/python_testing/TC_SEAR_1_3.py index 3e8d60fa6a24f8..2ea2e86b7d198d 100644 --- a/src/python_testing/TC_SEAR_1_3.py +++ b/src/python_testing/TC_SEAR_1_3.py @@ -51,7 +51,7 @@ async def read_supported_areas(self, step): self.print_step(step, "Read SupportedAreas attribute") supported_areas = await self.read_sear_attribute_expect_success( endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SupportedAreas) - logging.info("SupportedAreas: %s" % (supported_areas)) + logging.info("SupportedAreas: %s" % supported_areas) self.supported_areas = supported_areas @@ -70,16 +70,16 @@ async def send_cmd_select_areas_expect_response(self, step, new_areas, expected_ ret = await self.send_single_cmd(cmd=Clusters.Objects.ServiceArea.Commands.SelectAreas(newAreas=new_areas), endpoint=self.endpoint) - asserts.assert_equal(ret.commandResponseState.errorStateID, + asserts.assert_equal(ret.status, expected_response, - f"Command response ({ret.commandResponseState}) doesn't match the expected one") + f"Command response ({ret.status}) doesn't match the expected one") # Sends and out-of-band command to the rvc-app def write_to_app_pipe(self, command): with open(self.app_pipe, "w") as app_pipe: app_pipe.write(command + "\n") # Allow some time for the command to take effect. - # This removes the test flakyness which is very annoying for everyone in CI. + # This removes the test flakiness which is very annoying for everyone in CI. sleep(0.001) def TC_SEAR_1_3(self) -> list[str]: @@ -110,47 +110,54 @@ async def test_TC_SEAR_1_3(self): duplicated_areas = [valid_area_id, valid_area_id] # FIXME need to check if this is the correct name of this status code - await self.send_cmd_select_areas_expect_response(step=3, new_areas=duplicated_areas, expected_response=Clusters.ServiceArea.SelectAreasStatus.kDuplicatedAreas) + await self.send_cmd_select_areas_expect_response(step=3, new_areas=duplicated_areas, expected_response=Clusters.ServiceArea.Enums.SelectAreasStatus.kDuplicatedAreas) - await self.send_cmd_select_areas_expect_response(step=4, new_areas=[], expected_response=Clusters.ServiceArea.SelectAreasStatus.kSuccess) + await self.send_cmd_select_areas_expect_response(step=4, new_areas=[], expected_response=Clusters.ServiceArea.Enums.SelectAreasStatus.kSuccess) selected_areas = await self.read_selected_areas(step=5) asserts.assert_true(len(selected_areas) == 0, "SelectedAreas should be empty") - await self.send_cmd_select_areas_expect_response(step=6, new_areas=[invalid_area_id], expected_response=Clusters.ServiceArea.SelectAreasStatus.kUnsupportedArea) + await self.send_cmd_select_areas_expect_response(step=6, new_areas=[invalid_area_id], expected_response=Clusters.ServiceArea.Enums.SelectAreasStatus.kUnsupportedArea) if self.check_pics("SEAR.S.M.INVALID_STATE_FOR_SELECT_AREAS") and self.check_pics("SEAR.S.M.HAS_MANUAL_SELAREA_STATE_CONTROL"): test_step = "Manually intervene to put the device in a state that prevents it from executing the SelectAreas command" self.print_step("7", test_step) - if not self.is_ci: + if self.is_ci: + await self.send_single_cmd(cmd=Clusters.Objects.RvcRunMode.Commands.ChangeToMode(newMode=1), endpoint=self.endpoint) + else: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_select_areas_expect_response(step=8, new_areas=[valid_area_id], expected_response=Clusters.ServiceArea.SelectAreasStatus.kInvalidInMode) + await self.send_cmd_select_areas_expect_response(step=8, new_areas=[valid_area_id], expected_response=Clusters.ServiceArea.Enums.SelectAreasStatus.kInvalidInMode) if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SELECT_AREAS") and self.check_pics("SEAR.S.M.HAS_MANUAL_SELAREA_STATE_CONTROL"): test_step = f"Manually intervene to put the device in a state that allows it to execute the SelectAreas({supported_area_ids}) command" self.print_step("9", test_step) - if not self.is_ci: + if self.is_ci: + self.write_to_app_pipe('{"Name": "Reset"}') + else: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_select_areas_expect_response(step=10, new_areas=supported_area_ids, expected_response=Clusters.ServiceArea.SelectAreasStatus.kSuccess) + await self.send_cmd_select_areas_expect_response(step=10, new_areas=supported_area_ids, expected_response=Clusters.ServiceArea.Enums.SelectAreasStatus.kSuccess) selected_areas = await self.read_selected_areas(step=11) asserts.assert_true(len(selected_areas) == len(supported_area_ids), f"SelectedAreas({selected_areas}) should match SupportedAreas({supported_area_ids})") - await self.send_cmd_select_areas_expect_response(step=12, new_areas=supported_area_ids, expected_response=Clusters.ServiceArea.SelectAreasStatus.kSuccess) + await self.send_cmd_select_areas_expect_response(step=12, new_areas=supported_area_ids, expected_response=Clusters.ServiceArea.Enums.SelectAreasStatus.kSuccess) if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SELECT_AREAS") and self.check_pics("SEAR.S.M.HAS_MANUAL_SELAREA_STATE_CONTROL") and self.check_pics("SEAR.S.M.SELECT_AREAS_WHILE_NON_IDLE"): test_step = f"Manually intervene to put the device in a state that allows it to execute the SelectAreas({valid_area_id}) command, and put the device in a non-idle state" self.print_step("13", test_step) - if not self.is_ci: + if self.is_ci: + self.write_to_app_pipe('{"Name": "Reset"}') + await self.send_single_cmd(cmd=Clusters.Objects.RvcRunMode.Commands.ChangeToMode(newMode=1), endpoint=self.endpoint) + else: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") if self.check_pics("SEAR.S.F00"): - await self.send_cmd_select_areas_expect_response(step=14, new_areas=[valid_area_id], expected_response=Clusters.ServiceArea.SelectAreasStatus.kSuccess) + await self.send_cmd_select_areas_expect_response(step=14, new_areas=[valid_area_id], expected_response=Clusters.ServiceArea.Enums.SelectAreasStatus.kSuccess) else: - await self.send_cmd_select_areas_expect_response(step=14, new_areas=[valid_area_id], expected_response=Clusters.ServiceArea.SelectAreasStatus.kInvalidInMode) + await self.send_cmd_select_areas_expect_response(step=14, new_areas=[valid_area_id], expected_response=Clusters.ServiceArea.Enums.SelectAreasStatus.kInvalidInMode) if __name__ == "__main__": diff --git a/src/python_testing/TC_SEAR_1_4.py b/src/python_testing/TC_SEAR_1_4.py index a6326559beaa20..d31dcc2b137ad0 100644 --- a/src/python_testing/TC_SEAR_1_4.py +++ b/src/python_testing/TC_SEAR_1_4.py @@ -62,10 +62,6 @@ async def test_TC_SEAR_1_4(self): self.print_step(1, "Commissioning, already done") - # Ensure that the device is in the correct state - if self.is_ci: - self.write_to_app_pipe('{"Name": "Reset"}') - attribute_list = await self.read_sear_attribute_expect_success( endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.AttributeList) logging.info("AttributeList: %s" % (attribute_list))