Page MenuHomePhabricator

Revisit and update python testing in puppet
Closed, ResolvedPublic

Description

There is a lot of python code in the puppet repo. Naturally, anything that reaches a certain level of complexity needs a more robust language than bash, so we usually turn to python for that. As a result, python testing takes place in puppet's CI tasks, both in flake8 linting (which has its own issues) and unit tests.

We are proposing some changes to the unit test setup. Right now, to set up unit tests, one must edit the ruby taskgen file for Rake to consume, update the universal tox.ini with an environment and go from there. If we only separated such things into modules, that would be sufficient. However, we separate projects/items into profiles as well. Additionally, individuals are discouraged from adding tests when a lot of complexity is present that impacts everyone rather than just their work.

Changes proposed:

  • Edit taskgen to support finding tox.ini files in each module instead of a single universal one with conditional changes filters. This is an idea right now, we still need to produce a patch.
  • Create an appropriate tox.ini file for each module already using tests.
  • On profiles, filter for a tox.ini at modules/profile/files/*/tox.ini
  • Encourage a standard of placing python scripts and their tests in puppet inside a package directory (in the python sense) to facilitate testing and locating of python. This also allows environments to be defined for test suites in tox.

Related Objects

Event Timeline

Thanks @Bstorm for formalizing our random IRC chat into this proposal 😉

I would add that it would be surreal to think to be able to have coherent test environments between different Python script inside the Puppet repo, given their diversity, hence the reasoning of not having a single centralized tox.ini, that reduces this flexibility quite a bit.

Colocating the test environments definition inside each module seems much nicer to me. Of course this must be backed by some rake magic to easily allow to run tests, either all of them, or just the ones in the modules that have differences.

All in all this could mean a little bit slower test when running all tests, but actually slightly quicker or equal time to run tests of a single module, that is usually the case with CI.

That said I believe that once some Python script evolves over the single manageable file, it should be taken out of the Puppet repo, most likely to its own project repo.

My 2 cents.

ArielGlenn triaged this task as Medium priority.Nov 13 2018, 9:26 AM

While I don't want to open up this discussion here, it may be the case that some scripts moved out of puppet might share a repo, not necessarily every short 2-3 file script having its own repo. But in general I agree with the sentiment. I prefer to have individual modules with their own testing definitions, according to the needs of the module's scripts and the time and resources of the script maintainers.

jbond subscribed.

Edit taskgen to support finding tox.ini files in each module instead of a single universal one with conditional changes filters. This is an idea right now, we still need to produce a patch.

We now have the per_module_tox task for this

Create an appropriate tox.ini file for each module already using tests.

Im guessing this was also done as i see a few modules with tox.ini files

On profiles, filter for a tox.ini at modules/profile/files/*/tox.ini

Encourage a standard of placing python scripts and their tests in puppet inside a package directory (in the python sense) to facilitate testing and locating of python. This also allows environments to be defined for test suites in tox.

OI guess theses till need doing?

jbond claimed this task.