e2e

package
v1.2.0-rc.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2022 License: Apache-2.0 Imports: 42 Imported by: 4

Documentation

Overview

Package e2e implements end to end testing.

Index

Constants

View Source
const (
	KubernetesVersionManagement     = "KUBERNETES_VERSION_MANAGEMENT"
	KubernetesVersion               = "KUBERNETES_VERSION"
	CNIPath                         = "CNI"
	CNIResources                    = "CNI_RESOURCES"
	KubernetesVersionUpgradeFrom    = "KUBERNETES_VERSION_UPGRADE_FROM"
	KubernetesVersionUpgradeTo      = "KUBERNETES_VERSION_UPGRADE_TO"
	CPMachineTemplateUpgradeTo      = "CONTROL_PLANE_MACHINE_TEMPLATE_UPGRADE_TO"
	WorkersMachineTemplateUpgradeTo = "WORKERS_MACHINE_TEMPLATE_UPGRADE_TO"
	EtcdVersionUpgradeTo            = "ETCD_VERSION_UPGRADE_TO"
	CoreDNSVersionUpgradeTo         = "COREDNS_VERSION_UPGRADE_TO"
	IPFamily                        = "IP_FAMILY"
)

Test suite constants for e2e config variables.

Variables

This section is empty.

Functions

func Byf

func Byf(format string, a ...interface{})

func ClusterClassChangesSpec added in v1.1.0

func ClusterClassChangesSpec(ctx context.Context, inputGetter func() ClusterClassChangesSpecInput)

ClusterClassChangesSpec implements a test that verifies that ClusterClass changes are rolled out successfully. Thus, the test consists of the following steps:

  • Deploy Cluster using a ClusterClass and wait until it is fully provisioned.
  • Modify the ControlPlaneTemplate of the ClusterClass by setting ModifyControlPlaneFields and wait until the change has been rolled out to the ControlPlane of the Cluster.
  • Modify the BootstrapTemplate of all MachineDeploymentClasses of the ClusterClass by setting ModifyMachineDeploymentBootstrapConfigTemplateFields and wait until the change has been rolled out to the MachineDeployments of the Cluster.
  • Rebase the Cluster to a copy of the ClusterClass which has an additional worker label set. Then wait until the change has been rolled out to the MachineDeployments of the Cluster and verify the ControlPlane has not been changed.

NOTE: The ClusterClass can be changed in many ways (as documented in the ClusterClass Operations doc). This test verifies a subset of the possible operations and aims to test the most complicated rollouts (template changes, label propagation, rebase), everything else will be covered by unit or integration tests. NOTE: Changing the ClusterClass or rebasing to another ClusterClass is semantically equivalent from the point of view of a Cluster and the Cluster topology reconciler does not handle those cases differently. Thus we have indirect test coverage of this from other tests as well.

func ClusterUpgradeConformanceSpec

func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() ClusterUpgradeConformanceSpecInput)

ClusterUpgradeConformanceSpec implements a spec that upgrades a cluster and runs the Kubernetes conformance suite. Upgrading a cluster refers to upgrading the control-plane and worker nodes (managed by MD and machine pools). NOTE: This test only works with a KubeadmControlPlane. NOTE: This test works with Clusters with and without ClusterClass. When using ClusterClass the ClusterClass must have the variables "etcdImageTag" and "coreDNSImageTag" of type string. Those variables should have corresponding patches which set the etcd and CoreDNS tags in KCP.

func ClusterctlUpgradeSpec

func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpgradeSpecInput)

ClusterctlUpgradeSpec implements a test that verifies clusterctl upgrade of a management cluster.

NOTE: this test is designed to test older versions of Cluster API --> v1beta1 upgrades. This spec will create a workload cluster, which will be converted into a new management cluster (henceforth called secondary managemnet cluster) with the older version of Cluster API and infrastructure provider. It will then create an additional workload cluster (henceforth called secondary workload cluster) from the new management cluster using the default cluster template of the old release then run clusterctl upgrade to the latest version of Cluster API and ensure correct operation by scaling a MachineDeployment.

