Documentation
¶
Overview ¶
Package e2e implements end to end testing.
Index ¶
- Constants
- func Byf(format string, a ...interface{})
- func ClusterClassChangesSpec(ctx context.Context, inputGetter func() ClusterClassChangesSpecInput)
- func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() ClusterUpgradeConformanceSpecInput)
- func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpgradeSpecInput)
- func HaveControllerRef(kind string, owner metav1.Object) types.GomegaMatcher
- func HaveValidVersion(version string) types.GomegaMatcher
- func K8SConformanceSpec(ctx context.Context, inputGetter func() K8SConformanceSpecInput)
- func KCPAdoptionSpec(ctx context.Context, inputGetter func() KCPAdoptionSpecInput)
- func MachineDeploymentRolloutSpec(ctx context.Context, inputGetter func() MachineDeploymentRolloutSpecInput)
- func MachineDeploymentScaleSpec(ctx context.Context, inputGetter func() MachineDeploymentScaleSpecInput)
- func MachineRemediationSpec(ctx context.Context, inputGetter func() MachineRemediationSpecInput)
- func NodeDrainTimeoutSpec(ctx context.Context, inputGetter func() NodeDrainTimeoutSpecInput)
- func QuickStartSpec(ctx context.Context, inputGetter func() QuickStartSpecInput)
- func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
- type ClusterClassChangesSpecInput
- type ClusterProxy
- type ClusterUpgradeConformanceSpecInput
- type ClusterctlUpgradeSpecInput
- type K8SConformanceSpecInput
- type KCPAdoptionSpecInput
- type MachineDeploymentRolloutSpecInput
- type MachineDeploymentScaleSpecInput
- type MachineRemediationSpecInput
- type NodeDrainTimeoutSpecInput
- type QuickStartSpecInput
- type SelfHostedSpecInput
Constants ¶
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 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.
- Modify the InfrastructureMachineTemplate of all MachineDeploymentClasses of the ClusterClass by setting ModifyMachineDeploymentInfrastructureMachineTemplateFields 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 ControlPlaneWaiters clusterctl.ControlPlaneWaiters // 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{} // ModifyMachineDeploymentInfrastructureMachineTemplateFields are the fields which will be set on the // InfrastructureMachineTemplate 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>, // } ModifyMachineDeploymentInfrastructureMachineTemplateFields map[string]interface{} }
ClusterClassChangesSpecInput is the input for ClusterClassChangesSpec.
type ClusterProxy ¶
type ClusterUpgradeConformanceSpecInput ¶
type ClusterUpgradeConformanceSpecInput struct { E2EConfig *clusterctl.E2EConfig ClusterctlConfigPath string BootstrapClusterProxy framework.ClusterProxy ArtifactFolder string SkipCleanup bool SkipConformanceTests bool ControlPlaneWaiters clusterctl.ControlPlaneWaiters // 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 // InitWithKubernetesVersion can be used to override the INIT_WITH_KUBERNETES_VERSION e2e config variable with a specific // Kubernetes version to use to create the secondary management cluster, e.g. `v1.25.0` InitWithKubernetesVersion string // InitWithCoreProvider specifies the core provider version to use when initializing the secondary management cluster, e.g. `cluster-api:v1.3.0`. // If not set, the core provider version is calculated based on the contract. InitWithCoreProvider string // InitWithBootstrapProviders specifies the bootstrap provider versions to use when initializing the secondary management cluster, e.g. `kubeadm:v1.3.0`. // If not set, the bootstrap provider version is calculated based on the contract. InitWithBootstrapProviders []string // InitWithControlPlaneProviders specifies the control plane provider versions to use when initializing the secondary management cluster, e.g. `kubeadm:v1.3.0`. // If not set, the control plane provider version is calculated based on the contract. InitWithControlPlaneProviders []string // InitWithInfrastructureProviders specifies the infrastructure provider versions to add to the secondary management cluster, e.g. `aws:v2.0.0`. // If not set, the infrastructure provider version is calculated based on the contract. InitWithInfrastructureProviders []string // InitWithIPAMProviders specifies the IPAM provider versions to add to the secondary management cluster, e.g. `infoblox:v0.0.1`. // If not set, the IPAM provider version is calculated based on the contract. InitWithIPAMProviders []string // InitWithRuntimeExtensionProviders specifies the runtime extension provider versions to add to the secondary management cluster, e.g. `test:v0.0.1`. // If not set, the runtime extension provider version is calculated based on the contract. InitWithRuntimeExtensionProviders []string // UpgradeClusterctlVariables can be used to set additional variables for clusterctl upgrade. UpgradeClusterctlVariables map[string]string SkipCleanup bool // PreWaitForCluster is a function that can be used as a hook to apply extra resources (that cannot be part of the template) in the generated namespace hosting the cluster // This function is called after applying the cluster template and before waiting for the cluster resources. PreWaitForCluster func(managementClusterProxy framework.ClusterProxy, workloadClusterNamespace string, workloadClusterName string) ControlPlaneWaiters clusterctl.ControlPlaneWaiters PreInit func(managementClusterProxy framework.ClusterProxy) PreUpgrade func(managementClusterProxy framework.ClusterProxy) PostUpgrade func(managementClusterProxy framework.ClusterProxy) // PreCleanupManagementCluster hook can be used for extra steps that might be required from providers, for example, remove conflicting service (such as DHCP) running on // the target management cluster and run it on bootstrap (before the latter resumes LCM) if both clusters share the same LAN PreCleanupManagementCluster func(managementClusterProxy framework.ClusterProxy) MgmtFlavor string CNIManifestPath string WorkloadFlavor string // Custom providers can be specified to upgrade to a pre-release or a custom version instead of upgrading to the latest using contact CoreProvider string BootstrapProviders []string ControlPlaneProviders []string InfrastructureProviders []string IPAMProviders []string RuntimeExtensionProviders []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 ControlPlaneWaiters clusterctl.ControlPlaneWaiters }
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 ControlPlaneWaiters clusterctl.ControlPlaneWaiters 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 ControlPlaneWaiters clusterctl.ControlPlaneWaiters 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 ControlPlaneWaiters clusterctl.ControlPlaneWaiters // 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 ControlPlaneWaiters clusterctl.ControlPlaneWaiters // 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 ControlPlaneWaiters clusterctl.ControlPlaneWaiters // 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 ControlPlaneWaiters clusterctl.ControlPlaneWaiters Flavor string // SkipUpgrade skip the upgrade of the self-hosted clusters kubernetes version. // If true, the variable KUBERNETES_VERSION is expected to be set. // If false, the variables KUBERNETES_VERSION_UPGRADE_FROM, KUBERNETES_VERSION_UPGRADE_TO, // ETCD_VERSION_UPGRADE_TO and COREDNS_VERSION_UPGRADE_TO are expected to be set. SkipUpgrade 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 1. WorkerMachineCount *int64 }
SelfHostedSpecInput is the input for SelfHostedSpec.