github.com/dmvolod/operator-sdk@v0.8.2/doc/proposals/ansible-operator-testing.md (about) 1 # Ansible Operator Testing 2 3 ## Background 4 All operators should fit into the e2e testing framework used by operator-sdk, including Ansible Operator. 5 6 ## Goals 7 8 - Add support for the `test {local|cluster}` e2e testing subcommand with Ansible Operators 9 - Integrate with existing Ansible test frameworks to provide a uniform experience across the Ansible ecosystem 10 - Maintain the existing interface for the `test` subcommands 11 12 ## Non-Goals 13 14 - Create a new testing framework for Ansible that plays nicely with operators 15 - Allow Ansible users to write non-Ansible tests 16 17 ## Solution 18 1. Update scaffolding to (optionally?) include [molecule](https://molecule.readthedocs.io/en/latest/) initialization 19 - Set up a molecule scenario for the e2e environment (may have different behavior between `local` and `cluster` scenarios) 20 1. Create a [delegated driver](https://molecule.readthedocs.io/en/latest/configuration.html#delegated) for molecule that: 21 - In the `test local` case handles the creation of the necessary resources (namespace, CRDs, roles, rolebindings, operator deployment) in the Kubernetes cluster 22 - In the `test cluster` case does nothing 23 1. Add a custom entrypoint for testing that will spin up the operator and then run the proper molecule scenario, which can be included in the 24 Ansible Operator image when it is built with the `--enable-tests` option 25 1. Update the `test local` subcommand so that when it is run in the context of an Ansible Operator, it will trigger a molecule run of the proper scenario 26 1. Update the `test cluster` subcommand so that when it is run in the context of an Ansible Operator, a deployment of the operator with the custom testing entrypoint 27 is created. The behavior here should approximate the Golang operator equivalent, in terms of reporting/termination 28 29 ## Discussion / Further Investigation 30 - Should test scaffolding be optional, or should we always initialize tests? 31 - Can we easily get access to the `deploy/` resources from our molecule test? 32 - How do we distribute the custom molecule driver? 33 - Should `test local` and `test cluster` be two different molecule scenarios? 34 - `test local` can run molecule at the permissions required to create CRDs, roles, SAs, etc 35 - What if it isn't? Maybe we should do a best effort here, and not crash the run if we hit permissions issues. 36 - `test cluster` will be run at normal operator permissions, and will require that the prerequisites be satisfied before invocation