diff --git a/test/e2e/clusterctl_upgrade.go b/test/e2e/clusterctl_upgrade.go index 781a086cdfd2..b38677dc0222 100644 --- a/test/e2e/clusterctl_upgrade.go +++ b/test/e2e/clusterctl_upgrade.go @@ -24,6 +24,7 @@ import ( "os" "path/filepath" "runtime" + "sort" "strings" . "github.com/onsi/ginkgo/v2" @@ -400,6 +401,11 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg Kind: machineCRD.Spec.Names.ListKind, } + // Sort the machineCRD.Spec.Versions slice + sort.Slice(machineCRD.Spec.Versions, func(i, j int) bool { + return machineCRD.Spec.Versions[i].Name < machineCRD.Spec.Versions[j].Name + }) + // Pick the first served version for _, gvk := range machineCRD.Spec.Versions { if gvk.Served {