Following my migration to molecule 3, all my testinfra tests were taking more time than before. Like 56 seconds for 6 tests !
As I changed nothing on the test side of my roles, I dug a bit to know what happened and try to recover my previously fast tests.
With the release of Molecule 3, the devs decided to ditch testinfra as the primary verifier tool in favor of ansible itself. While it isn't a bad decision, I'm not fond of it as I think ansible is not the best fit for a verification step as it is quite verbose and relies too heavily on register.
I still don't know who's the culprit but the slowness is linked to the connection backend used by testinfra to connect to test instance. Like it's already written in testinfra doc, the ansible backend is the slowest of all.
After digging in molecule code and testing things, the fix is really easy to deploy in your stack:
In your molecule.yml
file, you need to declare the connection backend in testinfra options, like in my case, podman
:
verifier: name: testinfra options: connection: podman
With this option, my tests are now running at lightspeed!
Comments