Skip to content

Commit

Permalink
Merge pull request #5186 from detiber/e2eFlavors
Browse files Browse the repository at this point in the history
✨ [e2e framework] allow for overriding flavor for all e2e tests
  • Loading branch information
k8s-ci-robot authored Sep 7, 2021
2 parents 074c2cb + 9471472 commit 68e828f
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 15 deletions.
5 changes: 4 additions & 1 deletion test/e2e/cluster_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type ClusterUpgradeConformanceSpecInput struct {
ArtifactFolder string
SkipCleanup bool
SkipConformanceTests bool

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

// ClusterUpgradeConformanceSpec implements a spec that upgrades a cluster and runs the Kubernetes conformance suite.
Expand Down Expand Up @@ -95,7 +98,7 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
ClusterctlConfigPath: input.ClusterctlConfigPath,
KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(),
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
Flavor: "upgrades",
Flavor: pointer.StringDeref(input.Flavor, "upgrades"),
Namespace: namespace.Name,
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeFrom),
Expand Down
6 changes: 4 additions & 2 deletions test/e2e/clusterctl_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type ClusterctlUpgradeSpecInput struct {
SkipCleanup bool
PreUpgrade func(managementClusterProxy framework.ClusterProxy)
PostUpgrade func(managementClusterProxy framework.ClusterProxy)
MgmtFlavor string
WorkloadFlavor string
}

// ClusterctlUpgradeSpec implements a test that verifies clusterctl upgrade of a management cluster.
Expand Down Expand Up @@ -110,7 +112,7 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
ClusterctlConfigPath: input.ClusterctlConfigPath,
KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(),
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
Flavor: clusterctl.DefaultFlavor,
Flavor: input.MgmtFlavor,
Namespace: managementClusterNamespace.Name,
ClusterName: managementClusterName,
KubernetesVersion: input.E2EConfig.GetVariable(initWithKubernetesVersion),
Expand Down Expand Up @@ -195,7 +197,7 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
// pass the clusterctl config file that points to the local provider repository created for this test,
ClusterctlConfigPath: input.ClusterctlConfigPath,
// select template
Flavor: clusterctl.DefaultFlavor,
Flavor: input.WorkloadFlavor,
// define template variables
Namespace: testNamespace.Name,
ClusterName: workLoadClusterName,
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/k8s_conformance.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type K8SConformanceSpecInput struct {
BootstrapClusterProxy framework.ClusterProxy
ArtifactFolder string
SkipCleanup bool
Flavor string
}

