rancher / hull

Keep your Helm charts afloat with comprehensive testing
Apache License 2.0
4 stars 5 forks source link

Support the ability to generate templates on tests based on a mocked Kubernetes cluster #3

Open aiyengar2 opened 2 years ago

aiyengar2 commented 2 years ago

As a followup to https://github.com/aiyengar2/hull/issues/2, while the solution requested in the previous issue allows users to be able to mimic a helm install instead of a helm template / helm install --dry-run, it would not allow for environment-agnostic tests since the underlying Kubernetes cluster used may be different for different users, which can produce different results in tests.

Instead of assuming that a consistent environment is used in all test runs, Hull should offer the ability to start a HTTP server on a port that mocks one or more "read-only" API servers that are preconfigured to contain certain manifests of resources.

Ideally, from a user standpoint, a user would simply need to provide a manifest of resources (either a manifest string that can be go embedded from a file or a []runtime.Object) and a mock API server should be generated with a rest.Config that points to it that can be used for the e.RenderWithClient call; as a result, this mocked API server will be used as the basis for calling Helm which can result in tests that are fully environment-agnostic as they don't need a live Kubernetes cluster to be pre-setup to run tests with specific expectations.

aiyengar2 commented 1 year ago

This can be done simply by integrating with envtest, which handles setting up a mocked API Server and etcd only (no kubelet, so no actual running processes).