Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YAML] Add a "contains" method that support complex objects #30204

Closed
lpbeliveau-silabs opened this issue Nov 3, 2023 · 3 comments · Fixed by #30218
Closed

[YAML] Add a "contains" method that support complex objects #30204

lpbeliveau-silabs opened this issue Nov 3, 2023 · 3 comments · Fixed by #30218

Comments

@lpbeliveau-silabs
Copy link
Contributor

Workflow issues

In the Yaml CI, we currently need to explicitly test for all members of complex structures even if we are only interested in certain values. For instance, in Test_TC_S_2_2 here, we are only interested in on Attibute in two clusters, but end up checking all attributes present in the struct, which is tedious and means we will need to modifiy this test each time a new extension field set is implemented in the all-cluster-app:

                value:
                    [
                        {
                            ClusterID: 0x0006,
                            AttributeValueList:
                                [{ AttributeID: 0x0000, AttributeValue: 0x01 }],
                        },
                        {
                            ClusterID: 0x0008,
                            AttributeValueList:
                                [{ AttributeID: 0x0000, AttributeValue: 0x64 }],
                        },
                        {
                            ClusterID: 0x0300,
                            AttributeValueList:
                                [
                                    {
                                        AttributeID: 0x0003,
                                        AttributeValue: 0x616b,
                                    },
                                    {
                                        AttributeID: 0x0004,
                                        AttributeValue: 0x607d,
                                    },
                                    {
                                        AttributeID: 0x4000,
                                        AttributeValue: 0x0000,
                                    },
                                    {
                                        AttributeID: 0x0001,
                                        AttributeValue: 0x00,
                                    },
                                    {
                                        AttributeID: 0x4002,
                                        AttributeValue: 0x00,
                                    },
                                    {
                                        AttributeID: 0x4003,
                                        AttributeValue: 0x00,
                                    },
                                    {
                                        AttributeID: 0x4004,
                                        AttributeValue: 0x0019,
                                    },
                                    {
                                        AttributeID: 0x0007,
                                        AttributeValue: 0x00,
                                    },
                                    {
                                        AttributeID: 0x4001,
                                        AttributeValue: 0x02,
                                    },
                                ],
                        },
                    ]

As Identified in the TODO below, we need to have a way to check only for the values that we are expecting to see a change in:

                #TODO : Need to change the check for a check like below if possible
                # constraints:
                #     type: list
                #     contains: [
                #         {
                #             ClusterID: 0x0006,
                #             AttributeValueList:
                #                 [{ AttributeID: 0x0000, AttributeValue: 0x01 }],
                #         },
                #         {
                #             ClusterID: 0x0008,
                #             AttributeValueList:
                #                 [{ AttributeID: 0x0000, AttributeValue: 0x64 }],
                #         },
                #     ]

Platform

all

Anything else?

No response

@lpbeliveau-silabs lpbeliveau-silabs changed the title [YAML] [YAML] Add a "contains" method that support complex objects Nov 3, 2023
@bzbarsky-apple
Copy link
Contributor

@lpbeliveau-silabs This should be supported ever since #29643 merged a few weeks ago. Did you try it and it didn't work?

@lpbeliveau-silabs
Copy link
Contributor Author

lpbeliveau-silabs commented Nov 3, 2023

I am currently getting a parsing error when try to run the following step:

      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "GroupID"
                value: G1
              - name: "SceneID"
                value: 0x01
              - name: "TransitionTime"
                value: 0x0000
              - name: "ExtensionFieldSets"
                constraints:
                    type: list
                    contains: [
                        {
                            ClusterID: 0x0006,
                            AttributeValueList:
                                [{ AttributeID: 0x0000, AttributeValue: 0x01 }],
                        },
                        {
                            ClusterID: 0x0008,
                            AttributeValueList:
                                [{ AttributeID: 0x0000, AttributeValue: 0x64 }],
                        },
                    ]
                    

The resulting error is:

Parsing: src/app/tests/suites/certification/Test_TC_S_2_2.yaml
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : ✗ 18.0ms
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		Error at step 28:
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		label: 'Step 5: TH sends a ViewScene command to DUT with the GroupID field set to
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		  G1 and the SceneID field set to 0x01.'
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		PICS: S.S.C01.Rsp && PICS_SDK_CI_ONLY
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		command: ViewScene
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		arguments:
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		  values:
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		  - name: GroupID
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		    value: G1
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		  - name: SceneID
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		    value: 1
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		response:
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		  values:
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		  - name: Status
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		    value: 0
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		  - name: GroupID
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		    value: G1
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		  - name: SceneID
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		    value: 1
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		  - name: TransitionTime
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		    value: 0
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		  - name: ExtensionFieldSets
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		    constraints:
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		      type: list
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		      contains:
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		      - ClusterID: 6 <-- Unknown key "ClusterID"
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		        AttributeValueList:
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		        - AttributeID: 0
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		          AttributeValue: 1
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		      - ClusterID: 8
2023-11-03 16:17:25.196 ERROR   16:17:25.041 - TEST OUT  : 		        AttributeValueList:
2023-11-03 16:17:25.197 ERROR   16:17:25.041 - TEST OUT  : 		        - AttributeID: 0
2023-11-03 16:17:25.197 ERROR   16:17:25.041 - TEST OUT  : 		          AttributeValue: 100

Seems to indicate that the parser is not expecting this key here but this same key works when used to check for a specific value.

@bzbarsky-apple
Copy link
Contributor

Yep, there's a bug in the handling of contains for command responses like this. Fix coming up.

bzbarsky-apple added a commit to bzbarsky-apple/connectedhomeip that referenced this issue Nov 4, 2023
For a command response, the YAML parser was ending up with the wrong type
definition (the one for the whole command response, not the one for the one
field) when a type-dependent constraint was used on a field of the response.
This led to issues when a type-dependent constraint (like "contains") was used
with a list of structs: the field names for the structs were not found, since
the object used for lookup had field names for the command itself, not for the
field in question.

Fixes project-chip#30204
lpbeliveau-silabs pushed a commit that referenced this issue Nov 6, 2023
For a command response, the YAML parser was ending up with the wrong type
definition (the one for the whole command response, not the one for the one
field) when a type-dependent constraint was used on a field of the response.
This led to issues when a type-dependent constraint (like "contains") was used
with a list of structs: the field names for the structs were not found, since
the object used for lookup had field names for the command itself, not for the
field in question.

Fixes #30204
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants