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

Tests yaml #6944

Merged
merged 2 commits into from
Jun 3, 2021
Merged

Tests yaml #6944

merged 2 commits into from
Jun 3, 2021

Conversation

vivien-apple
Copy link
Contributor

Problem

In order to make it easier to create Cluster tests that may exercise the different high level layers of the controller, this PR introduce some tests written in yaml to make them easier to read and understand.

Those are basic tests, one for the Test Cluster in order support adding exotic commands to it and see if they work, the other is some test against the OnOff Cluster in order to validate that sending commands update the attribute appropriately.

Summary of Changes

  • Add a TestHelper.js in order to get ZAP to understand those YAML templates
  • Add onoff.yaml and test.yaml into a new folder src/app/tests/yaml/
  • Add an example using partials about how those yaml files can be used to generate some tests for the given framework
  • Generate some tests for the Darwin CI task

src/app/tests/yaml/onoff.yaml Outdated Show resolved Hide resolved
src/app/tests/yaml/onoff.yaml Outdated Show resolved Hide resolved
src/app/tests/yaml/onoff.yaml Outdated Show resolved Hide resolved
src/app/zap-templates/common/TestHelper.js Outdated Show resolved Hide resolved
Copy link
Contributor

@woody-apple woody-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vivien-apple. Agree with @andy31415 's feedback, and is this PR planning to have C++ chip-tool included as well? How about python?

@vivien-apple vivien-apple force-pushed the Tests_YAML branch 2 times, most recently from 8efc8d9 to 6fb29ce Compare May 26, 2021 12:14
@vivien-apple
Copy link
Contributor Author

Thanks @vivien-apple. Agree with @andy31415 's feedback, and is this PR planning to have C++ chip-tool included as well? How about python?

I have added chip-tool C++ generation as well. So the same test description is generating tests for the Darwin CI, as well as tests for chip-tool.

Under chip-tool the list of tests can be retrieved with ./out/debug/standalone/chip-tool tests

  +-------------------------------------------------------------------------------------+
  | Commands:                                                                           |
  +-------------------------------------------------------------------------------------+
  | * TestCluster                                                                       |
  | * OnOffCluster                                                                      |
  +-------------------------------------------------------------------------------------+

Those tests can then be runned by adding the test name at the end, e.g chip-tool tests OnOffCluster.

For python support it sounds like the way to add them will be update mobile-device-test.py to have a custom template to generate tests as well. For example https://github.com/project-chip/connectedhomeip/blob/master/src/controller/python/test/test_scripts/mobile-device-test.py#L69 calls hand written tests for the OnOff cluster. Someone would know python better than me should be able to replace the hand written version by the generated version. I would like to not block this PR on python support though as python support can come next.

@vivien-apple vivien-apple requested a review from woody-apple May 26, 2021 12:27
@woody-apple
Copy link
Contributor

woody-apple commented May 26, 2021

Thanks @vivien-apple !

@vivien-apple vivien-apple requested a review from andy31415 May 27, 2021 09:41
@andy31415
Copy link
Contributor

@vivien-apple - since this does code generation, will we need to check-in more generated code or is this for manual runs only (and generate manually as needed)?

I would find checking in test sequences/yaml code useful however historically checking in generated code from zap causes very large PRs that tend to hide real code changes between auto-generated code, making them hard to review.

What is the expected flow when using yaml test cases? Can we have a model where we have only yaml files and check in generated files?

@andy31415
Copy link
Contributor

Do we need zap or if we rely only on yaml files could we generate in pure python (easier to integrate in the build system if pure python)?

Could we convert the tests to generic POSIX? We have many developers who only have a linux machine and github charges 10x minutes when using darwin instead of linux backends.

@woody-apple
Copy link
Contributor

The plan is to convert these to POSIX as soon as possible, though I think we should get this in... this will help substantially test the C++ api here.

@woody-apple
Copy link
Contributor

@woody-apple woody-apple merged commit 1997ccf into project-chip:master Jun 3, 2021
@woody-apple
Copy link
Contributor

Put up this to bring it into CI:
#7381

nikita-s-wrk pushed a commit to nikita-s-wrk/connectedhomeip that referenced this pull request Sep 23, 2021
* Add a simple helper for ZAP templates in order to generate tests from YAML files

* Update gen/ folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants