sigs.k8s.io/cluster-api-provider-aws@v1.5.5/test/e2e/suites/managed/upgrade_test.go (about) 1 //go:build e2e 2 // +build e2e 3 4 /* 5 Copyright 2020 The Kubernetes Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 */ 19 20 package managed 21 22 import ( 23 "context" 24 "fmt" 25 26 "github.com/onsi/ginkgo" 27 . "github.com/onsi/gomega" 28 corev1 "k8s.io/api/core/v1" 29 30 ekscontrolplanev1 "sigs.k8s.io/cluster-api-provider-aws/controlplane/eks/api/v1beta1" 31 "sigs.k8s.io/cluster-api-provider-aws/test/e2e/shared" 32 "sigs.k8s.io/cluster-api/test/framework" 33 "sigs.k8s.io/cluster-api/util" 34 ) 35 36 // EKS cluster upgrade tests. 37 var _ = ginkgo.Describe("EKS Cluster upgrade test", func() { 38 const ( 39 initialVersion = "v1.21.0" 40 upgradeToVersion = "v1.22.0" 41 ) 42 var ( 43 namespace *corev1.Namespace 44 ctx context.Context 45 specName = "eks-upgrade" 46 clusterName string 47 ) 48 49 shared.ConditionalIt(runUpgradeTests, "[managed] [upgrade] should create a cluster and upgrade the kubernetes version", func() { 50 ginkgo.By("should have a valid test configuration") 51 Expect(e2eCtx.Environment.BootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. BootstrapClusterProxy can't be nil") 52 Expect(e2eCtx.E2EConfig).ToNot(BeNil(), "Invalid argument. e2eConfig can't be nil when calling %s spec", specName) 53 Expect(e2eCtx.E2EConfig.Variables).To(HaveKey(shared.KubernetesVersion)) 54 55 ctx = context.TODO() 56 namespace = shared.SetupSpecNamespace(ctx, specName, e2eCtx) 57 clusterName = fmt.Sprintf("%s-%s", specName, util.RandomString(6)) 58 59 ginkgo.By("default iam role should exist") 60 VerifyRoleExistsAndOwned(ekscontrolplanev1.DefaultEKSControlPlaneRole, clusterName, false, e2eCtx.BootstrapUserAWSSession) 61 62 ginkgo.By("should create an EKS control plane") 63 ManagedClusterSpec(ctx, func() ManagedClusterSpecInput { 64 return ManagedClusterSpecInput{ 65 E2EConfig: e2eCtx.E2EConfig, 66 ConfigClusterFn: defaultConfigCluster, 67 BootstrapClusterProxy: e2eCtx.Environment.BootstrapClusterProxy, 68 AWSSession: e2eCtx.BootstrapUserAWSSession, 69 Namespace: namespace, 70 ClusterName: clusterName, 71 Flavour: EKSControlPlaneOnlyFlavor, // TODO (richardcase) - change in the future when upgrades to machinepools work 72 ControlPlaneMachineCount: 1, // NOTE: this cannot be zero as clusterctl returns an error 73 WorkerMachineCount: 1, 74 KubernetesVersion: initialVersion, 75 } 76 }) 77 78 // TODO: should cluster be returned from the ManagedClusterSpec as a convenience 79 shared.Byf("getting cluster with name %s", clusterName) 80 cluster := framework.GetClusterByName(ctx, framework.GetClusterByNameInput{ 81 Getter: e2eCtx.Environment.BootstrapClusterProxy.GetClient(), 82 Namespace: namespace.Name, 83 Name: clusterName, 84 }) 85 Expect(cluster).NotTo(BeNil(), "couldn't find cluster") 86 87 // TODO (richardcase) - uncomment when we use machine pools again 88 // shared.Byf("Waiting for the machine pool to be running") 89 // mp := framework.DiscoveryAndWaitForMachinePools(ctx, framework.DiscoveryAndWaitForMachinePoolsInput{ 90 // Lister: e2eCtx.Environment.BootstrapClusterProxy.GetClient(), 91 // Getter: e2eCtx.Environment.BootstrapClusterProxy.GetClient(), 92 // Cluster: cluster, 93 // }, e2eCtx.E2EConfig.GetIntervals("", "wait-worker-nodes")...) 94 // Expect(len(mp)).To(Equal(1)) 95 96 shared.Byf("should upgrade control plane to version %s", upgradeToVersion) 97 UpgradeControlPlaneVersionSpec(ctx, func() UpgradeControlPlaneVersionSpecInput { 98 return UpgradeControlPlaneVersionSpecInput{ 99 E2EConfig: e2eCtx.E2EConfig, 100 AWSSession: e2eCtx.BootstrapUserAWSSession, 101 BootstrapClusterProxy: e2eCtx.Environment.BootstrapClusterProxy, 102 ClusterName: clusterName, 103 Namespace: namespace, 104 UpgradeVersion: upgradeToVersion, 105 } 106 }) 107 108 // TODO (richardcase): add test for the node group upgrade 109 110 framework.DeleteCluster(ctx, framework.DeleteClusterInput{ 111 Deleter: e2eCtx.Environment.BootstrapClusterProxy.GetClient(), 112 Cluster: cluster, 113 }) 114 framework.WaitForClusterDeleted(ctx, framework.WaitForClusterDeletedInput{ 115 Getter: e2eCtx.Environment.BootstrapClusterProxy.GetClient(), 116 Cluster: cluster, 117 }, e2eCtx.E2EConfig.GetIntervals("", "wait-delete-cluster")...) 118 }) 119 })