To use this spec the variables INIT_WITH_BINARY and INIT_WITH_PROVIDERS_CONTRACT must be set or specified directly in the spec input. See ClusterctlUpgradeSpecInput for further information.

In order to get this to work, infrastructure providers need to implement a mechanism to stage the locally compiled OCI image of their infrastructure provider and have it downloaded and available on the secondary management cluster. It is recommended that infrastructure providers use `docker save` and output the local image to a tar file, upload it to object storage, and then use preKubeadmCommands to pre-load the image before Kubernetes starts.

For example, for Cluster API Provider AWS, the docker image is stored in an s3 bucket with a unique name for the account-region pair, so as to not clash with any other AWS user / account, with the object key being the sha256sum of the image digest.

The following commands are then added to preKubeadmCommands:

preKubeadmCommands:
- mkdir -p /opt/cluster-api
- aws s3 cp "s3://${S3_BUCKET}/${E2E_IMAGE_SHA}" /opt/cluster-api/image.tar
- ctr -n k8s.io images import /opt/cluster-api/image.tar # The image must be imported into the k8s.io namespace

func HaveControllerRef

func HaveControllerRef(kind string, owner metav1.Object) types.GomegaMatcher

func HaveValidVersion

func HaveValidVersion(version string) types.GomegaMatcher

HaveValidVersion succeeds if version is a valid semver version.

func K8SConformanceSpec

func K8SConformanceSpec(ctx context.Context, inputGetter func() K8SConformanceSpecInput)

K8SConformanceSpec implements a spec that creates a cluster and runs Kubernetes conformance suite.

func KCPAdoptionSpec

func KCPAdoptionSpec(ctx context.Context, inputGetter func() KCPAdoptionSpecInput)

KCPAdoptionSpec implements a test that verifies KCP to properly adopt existing control plane Machines.

func MachineDeploymentRolloutSpec added in v0.4.1

func MachineDeploymentRolloutSpec(ctx context.Context, inputGetter func() MachineDeploymentRolloutSpecInput)

MachineDeploymentRolloutSpec implements a test that verifies that MachineDeployment rolling updates are successful.

func MachineDeploymentScaleSpec

func MachineDeploymentScaleSpec(ctx context.Context, inputGetter func() MachineDeploymentScaleSpecInput)

MachineDeploymentScaleSpec implements a test that verifies that MachineDeployment scale operations are successful.

func MachineRemediationSpec

func MachineRemediationSpec(ctx context.Context, inputGetter func() MachineRemediationSpecInput)

MachineRemediationSpec implements a test that verifies that Machines are remediated by MHC during unhealthy conditions.

func NodeDrainTimeoutSpec

func NodeDrainTimeoutSpec(ctx context.Context, inputGetter func() NodeDrainTimeoutSpecInput)

func QuickStartSpec

func QuickStartSpec(ctx context.Context, inputGetter func() QuickStartSpecInput)

QuickStartSpec implements a spec that mimics the operation described in the Cluster API quick start, that is creating a workload cluster. This test is meant to provide a first, fast signal to detect regression; it is recommended to use it as a PR blocker test. NOTE: This test works with Clusters with and without ClusterClass.

func SelfHostedSpec

func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)

SelfHostedSpec implements a test that verifies Cluster API creating a cluster, pivoting to a self-hosted cluster. NOTE: This test works with Clusters with and without ClusterClass.

Types

type ClusterClassChangesSpecInput added in v1.1.0

type ClusterClassChangesSpecInput struct {
	E2EConfig             *clusterctl.E2EConfig
	ClusterctlConfigPath  string
	BootstrapClusterProxy framework.ClusterProxy
	ArtifactFolder        string
	SkipCleanup           bool

	// Flavor is the cluster-template flavor used to create the Cluster for testing.
	// NOTE: The template must be using a ClusterClass.
	Flavor string

	// ModifyControlPlaneFields are the ControlPlane fields which will be set on the
	// ControlPlaneTemplate of the ClusterClass after the initial Cluster creation.
	// The test verifies that these fields are rolled out to the ControlPlane.
	// NOTE: The fields are configured in the following format: (without ".spec.template")
	// map[string]interface{}{
	//   "spec.path.to.field": <value>,
	// }
	ModifyControlPlaneFields map[string]interface{}

	// ModifyMachineDeploymentBootstrapConfigTemplateFields are the fields which will be set on the
	// BootstrapConfigTemplate of all MachineDeploymentClasses of the ClusterClass after the initial Cluster creation.
	// The test verifies that these fields are rolled out to the MachineDeployments.
	// NOTE: The fields are configured in the following format:
	// map[string]interface{}{
	//   "spec.template.spec.path.to.field": <value>,
	// }
	ModifyMachineDeploymentBootstrapConfigTemplateFields map[string]interface{}
}

