Skip to content

Commit

Permalink
add scale e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
ykakarap committed Jun 15, 2023
1 parent 52fd7eb commit caaa744
Show file tree
Hide file tree
Showing 40 changed files with 1,145 additions and 195 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ hack/tools/bin

# E2E test templates
test/e2e/data/infrastructure-docker/**/cluster-template*.yaml

test/e2e/data/infrastructure-inmemory/**/cluster-template*.yaml
# Output of Makefile targets using sed on MacOS systems
*.yaml-e

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ generate-modules: ## Run go mod tidy to ensure modules are up to date
generate-e2e-templates: $(KUSTOMIZE) $(addprefix generate-e2e-templates-, v0.4 v1.0 v1.3 v1.4 main) ## Generate cluster templates for all versions

DOCKER_TEMPLATES := test/e2e/data/infrastructure-docker
INMEMORY_TEMPLATES := test/e2e/data/infrastructure-inmemory

.PHONY: generate-e2e-templates-v0.4
generate-e2e-templates-v0.4: $(KUSTOMIZE)
Expand Down Expand Up @@ -546,6 +547,8 @@ generate-e2e-templates-main: $(KUSTOMIZE)
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-topology --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-topology.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-ignition --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-ignition.yaml

$(KUSTOMIZE) build $(INMEMORY_TEMPLATES)/main/cluster-template --load-restrictor LoadRestrictionsNone > $(INMEMORY_TEMPLATES)/main/cluster-template.yaml

.PHONY: generate-metrics-config
generate-metrics-config: $(ENVSUBST_BIN) ## Generate ./hack/observability/kube-state-metrics/crd-config.yaml
OUTPUT_FILE="${OBSERVABILITY_DIR}/kube-state-metrics/crd-config.yaml"; \
Expand Down
1 change: 1 addition & 0 deletions test/e2e/autoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var _ = Describe("When using the autoscaler with Cluster API using ClusterClass
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
InfrastructureProvider: pointer.String("docker"),
InfrastructureMachineTemplateKind: "dockermachinetemplates",
Flavor: pointer.String("topology-autoscaler"),
AutoscalerVersion: "v1.26.2",
Expand Down
14 changes: 13 additions & 1 deletion test/e2e/cluster_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ type ClusterUpgradeConformanceSpecInput struct {
SkipConformanceTests bool
ControlPlaneWaiters clusterctl.ControlPlaneWaiters

// InfrastructureProviders specifies the infrastructure to use for clusterctl
// operations (Example: get cluster templates).
// Note: In most cases this need not be specified. It only needs to be specified when
// multiple infrastructure providers (ex: CAPD + in-memory) are installed on the cluster as clusterctl will not be
// able to identify the default.
InfrastructureProvider *string

// ControlPlaneMachineCount is used in `config cluster` to configure the count of the control plane machines used in the test.
// Default is 1.
ControlPlaneMachineCount *int64
Expand Down Expand Up @@ -118,13 +125,18 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
It("Should create and upgrade a workload cluster and eventually run kubetest", func() {
By("Creating a workload cluster")

infrastructureProvider := clusterctl.DefaultInfrastructureProvider
if input.InfrastructureProvider != nil {
infrastructureProvider = *input.InfrastructureProvider
}

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,
InfrastructureProvider: infrastructureProvider,
Flavor: pointer.StringDeref(input.Flavor, "upgrades"),
Namespace: namespace.Name,
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
Expand Down
14 changes: 13 additions & 1 deletion test/e2e/cluster_upgrade_runtimesdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ type clusterUpgradeWithRuntimeSDKSpecInput struct {
ArtifactFolder string
SkipCleanup bool

// InfrastructureProviders specifies the infrastructure to use for clusterctl
// operations (Example: get cluster templates).
// Note: In most cases this need not be specified. It only needs to be specified when
// multiple infrastructure providers (ex: CAPD + in-memory) are installed on the cluster as clusterctl will not be
// able to identify the default.
InfrastructureProvider *string

// ControlPlaneMachineCount is used in `config cluster` to configure the count of the control plane machines used in the test.
// Default is 1.
ControlPlaneMachineCount *int64
Expand Down Expand Up @@ -150,13 +157,18 @@ func clusterUpgradeWithRuntimeSDKSpec(ctx context.Context, inputGetter func() cl
Namespace: namespace.Name,
}

infrastructureProvider := clusterctl.DefaultInfrastructureProvider
if input.InfrastructureProvider != nil {
infrastructureProvider = *input.InfrastructureProvider
}

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,
InfrastructureProvider: infrastructureProvider,
Flavor: pointer.StringDeref(input.Flavor, "upgrades"),
Namespace: namespace.Name,
ClusterName: clusterName,
Expand Down
11 changes: 6 additions & 5 deletions test/e2e/cluster_upgrade_runtimesdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ var _ = Describe("When upgrading a workload cluster using ClusterClass with Runt
}

return clusterUpgradeWithRuntimeSDKSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
InfrastructureProvider: pointer.String("docker"),
// "upgrades" is the same as the "topology" flavor but with an additional MachinePool.
Flavor: pointer.String("upgrades-runtimesdk"),
}
Expand Down
48 changes: 26 additions & 22 deletions test/e2e/cluster_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,27 @@ var _ = Describe("When upgrading a workload cluster using ClusterClass and testi
}

return ClusterUpgradeConformanceSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
Flavor: flavor,
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
Flavor: flavor,
InfrastructureProvider: pointer.String("docker"),
}
})
})

