I had an interesting conversation on this Kinesis Stream PR.
I would like to know the opinions of Module development community, when it comes to documenting modules and writing tests for these modules.
Here are some of my opinions… (I understand maybe some of you or maybe none of you may agree with my opinions)
Some things I understand (But may not always agree with).
- Some modules are so small, that there is no point in documenting them.
- Since some of these modules are so small, there may not be a point in writing tests for them.
Here are some issues that I have personally ran into when moving from Ansible 1.9 to 2.0.
-
Some modules are not explicitly setting the type in argument_spec.
-
Not doing so allows people to pass a dictionary instead of a list and which may have worked at one point, but due to updates in the module, now the module no longer works with the list.
-
Not being explicit, in turn allows for these minor bugs to be introduced.1. Some modules have either 1 extremely huge function or just a main function. Doing this in turn can sometimes introduce new issues. Such as…
-
Not being able to write tests easily.
-
Function is performing 5+ actions, which not only makes writing detailed tests harder, but it also makes it difficult to debug.1. For modules that do include more than one function.
-
When a function is not documented and it is bigger than 20 lines, it makes it a bit tedious to debug.
-
Not documenting what the function is suppose to return, makes it a tad tedious to debug.1. Portion of the modules are not using check_mode. Using check_mode is especially great when writing tests.
What I personally would like to see. (I understand that it may never happen).
- Since tests are accepted, then they should be automatically run as well. If the tests does not pass then the PR is denied or updated with further comments.
- New module developers should be encouraged to write tests.
- New module developers should be encouraged to write documentation.
- The ansible-validate-modules command should complain about modules that take in parameters without assigning a type to the parameters.
- Allow 2 types of integration tests. The playbook style and the API Style. (I personally prefer to write the API style.)
Reality… (Or my Reality :P)
-
I understand that even with Unit tests in place, we can still introduce bugs into a module.
-
We can limit the amount of minor bugs in each release of each module, with the proper amount of testing.
-
We can reduce the amount of time that a module needs in order to receive a shipit. Since we would no longer be relying on the community to test the modules for us. I know as a user, I have spent hours debugging a module, to find a minor bug in the module.
In the mean time…
- I started my own repository called ld-ansible-modules. This repository is integrated with Travis.ci and coveralls.io. I am including in this repository all modules that I have written and have tests associated with them. I am also in the process of writing tests for each module that I have written. I encourage anyone to contribute to this repository and would like to see and encourage the Ansible Module Development community begin to writing well documented modules with coinciding unit tests…