From 7f964bb3a6837660689348d40ef420561d932319 Mon Sep 17 00:00:00 2001 From: Thomas Cordeu Date: Thu, 27 May 2021 12:35:42 -0300 Subject: [PATCH] Divide KCPUpgrade E2E test suite --- test/e2e/kcp_upgrade.go | 94 +++++------------------------------- test/e2e/kcp_upgrade_test.go | 42 +++++++++++++--- 2 files changed, 48 insertions(+), 88 deletions(-) diff --git a/test/e2e/kcp_upgrade.go b/test/e2e/kcp_upgrade.go index e09213dc7ec2..773122c9297b 100644 --- a/test/e2e/kcp_upgrade.go +++ b/test/e2e/kcp_upgrade.go @@ -35,11 +35,13 @@ import ( // KCPUpgradeSpecInput is the input for KCPUpgradeSpec. type KCPUpgradeSpecInput struct { - E2EConfig *clusterctl.E2EConfig - ClusterctlConfigPath string - BootstrapClusterProxy framework.ClusterProxy - ArtifactFolder string - SkipCleanup bool + E2EConfig *clusterctl.E2EConfig + ClusterctlConfigPath string + BootstrapClusterProxy framework.ClusterProxy + ArtifactFolder string + SkipCleanup bool + ControlPlaneMachineCount int64 + Flavor string } // KCPUpgradeSpec implements a test that verifies KCP to properly upgrade a control plane with 3 machines. @@ -59,6 +61,8 @@ func KCPUpgradeSpec(ctx context.Context, inputGetter func() KCPUpgradeSpecInput) Expect(input.ClusterctlConfigPath).To(BeAnExistingFile(), "Invalid argument. input.ClusterctlConfigPath must be an existing file when calling %s spec", specName) Expect(input.BootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. input.BootstrapClusterProxy can't be nil when calling %s spec", specName) Expect(os.MkdirAll(input.ArtifactFolder, 0755)).To(Succeed(), "Invalid argument. input.ArtifactFolder can't be created for %s spec", specName) + Expect(input.ControlPlaneMachineCount).ToNot(BeZero()) + Expect(input.Flavor).ToNot(BeEmpty()) Expect(input.E2EConfig.Variables).To(HaveKey(KubernetesVersionUpgradeTo)) Expect(input.E2EConfig.Variables).To(HaveKey(KubernetesVersionUpgradeFrom)) Expect(input.E2EConfig.Variables).To(HaveKey(EtcdVersionUpgradeTo)) @@ -69,7 +73,7 @@ func KCPUpgradeSpec(ctx context.Context, inputGetter func() KCPUpgradeSpecInput) clusterResources = new(clusterctl.ApplyClusterTemplateAndWaitResult) }) - It("Should successfully upgrade Kubernetes, DNS, kube-proxy, and etcd in a single control plane cluster", func() { + It("Should successfully upgrade Kubernetes, DNS, kube-proxy, and etcd", func() { By("Creating a workload cluster") clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{ ClusterProxy: input.BootstrapClusterProxy, @@ -78,85 +82,11 @@ func KCPUpgradeSpec(ctx context.Context, inputGetter func() KCPUpgradeSpecInput) 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), - ControlPlaneMachineCount: pointer.Int64Ptr(1), - WorkerMachineCount: pointer.Int64Ptr(1), - }, - WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"), - WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"), - WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"), - }, clusterResources) - - By("Upgrading Kubernetes, DNS, kube-proxy, and etcd versions") - framework.UpgradeControlPlaneAndWaitForUpgrade(ctx, framework.UpgradeControlPlaneAndWaitForUpgradeInput{ - ClusterProxy: input.BootstrapClusterProxy, - Cluster: clusterResources.Cluster, - ControlPlane: clusterResources.ControlPlane, - EtcdImageTag: input.E2EConfig.GetVariable(EtcdVersionUpgradeTo), - DNSImageTag: input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo), - KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo), - WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"), - WaitForDNSUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"), - WaitForEtcdUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"), - }) - - By("PASSED!") - }) - - It("Should successfully upgrade Kubernetes, DNS, kube-proxy, and etcd in a HA cluster", 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, - Namespace: namespace.Name, - ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)), - KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeFrom), - ControlPlaneMachineCount: pointer.Int64Ptr(3), - WorkerMachineCount: pointer.Int64Ptr(1), - }, - WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"), - WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"), - WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"), - }, clusterResources) - - By("Upgrading Kubernetes, DNS, kube-proxy, and etcd versions") - framework.UpgradeControlPlaneAndWaitForUpgrade(ctx, framework.UpgradeControlPlaneAndWaitForUpgradeInput{ - ClusterProxy: input.BootstrapClusterProxy, - Cluster: clusterResources.Cluster, - ControlPlane: clusterResources.ControlPlane, - EtcdImageTag: input.E2EConfig.GetVariable(EtcdVersionUpgradeTo), - DNSImageTag: input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo), - KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo), - WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"), - WaitForDNSUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"), - WaitForEtcdUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"), - }) - - By("PASSED!") - }) - - It("Should successfully upgrade Kubernetes, DNS, kube-proxy, and etcd in a HA cluster using scale in rollout", 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: "kcp-scale-in", - Namespace: namespace.Name, - ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)), - KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeFrom), - ControlPlaneMachineCount: pointer.Int64Ptr(3), + ControlPlaneMachineCount: pointer.Int64Ptr(input.ControlPlaneMachineCount), WorkerMachineCount: pointer.Int64Ptr(1), }, WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"), diff --git a/test/e2e/kcp_upgrade_test.go b/test/e2e/kcp_upgrade_test.go index e0ca5b2dd884..818e2323f54c 100644 --- a/test/e2e/kcp_upgrade_test.go +++ b/test/e2e/kcp_upgrade_test.go @@ -22,18 +22,48 @@ import ( "context" . "github.com/onsi/ginkgo" + + "sigs.k8s.io/cluster-api/test/framework/clusterctl" ) -var _ = Describe("When testing KCP upgrade", func() { +var _ = Describe("When testing KCP upgrade in a single control plane cluster", func() { + KCPUpgradeSpec(context.TODO(), func() KCPUpgradeSpecInput { + return KCPUpgradeSpecInput{ + E2EConfig: e2eConfig, + ClusterctlConfigPath: clusterctlConfigPath, + BootstrapClusterProxy: bootstrapClusterProxy, + ArtifactFolder: artifactFolder, + SkipCleanup: skipCleanup, + ControlPlaneMachineCount: 1, + Flavor: clusterctl.DefaultFlavor, + } + }) +}) +var _ = Describe("When testing KCP upgrade in a HA cluster", func() { KCPUpgradeSpec(context.TODO(), func() KCPUpgradeSpecInput { return KCPUpgradeSpecInput{ - E2EConfig: e2eConfig, - ClusterctlConfigPath: clusterctlConfigPath, - BootstrapClusterProxy: bootstrapClusterProxy, - ArtifactFolder: artifactFolder, - SkipCleanup: skipCleanup, + E2EConfig: e2eConfig, + ClusterctlConfigPath: clusterctlConfigPath, + BootstrapClusterProxy: bootstrapClusterProxy, + ArtifactFolder: artifactFolder, + SkipCleanup: skipCleanup, + ControlPlaneMachineCount: 3, + Flavor: clusterctl.DefaultFlavor, } }) +}) +var _ = Describe("When testing KCP upgrade in a HA cluster using scale in rollout", func() { + KCPUpgradeSpec(context.TODO(), func() KCPUpgradeSpecInput { + return KCPUpgradeSpecInput{ + E2EConfig: e2eConfig, + ClusterctlConfigPath: clusterctlConfigPath, + BootstrapClusterProxy: bootstrapClusterProxy, + ArtifactFolder: artifactFolder, + SkipCleanup: skipCleanup, + ControlPlaneMachineCount: 3, + Flavor: "kcp-scale-in", + } + }) })