var _ = Describe("When upgrading a workload cluster using ClusterClass [ClusterClass]", func() {
ClusterUpgradeConformanceSpec(ctx, func() ClusterUpgradeConformanceSpecInput {
return ClusterUpgradeConformanceSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
Flavor: pointer.String("topology"),
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
InfrastructureProvider: pointer.String("docker"),
Flavor: pointer.String("topology"),
// This test is run in CI in parallel with other tests. To keep the test duration reasonable
// the conformance tests are skipped.
ControlPlaneMachineCount: pointer.Int64(1),
Expand All @@ -83,11 +85,12 @@ var _ = Describe("When upgrading a workload cluster using ClusterClass [ClusterC
var _ = Describe("When upgrading a workload cluster using ClusterClass with a HA control plane [ClusterClass]", func() {
ClusterUpgradeConformanceSpec(ctx, func() ClusterUpgradeConformanceSpecInput {
return ClusterUpgradeConformanceSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
InfrastructureProvider: pointer.String("docker"),
// This test is run in CI in parallel with other tests. To keep the test duration reasonable
// the conformance tests are skipped.
SkipConformanceTests: true,
Expand All @@ -101,11 +104,12 @@ var _ = Describe("When upgrading a workload cluster using ClusterClass with a HA
var _ = Describe("When upgrading a workload cluster using ClusterClass with a HA control plane using scale-in rollout [ClusterClass]", func() {
ClusterUpgradeConformanceSpec(ctx, func() ClusterUpgradeConformanceSpecInput {
return ClusterUpgradeConformanceSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
InfrastructureProvider: pointer.String("docker"),
// This test is run in CI in parallel with other tests. To keep the test duration reasonable
// the conformance tests are skipped.
SkipConformanceTests: true,
Expand Down
12 changes: 11 additions & 1 deletion test/e2e/clusterclass_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ type ClusterClassChangesSpecInput struct {
SkipCleanup bool
ControlPlaneWaiters clusterctl.ControlPlaneWaiters

// InfrastructureProviders specifies the infrastructure to use for clusterctl
// operations (Example: get cluster templates).
// Note: In most cases this need not be specified. It only needs to be specified when
// multiple infrastructure providers (ex: CAPD + in-memory) are installed on the cluster as clusterctl will not be
// able to identify the default.
InfrastructureProvider *string
// Flavor is the cluster-template flavor used to create the Cluster for testing.
// NOTE: The template must be using a ClusterClass.
Flavor string
Expand Down Expand Up @@ -131,13 +137,17 @@ func ClusterClassChangesSpec(ctx context.Context, inputGetter func() ClusterClas

It("Should successfully rollout the managed topology upon changes to the ClusterClass", func() {
By("Creating a workload cluster")
infrastructureProvider := clusterctl.DefaultInfrastructureProvider
if input.InfrastructureProvider != nil {
infrastructureProvider = *input.InfrastructureProvider
}
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,
InfrastructureProvider: infrastructureProvider,
Flavor: input.Flavor,
Namespace: namespace.Name,
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
Expand Down
14 changes: 8 additions & 6 deletions test/e2e/clusterclass_changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ package e2e

import (
. "github.com/onsi/ginkgo/v2"
"k8s.io/utils/pointer"
)

var _ = Describe("When testing ClusterClass changes [ClusterClass]", func() {
ClusterClassChangesSpec(ctx, func() ClusterClassChangesSpecInput {
return ClusterClassChangesSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
Flavor: "topology",
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
InfrastructureProvider: pointer.String("docker"),
Flavor: "topology",
// 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.
Expand Down
13 changes: 12 additions & 1 deletion test/e2e/clusterclass_rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ type ClusterClassRolloutSpecInput struct {
SkipCleanup bool
ControlPlaneWaiters clusterctl.ControlPlaneWaiters

// InfrastructureProviders specifies the infrastructure to use for clusterctl
// operations (Example: get cluster templates).
// Note: In most cases this need not be specified. It only needs to be specified when
// multiple infrastructure providers (ex: CAPD + in-memory) are installed on the cluster as clusterctl will not be
// able to identify the default.
InfrastructureProvider *string

// Flavor is the cluster-template flavor used to create the Cluster for testing.
// NOTE: The template must be using ClusterClass, KCP and CABPK as this test is specifically
// testing ClusterClass and KCP rollout behavior.
Expand Down Expand Up @@ -105,13 +112,17 @@ func ClusterClassRolloutSpec(ctx context.Context, inputGetter func() ClusterClas

It("Should successfully rollout the managed topology upon changes to the ClusterClass", func() {
By("Creating a workload cluster")
infrastructureProvider := clusterctl.DefaultInfrastructureProvider
if input.InfrastructureProvider != nil {
infrastructureProvider = *input.InfrastructureProvider
}
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,
InfrastructureProvider: infrastructureProvider,
Flavor: input.Flavor,
Namespace: namespace.Name,
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
Expand Down
14 changes: 8 additions & 6 deletions test/e2e/clusterclass_rollout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ package e2e

import (
. "github.com/onsi/ginkgo/v2"
"k8s.io/utils/pointer"
)

var _ = Describe("When testing ClusterClass rollouts [ClusterClass]", func() {
ClusterClassRolloutSpec(ctx, func() ClusterClassRolloutSpecInput {
return ClusterClassRolloutSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
Flavor: "topology",
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
Flavor: "topology",
InfrastructureProvider: pointer.String("docker"),
}
})
})
15 changes: 13 additions & 2 deletions test/e2e/clusterctl_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ type ClusterctlUpgradeSpecInput struct {
// UpgradeClusterctlVariables can be used to set additional variables for clusterctl upgrade.
UpgradeClusterctlVariables map[string]string
SkipCleanup bool

// InfrastructureProviders specifies the infrastructure to use for clusterctl
// operations (Example: get cluster templates).
// Note: In most cases this need not be specified. It only needs to be specified when
// multiple infrastructure providers (ex: CAPD + in-memory) are installed on the cluster as clusterctl will not be
// able to identify the default.
InfrastructureProvider *string
// 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)
Expand Down Expand Up @@ -216,14 +223,18 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
By("Creating a workload cluster to be used as a new management cluster")
// NOTE: given that the bootstrap cluster could be shared by several tests, it is not practical to use it for testing clusterctl upgrades.
// So we are creating a workload cluster that will be used as a new management cluster where to install older version of providers
infrastructureProvider := clusterctl.DefaultInfrastructureProvider
if input.InfrastructureProvider != nil {
infrastructureProvider = *input.InfrastructureProvider
}
managementClusterName = fmt.Sprintf("%s-%s", specName, util.RandomString(6))
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,
InfrastructureProvider: infrastructureProvider,
Flavor: input.MgmtFlavor,
Namespace: managementClusterNamespace.Name,
ClusterName: managementClusterName,
Expand Down Expand Up @@ -362,7 +373,7 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
KubernetesVersion: kubernetesVersion,
ControlPlaneMachineCount: controlPlaneMachineCount,
WorkerMachineCount: workerMachineCount,
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
InfrastructureProvider: infrastructureProvider,
// setup clusterctl logs folder
LogFolder: filepath.Join(input.ArtifactFolder, "clusters", managementClusterProxy.GetName()),
})
Expand Down
Loading

0 comments on commit caaa744

Please sign in to comment.