Skip to content

Repository files navigation

clustertest

A test framework for helping with E2E testing of Giant Swarm clusters.

Installation

go get github.com/giantswarm/clustertest

Features

  • Kubernetes client for interacting with the Management Cluster
  • Kubernetes client for interacting with the Workload Clusters
  • Wrapper types around Apps and their respective values ConfigMaps
  • Wrapper types around Cluster apps and Releases
  • Management (creation and deletion) or Organization resources
  • Wait and polling helpers
  • Override App versions using environment variables. (See application documentation for details)

Supported Environment Variables

The following environment variables can be set to control or override different behaviour:

Env Var Description
E2E_KUBECONFIG Points to the file containing the kubeconfig to use for the Management Clusters
E2E_WC_NAME The name of an existing Workload Cluster to load from the Management Cluster instead of creating a new one.
Must be used with E2E_WC_NAMESPACE
E2E_WC_NAMESPACE The namespace an existing Workload Cluster is in which will be loaded instead of creating a new one.
Must be used with E2E_WC_NAME
E2E_WC_KEEP This environment variable is used to indicate that the workload cluster should not be deleted at the end of a test run. Note: not used within this codebase but exposed for use by other tooling.
E2E_OVERRIDE_VERSIONS Sets the version of Apps to use instead of installing the latest released.
Example format: E2E_OVERRIDE_VERSIONS="cluster-aws=0.38.0-5f4372ac697fce58d524830a985ede2082d7f461"
E2E_RELEASE_VERSION The base Release version to use when creating the Workload Cluster.
Must be used with E2E_RELEASE_COMMIT
E2E_RELEASE_COMMIT The git commit from the releases repo that contains the Release version to use when creating the Workload Cluster.
Must be used with E2E_RELEASE_VERSION
E2E_RELEASE_PRE_UPGRADE When performing upgrade tests, this sets the initial version to install. If set to previous_major, it automatically finds the latest release of the previous major version to test cross-major upgrades. If set to first_previous_major, it finds the earliest non-deprecated release of the previous major version.

All of these can be found in ./pkg/env/const.go.

Documentation

Documentation can be found at: pkg.go.dev/github.com/giantswarm/clustertest.

Example Usage

ctx := context.Background()

framework, err := clustertest.New("capa_standard")
if err != nil {
  panic(err)
}

cluster := application.NewClusterApp(utils.GenerateRandomName("t"), application.ProviderAWS).
  WithOrg(organization.NewRandomOrg()).
  WithAppValuesFile(path.Clean("./test_data/cluster_values.yaml"), nil)

client, err := framework.ApplyCluster(ctx, cluster)

// Run tests...

err = framework.DeleteCluster(ctx, cluster)

About

A test framework for helping with E2E testing of cluster creation

Resources

Security policy

Stars

0 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages