Skip to content

Commit

Permalink
test/e2e: deprecate KCPUpgradeSpec, make ClusterUpgradeConformanceSpe…
Browse files Browse the repository at this point in the history
…c more flexible

Signed-off-by: Stefan Büringer [email protected]
  • Loading branch information
sbueringer committed Dec 1, 2021
1 parent 2f2fd88 commit 8a3a248
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 191 deletions.
4 changes: 4 additions & 0 deletions docs/book/src/developer/providers/v1.0-to-v1.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ are kept in sync with the versions used by `sigs.k8s.io/controller-runtime`.
* The `third_party/kubernetes-drain` package is deprecated, as we're now using `k8s.io/kubectl/pkg/drain` instead ([PR](https://github.com/kubernetes-sigs/cluster-api/pull/5440)).
* `util/version.CompareWithBuildIdentifiers` has been deprecated, please use `util/version.Compare(a, b, WithBuildTags())` instead.

### Removals

* `KCPUpgradeSpec` has been removed. Please use `ClusterUpgradeConformanceSpec` instead.

### API Change

* Some controllers have been moved to internal to reduce their API surface. We now only
Expand Down
38 changes: 29 additions & 9 deletions test/e2e/cluster_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ type ClusterUpgradeConformanceSpecInput struct {
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
}
Expand All @@ -57,9 +66,13 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
specName = "k8s-upgrade-and-conformance"
)
var (
input ClusterUpgradeConformanceSpecInput
namespace *corev1.Namespace
cancelWatches context.CancelFunc
input ClusterUpgradeConformanceSpecInput
namespace *corev1.Namespace
cancelWatches context.CancelFunc

controlPlaneMachineCount int64
workerMachineCount int64

clusterResources *clusterctl.ApplyClusterTemplateAndWaitResult
kubetestConfigFilePath string
)
Expand All @@ -81,6 +94,18 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
kubetestConfigFilePath = input.E2EConfig.GetVariable(kubetestConfigurationVariable)
Expect(kubetestConfigFilePath).To(BeAnExistingFile(), "%s should be a valid kubetest config file")

if input.ControlPlaneMachineCount == nil {
controlPlaneMachineCount = 1
} else {
controlPlaneMachineCount = *input.ControlPlaneMachineCount
}

if input.WorkerMachineCount == nil {
workerMachineCount = 2
} else {
workerMachineCount = *input.WorkerMachineCount
}

// Setup a Namespace where to host objects for this spec and create a watcher for the Namespace events.
namespace, cancelWatches = setupSpecNamespace(ctx, specName, input.BootstrapClusterProxy, input.ArtifactFolder)
clusterResources = new(clusterctl.ApplyClusterTemplateAndWaitResult)
Expand All @@ -89,11 +114,6 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
It("Should create and upgrade a workload cluster and run kubetest", func() {
By("Creating a workload cluster")

var controlPlaneMachineCount int64 = 1
// clusterTemplateWorkerMachineCount is used for ConfigCluster, as it is used for MachineDeployments and
// MachinePools
var clusterTemplateWorkerMachineCount int64 = 2

clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
ClusterProxy: input.BootstrapClusterProxy,
ConfigCluster: clusterctl.ConfigClusterInput{
Expand All @@ -106,7 +126,7 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeFrom),
ControlPlaneMachineCount: pointer.Int64Ptr(controlPlaneMachineCount),
WorkerMachineCount: pointer.Int64Ptr(clusterTemplateWorkerMachineCount),
WorkerMachineCount: pointer.Int64Ptr(workerMachineCount),
},
WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"),
WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"),
Expand Down
55 changes: 55 additions & 0 deletions test/e2e/cluster_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package e2e
import (
. "github.com/onsi/ginkgo"
"k8s.io/utils/pointer"
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
)

var _ = Describe("When upgrading a workload cluster and testing K8S conformance [Conformance] [K8s-Upgrade]", func() {
Expand Down Expand Up @@ -51,3 +52,57 @@ var _ = Describe("When upgrading a workload cluster using ClusterClass", func()
}
})
})

var _ = Describe("When upgrading a workload cluster with a single control plane machine", func() {
ClusterUpgradeConformanceSpec(ctx, func() ClusterUpgradeConformanceSpecInput {
return ClusterUpgradeConformanceSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
// This test is run in CI in parallel with other tests. To keep the test duration reasonable
// the conformance tests are skipped.
SkipConformanceTests: true,
ControlPlaneMachineCount: pointer.Int64(1),
WorkerMachineCount: pointer.Int64(1),
Flavor: pointer.String(clusterctl.DefaultFlavor),
}
})
})

var _ = Describe("When upgrading a workload cluster with a HA control plane", func() {
ClusterUpgradeConformanceSpec(ctx, func() ClusterUpgradeConformanceSpecInput {
return ClusterUpgradeConformanceSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
// This test is run in CI in parallel with other tests. To keep the test duration reasonable
// the conformance tests are skipped.
SkipConformanceTests: true,
ControlPlaneMachineCount: pointer.Int64(3),
WorkerMachineCount: pointer.Int64(1),
Flavor: pointer.String(clusterctl.DefaultFlavor),
}
})
})

var _ = Describe("When upgrading a workload cluster with a HA control plane using scale-in rollout", func() {
ClusterUpgradeConformanceSpec(ctx, func() ClusterUpgradeConformanceSpecInput {
return ClusterUpgradeConformanceSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
// This test is run in CI in parallel with other tests. To keep the test duration reasonable
// the conformance tests are skipped.
SkipConformanceTests: true,
ControlPlaneMachineCount: pointer.Int64(3),
WorkerMachineCount: pointer.Int64(1),
Flavor: pointer.String("kcp-scale-in"),
}
})
})
115 changes: 0 additions & 115 deletions test/e2e/kcp_upgrade.go

This file was deleted.

67 changes: 0 additions & 67 deletions test/e2e/kcp_upgrade_test.go

This file was deleted.

0 comments on commit 8a3a248

Please sign in to comment.