I am currently trying to migrate a VM-based infrastructure to a Docker-based one and take the chance to add behavior testing to this infrastructure. So I aim to have all changes I make to the base system configuration in code (e.g. in a Dockerfile), git versioned and (in an ideal world) every change should have a testable effect.
Examples for tests I want to do:
- If I add a user account and a permission rule in my "postgres" container, then user "x" should be able to access (only) database "y" (only) from the "web" container.
- If I change the postfix configuration like insert change here, then human users must authenticate, but system users can send email unauthenticated.
- If I change the Apache configuration like insert change here, then average response time goes below x ms.
Things I don't really want to test (doesn't hurt if I could, though):
- File x should be present.
- Service y should be installed.
I was wondering what is a good/common approach to do infrastructure testing such as the above and would be happy to receive any advice or hear best practices. (I discovered serverspec, but it seemed to me as if this would support rather the second kind of tests; in all the examples I read it would rather check system state than system behavior.)