diff --git a/scripts/ci-e2e.sh b/scripts/ci-e2e.sh index f0ab15963c..a03cb9d094 100755 --- a/scripts/ci-e2e.sh +++ b/scripts/ci-e2e.sh @@ -20,8 +20,8 @@ source "${REPO_ROOT}/scripts/environment.sh" # Clone dev-env repo sudo mkdir -p ${WORKING_DIR} sudo chown "${USER}":"${USER}" ${WORKING_DIR} -M3_DEV_ENV_REPO="https://github.com/metal3-io/metal3-dev-env.git" -M3_DEV_ENV_BRANCH=main +M3_DEV_ENV_REPO="https://github.com/Nordix/metal3-dev-env.git" +M3_DEV_ENV_BRANCH=uplift-k8s-1.31.0-rc.0/adil M3_DEV_ENV_PATH="${M3_DEV_ENV_PATH:-${WORKING_DIR}/metal3-dev-env}" clone_repo "${M3_DEV_ENV_REPO}" "${M3_DEV_ENV_BRANCH}" "${M3_DEV_ENV_PATH}" diff --git a/test/e2e/common.go b/test/e2e/common.go index 4fe59da41a..a472e68057 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -417,6 +417,25 @@ func ListNodes(ctx context.Context, c client.Client) { logTable("Listing Nodes", rows) } +func CreateNewM3MachineTemplate(ctx context.Context, namespace string, newM3MachineTemplateName string, m3MachineTemplateName string, clusterClient client.Client, imageURL string, imageChecksum string) { + checksumType := "sha256" + imageFormat := "raw" + + m3MachineTemplate := infrav1.Metal3MachineTemplate{} + Expect(clusterClient.Get(ctx, client.ObjectKey{Namespace: namespace, Name: m3MachineTemplateName}, &m3MachineTemplate)).To(Succeed()) + + newM3MachineTemplate := m3MachineTemplate.DeepCopy() + cleanObjectMeta(&newM3MachineTemplate.ObjectMeta) + + newM3MachineTemplate.Spec.Template.Spec.Image.URL = imageURL + newM3MachineTemplate.Spec.Template.Spec.Image.Checksum = imageChecksum + newM3MachineTemplate.Spec.Template.Spec.Image.DiskFormat = &imageFormat + newM3MachineTemplate.Spec.Template.Spec.Image.ChecksumType = &checksumType + newM3MachineTemplate.ObjectMeta.Name = newM3MachineTemplateName + + Expect(clusterClient.Create(ctx, newM3MachineTemplate)).To(Succeed(), "Failed to create new Metal3MachineTemplate") +} + type WaitForNumInput struct { Client client.Client Options []client.ListOption diff --git a/test/e2e/config/e2e_conf.yaml b/test/e2e/config/e2e_conf.yaml index 420ec3b6b5..32c726911c 100644 --- a/test/e2e/config/e2e_conf.yaml +++ b/test/e2e/config/e2e_conf.yaml @@ -17,6 +17,15 @@ providers: - name: cluster-api type: CoreProvider versions: + - name: "v1.8.0" # supported release in the v1beta1 series + value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.8.0-rc.0/core-components.yaml" + type: "url" + contract: v1beta1 + replacements: + - old: --metrics-addr=127.0.0.1:8080 + new: --metrics-addr=:8080 + files: + - sourcePath: "../data/shared/v1.8/metadata.yaml" - name: "{go://sigs.k8s.io/cluster-api@v1.7}" value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/{go://sigs.k8s.io/cluster-api@v1.7}/core-components.yaml" type: "url" @@ -35,18 +44,18 @@ providers: new: --metrics-addr=:8080 files: - sourcePath: "../data/shared/v1.6/metadata.yaml" - - name: "{go://sigs.k8s.io/cluster-api@v1.5}" - value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/{go://sigs.k8s.io/cluster-api@v1.5}/core-components.yaml" +- name: kubeadm + type: BootstrapProvider + versions: + - name: "v1.8.0" # supported release in the v1beta1 series + value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.8.0-rc.0/bootstrap-components.yaml" type: "url" contract: v1beta1 replacements: - old: --metrics-addr=127.0.0.1:8080 new: --metrics-addr=:8080 files: - - sourcePath: "../data/shared/v1.5/metadata.yaml" -- name: kubeadm - type: BootstrapProvider - versions: + - sourcePath: "../data/shared/v1.8/metadata.yaml" - name: "{go://sigs.k8s.io/cluster-api@v1.7}" value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/{go://sigs.k8s.io/cluster-api@v1.7}/bootstrap-components.yaml" type: "url" @@ -65,18 +74,18 @@ providers: new: --metrics-addr=:8080 files: - sourcePath: "../data/shared/v1.6/metadata.yaml" - - name: "{go://sigs.k8s.io/cluster-api@v1.5}" - value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/{go://sigs.k8s.io/cluster-api@v1.5}/bootstrap-components.yaml" +- name: kubeadm + type: ControlPlaneProvider + versions: + - name: "v1.8.0" # supported release in the v1beta1 series + value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.8.0-rc.0/control-plane-components.yaml" type: "url" contract: v1beta1 replacements: - old: --metrics-addr=127.0.0.1:8080 new: --metrics-addr=:8080 files: - - sourcePath: "../data/shared/v1.5/metadata.yaml" -- name: kubeadm - type: ControlPlaneProvider - versions: + - sourcePath: "../data/shared/v1.8/metadata.yaml" - name: "{go://sigs.k8s.io/cluster-api@v1.7}" value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/{go://sigs.k8s.io/cluster-api@v1.7}/control-plane-components.yaml" type: "url" @@ -95,19 +104,7 @@ providers: new: --metrics-addr=:8080 files: - sourcePath: "../data/shared/v1.6/metadata.yaml" - - name: "{go://sigs.k8s.io/cluster-api@v1.5}" - value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/{go://sigs.k8s.io/cluster-api@v1.5}/control-plane-components.yaml" - type: "url" - contract: v1beta1 - replacements: - - old: --metrics-addr=127.0.0.1:8080 - new: --metrics-addr=:8080 - files: - - sourcePath: "../data/shared/v1.5/metadata.yaml" - # https://proxy.golang.org/sigs.k8s.io/cluster-api/@v/list - -# https://proxy.golang.org/github.com/metal3-io/cluster-api-provider-metal3/@v/list - name: metal3 type: InfrastructureProvider versions: diff --git a/test/e2e/data/shared/v1.8/metadata.yaml b/test/e2e/data/shared/v1.8/metadata.yaml new file mode 100644 index 0000000000..c692cde2d6 --- /dev/null +++ b/test/e2e/data/shared/v1.8/metadata.yaml @@ -0,0 +1,35 @@ +# maps release series of major.minor to cluster-api contract version +# the contract version may change between minor or major versions, but *not* +# between patch versions. +# +# update this file only when a new major or minor version is released +apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3 +kind: Metadata +releaseSeries: + - major: 1 + minor: 8 + contract: v1beta1 + - major: 1 + minor: 7 + contract: v1beta1 + - major: 1 + minor: 6 + contract: v1beta1 + - major: 1 + minor: 5 + contract: v1beta1 + - major: 1 + minor: 4 + contract: v1beta1 + - major: 1 + minor: 3 + contract: v1beta1 + - major: 1 + minor: 2 + contract: v1beta1 + - major: 1 + minor: 1 + contract: v1beta1 + - major: 1 + minor: 0 + contract: v1beta1 diff --git a/test/e2e/ip_reuse.go b/test/e2e/ip_reuse.go index a3d6e2b499..e9e11250ee 100644 --- a/test/e2e/ip_reuse.go +++ b/test/e2e/ip_reuse.go @@ -8,7 +8,6 @@ import ( bmov1alpha1 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/types" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/test/framework/clusterctl" @@ -116,24 +115,23 @@ func IPReuse(ctx context.Context, inputGetter func() IPReuseInput) { Expect(machineDeployments).To(HaveLen(1), "Expected exactly 1 MachineDeployment") md := machineDeployments[0] + // Download node image + Byf("Download image %s", kubernetesVersion) + imageURL, imageChecksum := EnsureImage(kubernetesVersion) + + By("Create new worker Metal3MachineTemplate with upgraded image to boot") + m3MachineTemplateName := md.Spec.Template.Spec.InfrastructureRef.Name + newM3MachineTemplateName := fmt.Sprintf("%s-new", m3MachineTemplateName) + CreateNewM3MachineTemplate(ctx, input.Namespace, newM3MachineTemplateName, m3MachineTemplateName, managementClusterClient, imageURL, imageChecksum) + Byf("Update MachineDeployment maxUnavailable to number of workers and k8s version from %s to %s", fromK8sVersion, kubernetesVersion) - patch := []byte(fmt.Sprintf(`{ - "spec": { - "strategy": { - "rollingUpdate": { - "maxSurge": 0, - "maxUnavailable": 3 - } - }, - "template": { - "spec": { - "version": "%s" - } - } - } - }`, kubernetesVersion)) - err = managementClusterClient.Patch(ctx, md, client.RawPatch(types.MergePatchType, patch)) - Expect(err).ToNot(HaveOccurred(), "Failed to patch MachineDeployment") + helper, err := patch.NewHelper(md, managementClusterClient) + Expect(err).NotTo(HaveOccurred()) + md.Spec.Template.Spec.InfrastructureRef.Name = newM3MachineTemplateName + md.Spec.Template.Spec.Version = &kubernetesVersion + md.Spec.Strategy.RollingUpdate.MaxSurge.IntVal = 0 + md.Spec.Strategy.RollingUpdate.MaxUnavailable.IntVal = 3 + Expect(helper.Patch(ctx, md)).To(Succeed()) Byf("Wait until %d BMH(s) in deprovisioning state", 3) WaitForNumBmhInState(ctx, bmov1alpha1.StateDeprovisioning, WaitForNumInput{ @@ -143,6 +141,11 @@ func IPReuse(ctx context.Context, inputGetter func() IPReuseInput) { Intervals: input.E2EConfig.GetIntervals(input.SpecName, "wait-bmh-deprovisioning"), }) + ListBareMetalHosts(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListMetal3Machines(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListMachines(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListNodes(ctx, targetClusterClient) + Byf("Wait until all %d machine(s) become(s) running", 4) WaitForNumMachinesInState(ctx, clusterv1.MachinePhaseRunning, WaitForNumInput{ Client: managementClusterClient, @@ -151,6 +154,11 @@ func IPReuse(ctx context.Context, inputGetter func() IPReuseInput) { Intervals: input.E2EConfig.GetIntervals(input.SpecName, "wait-machine-running"), }) + ListBareMetalHosts(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListMetal3Machines(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListMachines(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListNodes(ctx, targetClusterClient) + By("Get the IPPools in the cluster") baremetalv4Pool, provisioningPool = GetIPPools(ctx, managementClusterClient, input.ClusterName, input.Namespace) Expect(baremetalv4Pool).To(HaveLen(1)) diff --git a/test/e2e/node_reuse.go b/test/e2e/node_reuse.go index d26dcaf952..9272a44034 100644 --- a/test/e2e/node_reuse.go +++ b/test/e2e/node_reuse.go @@ -108,7 +108,7 @@ func nodeReuse(ctx context.Context, inputGetter func() NodeReuseInput) { m3MachineTemplateName := fmt.Sprintf("%s-controlplane", input.ClusterName) updateNodeReuse(ctx, input.Namespace, true, m3MachineTemplateName, managementClusterClient) newM3MachineTemplateName := fmt.Sprintf("%s-new-controlplane", input.ClusterName) - createNewM3MachineTemplate(ctx, input.Namespace, newM3MachineTemplateName, m3MachineTemplateName, managementClusterClient, imageURL, imageChecksum) + CreateNewM3MachineTemplate(ctx, input.Namespace, newM3MachineTemplateName, m3MachineTemplateName, managementClusterClient, imageURL, imageChecksum) Byf("Update KCP to upgrade k8s version and binaries from %s to %s [node_reuse]", kubernetesVersion, upgradedK8sVersion) kcpObj := framework.GetKubeadmControlPlaneByCluster(ctx, framework.GetKubeadmControlPlaneByClusterInput{ @@ -330,7 +330,7 @@ func nodeReuse(ctx context.Context, inputGetter func() NodeReuseInput) { By("Set nodeReuse field to 'True' and create new Metal3MachineTemplate for MD with upgraded image to boot [node_reuse]") updateNodeReuse(ctx, input.Namespace, true, m3MachineTemplateName, managementClusterClient) newM3MachineTemplateName = fmt.Sprintf("%s-new-workers", input.ClusterName) - createNewM3MachineTemplate(ctx, input.Namespace, newM3MachineTemplateName, m3MachineTemplateName, managementClusterClient, imageURL, imageChecksum) + CreateNewM3MachineTemplate(ctx, input.Namespace, newM3MachineTemplateName, m3MachineTemplateName, managementClusterClient, imageURL, imageChecksum) Byf("Update MD to upgrade k8s version and binaries from %s to %s", kubernetesVersion, upgradedK8sVersion) // Note: We have only 4 nodes (3 control-plane and 1 worker) so we @@ -536,22 +536,3 @@ func deleteTaint(taints []corev1.Taint, taintsToDelete []corev1.Taint) ([]corev1 } return newTaints, deleted } - -func createNewM3MachineTemplate(ctx context.Context, namespace string, newM3MachineTemplateName string, m3MachineTemplateName string, clusterClient client.Client, imageURL string, imageChecksum string) { - checksumType := "sha256" - imageFormat := "raw" - - m3MachineTemplate := infrav1.Metal3MachineTemplate{} - Expect(clusterClient.Get(ctx, client.ObjectKey{Namespace: namespace, Name: m3MachineTemplateName}, &m3MachineTemplate)).To(Succeed()) - - newM3MachineTemplate := m3MachineTemplate.DeepCopy() - cleanObjectMeta(&newM3MachineTemplate.ObjectMeta) - - newM3MachineTemplate.Spec.Template.Spec.Image.URL = imageURL - newM3MachineTemplate.Spec.Template.Spec.Image.Checksum = imageChecksum - newM3MachineTemplate.Spec.Template.Spec.Image.DiskFormat = &imageFormat - newM3MachineTemplate.Spec.Template.Spec.Image.ChecksumType = &checksumType - newM3MachineTemplate.ObjectMeta.Name = newM3MachineTemplateName - - Expect(clusterClient.Create(ctx, newM3MachineTemplate)).To(Succeed(), "Failed to create new Metal3MachineTemplate") -} diff --git a/test/e2e/upgrade_kubernetes_test.go b/test/e2e/upgrade_kubernetes_test.go index ce4fa55145..e2b2d1e9af 100644 --- a/test/e2e/upgrade_kubernetes_test.go +++ b/test/e2e/upgrade_kubernetes_test.go @@ -108,7 +108,7 @@ func upgradeKubernetes(ctx context.Context, inputGetter func() upgradeKubernetes By("Create new KCP Metal3MachineTemplate with upgraded image to boot") m3MachineTemplateName := fmt.Sprintf("%s-controlplane", clusterName) newM3MachineTemplateName := fmt.Sprintf("%s-new-controlplane", clusterName) - createNewM3MachineTemplate(ctx, namespace, newM3MachineTemplateName, m3MachineTemplateName, clusterClient, imageURL, imageChecksum) + CreateNewM3MachineTemplate(ctx, namespace, newM3MachineTemplateName, m3MachineTemplateName, clusterClient, imageURL, imageChecksum) Byf("Update KCP to upgrade k8s version and binaries from %s to %s", kubernetesVersion, upgradedK8sVersion) kcpObj := framework.GetKubeadmControlPlaneByCluster(ctx, framework.GetKubeadmControlPlaneByClusterInput{ @@ -177,7 +177,7 @@ func upgradeKubernetes(ctx context.Context, inputGetter func() upgradeKubernetes By("Create new Metal3MachineTemplate for MD with upgraded image to boot") m3MachineTemplateName = fmt.Sprintf("%s-workers", clusterName) newM3MachineTemplateName = fmt.Sprintf("%s-new-workers", clusterName) - createNewM3MachineTemplate(ctx, namespace, newM3MachineTemplateName, m3MachineTemplateName, clusterClient, imageURL, imageChecksum) + CreateNewM3MachineTemplate(ctx, namespace, newM3MachineTemplateName, m3MachineTemplateName, clusterClient, imageURL, imageChecksum) Byf("Update MD to upgrade k8s version and binaries from %s to %s", kubernetesVersion, upgradedK8sVersion) helper, err = patch.NewHelper(machineDeploy, clusterClient)