// K8SConformanceSpec implements a spec that creates a cluster and runs Kubernetes conformance suite.
Expand Down Expand Up @@ -89,7 +90,7 @@ func K8SConformanceSpec(ctx context.Context, inputGetter func() K8SConformanceSp
ClusterctlConfigPath: input.ClusterctlConfigPath,
KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(),
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
Flavor: clusterctl.DefaultFlavor,
Flavor: input.Flavor,
Namespace: namespace.Name,
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
Expand Down
14 changes: 13 additions & 1 deletion test/e2e/kcp_adoption.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ type KCPAdoptionSpecInput struct {
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
}

type ClusterProxy interface {
Expand Down Expand Up @@ -96,7 +108,7 @@ func KCPAdoptionSpec(ctx context.Context, inputGetter func() KCPAdoptionSpecInpu
// pass the clusterctl config file that points to the local provider repository created for this test,
ClusterctlConfigPath: input.ClusterctlConfigPath,
// select template
Flavor: "kcp-adoption",
Flavor: pointer.StringDeref(input.Flavor, "kcp-adoption"),
// define template variables
Namespace: namespace.Name,
ClusterName: clusterName,
Expand Down
6 changes: 5 additions & 1 deletion test/e2e/machine_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ type MachinePoolInput struct {
BootstrapClusterProxy framework.ClusterProxy
ArtifactFolder string
SkipCleanup bool

// Flavor, if specified must refer to a template that contains a MachinePool resource.
// If not specified, "machine-pool" is used
Flavor *string
}

// MachinePoolSpec implements a test that verifies MachinePool create, scale up and scale down.
Expand Down Expand Up @@ -79,7 +83,7 @@ func MachinePoolSpec(ctx context.Context, inputGetter func() MachinePoolInput) {
ClusterctlConfigPath: input.ClusterctlConfigPath,
KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(),
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
Flavor: "machine-pool",
Flavor: pointer.StringDeref(input.Flavor, "machine-pool"),
Namespace: namespace.Name,
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeFrom),
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/md_rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type MachineDeploymentRolloutSpecInput struct {
BootstrapClusterProxy framework.ClusterProxy
ArtifactFolder string
SkipCleanup bool
Flavor string
}

// MachineDeploymentRolloutSpec implements a test that verifies that MachineDeployment rolling updates are successful.
Expand Down Expand Up @@ -78,7 +79,7 @@ func MachineDeploymentRolloutSpec(ctx context.Context, inputGetter func() Machin
ClusterctlConfigPath: input.ClusterctlConfigPath,
KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(),
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
Flavor: clusterctl.DefaultFlavor,
Flavor: input.Flavor,
Namespace: namespace.Name,
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeFrom),
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/md_scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type MachineDeploymentScaleSpecInput struct {
BootstrapClusterProxy framework.ClusterProxy
ArtifactFolder string
SkipCleanup bool
Flavor string
}

// MachineDeploymentScaleSpec implements a test that verifies that MachineDeployment scale operations are successful.
Expand Down Expand Up @@ -68,14 +69,15 @@ func MachineDeploymentScaleSpec(ctx context.Context, inputGetter func() MachineD

It("Should successfully scale a MachineDeployment up and down upon changes to the MachineDeployment replica count", func() {
By("Creating a workload cluster")

clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
ClusterProxy: input.BootstrapClusterProxy,
ConfigCluster: clusterctl.ConfigClusterInput{
LogFolder: filepath.Join(input.ArtifactFolder, "clusters", input.BootstrapClusterProxy.GetName()),
ClusterctlConfigPath: input.ClusterctlConfigPath,
KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(),
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
Flavor: clusterctl.DefaultFlavor,
Flavor: input.Flavor,
Namespace: namespace.Name,
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
Expand Down
18 changes: 16 additions & 2 deletions test/e2e/mhc_remediations.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ type MachineRemediationSpecInput struct {
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
}

// MachineRemediationSpec implements a test that verifies that Machines are remediated by MHC during unhealthy conditions.
Expand Down Expand Up @@ -76,7 +90,7 @@ func MachineRemediationSpec(ctx context.Context, inputGetter func() MachineRemed
ClusterctlConfigPath: input.ClusterctlConfigPath,
KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(),
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
Flavor: "md-remediation",
Flavor: pointer.StringDeref(input.MDFlavor, "md-remediation"),
Namespace: namespace.Name,
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
Expand Down Expand Up @@ -108,7 +122,7 @@ func MachineRemediationSpec(ctx context.Context, inputGetter func() MachineRemed
ClusterctlConfigPath: input.ClusterctlConfigPath,
KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(),
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
Flavor: "kcp-remediation",
Flavor: pointer.StringDeref(input.KCPFlavor, "kcp-remediation"),
Namespace: namespace.Name,
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
Expand Down
9 changes: 8 additions & 1 deletion test/e2e/node_drain_timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ type NodeDrainTimeoutSpecInput struct {
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
}

func NodeDrainTimeoutSpec(ctx context.Context, inputGetter func() NodeDrainTimeoutSpecInput) {
Expand Down Expand Up @@ -83,7 +90,7 @@ func NodeDrainTimeoutSpec(ctx context.Context, inputGetter func() NodeDrainTimeo
ClusterctlConfigPath: input.ClusterctlConfigPath,
KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(),
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
Flavor: "node-drain",
Flavor: pointer.StringDeref(input.Flavor, "node-drain"),
Namespace: namespace.Name,
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
Expand Down
11 changes: 8 additions & 3 deletions test/e2e/quick_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ type QuickStartSpecInput struct {
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
}

// QuickStartSpec implements a spec that mimics the operation described in the Cluster API quick start, that is
Expand Down Expand Up @@ -72,9 +77,9 @@ func QuickStartSpec(ctx context.Context, inputGetter func() QuickStartSpecInput)
It("Should create a workload cluster", func() {
By("Creating a workload cluster")

flavor := clusterctl.DefaultFlavor
defaultFlavor := clusterctl.DefaultFlavor
if input.E2EConfig.GetVariable(IPFamily) == "IPv6" {
flavor = "ipv6"
defaultFlavor = "ipv6"
}

clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
Expand All @@ -84,7 +89,7 @@ func QuickStartSpec(ctx context.Context, inputGetter func() QuickStartSpecInput)
ClusterctlConfigPath: input.ClusterctlConfigPath,
KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(),
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
Flavor: flavor,
Flavor: pointer.StringDeref(input.Flavor, defaultFlavor),
Namespace: namespace.Name,
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/self_hosted.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type SelfHostedSpecInput struct {
BootstrapClusterProxy framework.ClusterProxy
ArtifactFolder string
SkipCleanup bool
Flavor string
}

// SelfHostedSpec implements a test that verifies Cluster API creating a cluster, pivoting to a self-hosted cluster.
Expand Down Expand Up @@ -84,7 +85,7 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
ClusterctlConfigPath: input.ClusterctlConfigPath,
KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(),
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
Flavor: clusterctl.DefaultFlavor,
Flavor: input.Flavor,
Namespace: namespace.Name,
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
Expand Down

0 comments on commit 68e828f

Please sign in to comment.