teseraio / ensemble

Modular Kubernetes operator to manage the lifecycle of databases
https://ensembleoss.io
Mozilla Public License 2.0
42 stars 1 forks source link

Use a scheduler Plan to test backend reconcile functions #40

Closed ferranbt closed 3 years ago

ferranbt commented 3 years ago

Right now, backend unit testing is done using the docker provider to run a cluster of nodes. Its a sort of black box meant to test the final state of the cluster (i.e. it has 3 running nodes in a cluster) and not the specific state of each node (i.e. does this zookeeper node has a tickTime limit of 3000). This approach might not be scalable on the long run for every unit test in the backend, specially in CI environments if we have to wait for all the docker images to be downloaded.

We should create an scheduler package that contains the current reconcile functionality, it takes as an input an Evaluation and returns a Plan for that evaluation. The output Plan is meant to be processed by the operator calling the different functions in the Provider.

On the backends, we could use the new independent scheduler to plan and validate a wide range of cluster reconcile specs without having to run any container. Note that this would only test if the planned instances return a specific result and not if that result is correct. In the future, we could use this approach to test all the backend logic (i.e. hooks) and have a general e2e test for each backend to run the database as containers and check some final states (this could be enabled or not on CI).

ferranbt commented 3 years ago

This would fix backend testing in #23