ClusterClassChangesSpecInput is the input for ClusterClassChangesSpec.

type ClusterProxy

type ClusterProxy interface {
	framework.ClusterProxy

	ApplyWithArgs(context.Context, []byte, ...string) error
}

type ClusterUpgradeConformanceSpecInput

type ClusterUpgradeConformanceSpecInput struct {
	E2EConfig             *clusterctl.E2EConfig
	ClusterctlConfigPath  string
	BootstrapClusterProxy framework.ClusterProxy
	ArtifactFolder        string
	SkipCleanup           bool
	SkipConformanceTests  bool

	// ControlPlaneMachineCount is used in `config cluster` to configure the count of the control plane machines used in the test.
	// Default is 1.
	ControlPlaneMachineCount *int64

	// WorkerMachineCount is used in `config cluster` to configure the count of the worker machines used in the test.
	// NOTE: If the WORKER_MACHINE_COUNT var is used multiple times in the cluster template, the absolute count of
	// worker machines is a multiple of WorkerMachineCount.
	// Default is 2.
	WorkerMachineCount *int64

	// Flavor to use when creating the cluster for testing, "upgrades" is used if not specified.
	Flavor *string
}

ClusterUpgradeConformanceSpecInput is the input for ClusterUpgradeConformanceSpec.

type ClusterctlUpgradeSpecInput

type ClusterctlUpgradeSpecInput struct {
	E2EConfig             *clusterctl.E2EConfig
	ClusterctlConfigPath  string
	BootstrapClusterProxy framework.ClusterProxy
	ArtifactFolder        string
	// InitWithBinary can be used to override the INIT_WITH_BINARY e2e config variable with the URL of the clusterctl binary of the old version of Cluster API. The spec will interpolate the
	// strings `{OS}` and `{ARCH}` to `runtime.GOOS` and `runtime.GOARCH` respectively, e.g. https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.23/clusterctl-{OS}-{ARCH}
	InitWithBinary string
	// InitWithProvidersContract can be used to override the INIT_WITH_PROVIDERS_CONTRACT e2e config variable with a specific
	// provider contract to use to initialise the secondary management cluster, e.g. `v1alpha3`
	InitWithProvidersContract string
	SkipCleanup               bool
	PreInit                   func(managementClusterProxy framework.ClusterProxy)
	PreUpgrade                func(managementClusterProxy framework.ClusterProxy)
	PostUpgrade               func(managementClusterProxy framework.ClusterProxy)
	MgmtFlavor                string
	WorkloadFlavor            string
}

ClusterctlUpgradeSpecInput is the input for ClusterctlUpgradeSpec.

type K8SConformanceSpecInput

type K8SConformanceSpecInput struct {
	E2EConfig             *clusterctl.E2EConfig
	ClusterctlConfigPath  string
	BootstrapClusterProxy framework.ClusterProxy
	ArtifactFolder        string
	SkipCleanup           bool
	Flavor                string
}

K8SConformanceSpecInput is the input for K8SConformanceSpec.

type KCPAdoptionSpecInput

type KCPAdoptionSpecInput struct {
	E2EConfig             *clusterctl.E2EConfig
	ClusterctlConfigPath  string
	BootstrapClusterProxy framework.ClusterProxy
	ArtifactFolder        string
	SkipCleanup           bool

	// Flavor, if specified, must refer to a template that is
	// specially crafted with individual control plane machines
	// and a KubeadmControlPlane resource configured for adoption.
	// The initial Cluster, InfraCluster, Machine, InfraMachine,
	// KubeadmConfig, and any other resources that should exist
	// prior to adoption must have the kcp-adoption.step1: "" label
	// applied to them. The updated Cluster (with controlPlaneRef
	// configured), InfraMachineTemplate, and KubeadmControlPlane
	// resources must have the kcp-adoption.step2: "" applied to them.
	// If not specified, "kcp-adoption" is used.
	Flavor *string
}

