Tests for YTT Cluster templates
This directory is a standalone toolkit for validating the cluster templates that are generated by tanzu-framework.
Validating these YTT templates generally involves:
-
using clustergen
to compare a broad range of parametric variations for regressions in the expected behaviour after configuration changes that isn't explicitly tested.
-
using the newer, unit test module, which specifically can test your cluster's generation with YTT inputs and bespoke configurations in a unified way.
Clustergen tests
These tests run automatically for you in CI, changing many different types of parameters, storing resulting cluster templates, and then comparing how your new framework PR modifies cluster Yaml compared with the previous commit. These generally can give you hints at unintended changes you made, for more details, look in the clustergen directory.
Unit tests
The unit tests in this repository can be run like so:
cd pkg/v1/providers/tests/
go test -timeout 30s -run ^TestUnit$ github.com/vmware-tanzu/tanzu-framework/pkg/v1/providers/tests/unit/matchers
You can write an end to end unit test by:
-
Importing YTT values required for your cluster overlay.
-
Invoking the various YTT files required to make a cluster, simulating the normal behaviour of tanzu cli.
There are TKR and TKG bom files that are inluded in this directory for isolated testing purposes.
They may need periodic updates, in a manner similar to that of the config_variable_association.star
files in other parts of this repository.
Examples
- For a "full cluster template" test, see the windows_test.go, which generates a full windows cluster from YTT and then verifies the top level topology of CAPI components.
- For a more targeted test example of how a specific YTT module is behaving, see the ip_family tests, which verify the behaviour of YTT transformations that occur for various networking related functionality.