KCPAdoptionSpecInput is the input for KCPAdoptionSpec.

type MachineDeploymentRolloutSpecInput added in v0.4.1

type MachineDeploymentRolloutSpecInput struct {
	E2EConfig             *clusterctl.E2EConfig
	ClusterctlConfigPath  string
	BootstrapClusterProxy framework.ClusterProxy
	ArtifactFolder        string
	SkipCleanup           bool
	Flavor                string
}

MachineDeploymentRolloutSpecInput is the input for MachineDeploymentRolloutSpec.

type MachineDeploymentScaleSpecInput

type MachineDeploymentScaleSpecInput struct {
	E2EConfig             *clusterctl.E2EConfig
	ClusterctlConfigPath  string
	BootstrapClusterProxy framework.ClusterProxy
	ArtifactFolder        string
	SkipCleanup           bool
	Flavor                string
}

MachineDeploymentScaleSpecInput is the input for MachineDeploymentScaleSpec.

type MachineRemediationSpecInput

type MachineRemediationSpecInput struct {
	E2EConfig             *clusterctl.E2EConfig
	ClusterctlConfigPath  string
	BootstrapClusterProxy framework.ClusterProxy
	ArtifactFolder        string
	SkipCleanup           bool

	// KCPFlavor, if specified, must refer to a template that has a MachineHealthCheck
	// resource configured to match the control plane Machines (cluster.x-k8s.io/controlplane: "" label)
	// and be configured to treat "e2e.remediation.condition" "False" as an unhealthy
	// condition with a short timeout.
	// If not specified, "kcp-remediation" is used.
	KCPFlavor *string

	// MDFlavor, if specified, must refer to a template that has a MachineHealthCheck
	// resource configured to match the MachineDeployment managed Machines and be
	// configured to treat "e2e.remediation.condition" "False" as an unhealthy
	// condition with a short timeout.
	// If not specified, "md-remediation" is used.
	MDFlavor *string
}

MachineRemediationSpecInput is the input for MachineRemediationSpec.

type NodeDrainTimeoutSpecInput

type NodeDrainTimeoutSpecInput struct {
	E2EConfig             *clusterctl.E2EConfig
	ClusterctlConfigPath  string
	BootstrapClusterProxy framework.ClusterProxy
	ArtifactFolder        string
	SkipCleanup           bool

	// Flavor, if specified, must refer to a template that contains
	// a KubeadmControlPlane resource with spec.machineTemplate.nodeDrainTimeout
	// configured and a MachineDeployment resource that has
	// spec.template.spec.nodeDrainTimeout configured.
	// If not specified, "node-drain" is used.
	Flavor *string
}

NodeDrainTimeoutSpecInput is the input for NodeDrainTimeoutSpec.

type QuickStartSpecInput

type QuickStartSpecInput struct {
	E2EConfig             *clusterctl.E2EConfig
	ClusterctlConfigPath  string
	BootstrapClusterProxy framework.ClusterProxy
	ArtifactFolder        string
	SkipCleanup           bool

	// Flavor, if specified is the template flavor used to create the cluster for testing.
	// If not specified, and the e2econfig variable IPFamily is IPV6, then "ipv6" is used,
	// otherwise the default flavor is used.
	Flavor *string
}

QuickStartSpecInput is the input for QuickStartSpec.

type SelfHostedSpecInput

type SelfHostedSpecInput struct {
	E2EConfig             *clusterctl.E2EConfig
	ClusterctlConfigPath  string
	BootstrapClusterProxy framework.ClusterProxy
	ArtifactFolder        string
	SkipCleanup           bool
	Flavor                string
}

SelfHostedSpecInput is the input for SelfHostedSpec.

Directories

Path Synopsis
internal
log
Package log implements log handling.
Package log implements log handling.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL