@@ -19,9 +19,13 @@ package e2e
19
19
import (
20
20
"context"
21
21
"fmt"
22
+ "strings"
22
23
23
24
. "github.com/onsi/ginkgo/v2"
24
25
. "github.com/onsi/gomega"
26
+ apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
27
+ clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
28
+ clusterctlcluster "sigs.k8s.io/cluster-api/cmd/clusterctl/client/cluster"
25
29
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
26
30
"sigs.k8s.io/cluster-api/test/framework"
27
31
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
@@ -67,6 +71,15 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.12
67
71
InitWithInfrastructureProviders : []string {fmt .Sprintf (providerVSpherePrefix , capvStableRelease )},
68
72
InitWithRuntimeExtensionProviders : testSpecificSettingsGetter ().RuntimeExtensionProviders ,
69
73
InitWithIPAMProviders : []string {},
74
+ Upgrades : []capi_e2e.ClusterctlUpgradeSpecInputUpgrade {
75
+ { // Upgrade to latest v1beta1.
76
+ Contract : clusterv1 .GroupVersion .Version ,
77
+ PostUpgrade : func (proxy framework.ClusterProxy , namespace , clusterName string ) {
78
+ framework .ValidateCRDMigration (ctx , proxy , namespace , clusterName ,
79
+ crdShouldBeMigrated , clusterctlcluster .FilterClusterObjectsWithNameFilter (clusterName ))
80
+ },
81
+ },
82
+ },
70
83
// InitWithKubernetesVersion should be the highest kubernetes version supported by the init Cluster API version.
71
84
// This is to guarantee that both, the old and new CAPI version, support the defined version.
72
85
// Ensure all Kubernetes versions used here are covered in patch-vsphere-template.yaml
@@ -112,6 +125,15 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.12
112
125
InitWithInfrastructureProviders : []string {fmt .Sprintf (providerVSpherePrefix , capvStableRelease )},
113
126
InitWithRuntimeExtensionProviders : testSpecificSettingsGetter ().RuntimeExtensionProviders ,
114
127
InitWithIPAMProviders : []string {},
128
+ Upgrades : []capi_e2e.ClusterctlUpgradeSpecInputUpgrade {
129
+ { // Upgrade to latest v1beta1.
130
+ Contract : clusterv1 .GroupVersion .Version ,
131
+ PostUpgrade : func (proxy framework.ClusterProxy , namespace , clusterName string ) {
132
+ framework .ValidateCRDMigration (ctx , proxy , namespace , clusterName ,
133
+ crdShouldBeMigrated , clusterctlcluster .FilterClusterObjectsWithNameFilter (clusterName ))
134
+ },
135
+ },
136
+ },
115
137
// InitWithKubernetesVersion should be the highest kubernetes version supported by the init Cluster API version.
116
138
// This is to guarantee that both, the old and new CAPI version, support the defined version.
117
139
// Ensure all Kubernetes versions used here are covered in patch-vsphere-template.yaml
@@ -157,6 +179,15 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.11
157
179
InitWithInfrastructureProviders : []string {fmt .Sprintf (providerVSpherePrefix , capvStableRelease )},
158
180
InitWithRuntimeExtensionProviders : testSpecificSettingsGetter ().RuntimeExtensionProviders ,
159
181
InitWithIPAMProviders : []string {},
182
+ Upgrades : []capi_e2e.ClusterctlUpgradeSpecInputUpgrade {
183
+ { // Upgrade to latest v1beta1.
184
+ Contract : clusterv1 .GroupVersion .Version ,
185
+ PostUpgrade : func (proxy framework.ClusterProxy , namespace , clusterName string ) {
186
+ framework .ValidateCRDMigration (ctx , proxy , namespace , clusterName ,
187
+ crdShouldBeMigrated , clusterctlcluster .FilterClusterObjectsWithNameFilter (clusterName ))
188
+ },
189
+ },
190
+ },
160
191
// InitWithKubernetesVersion should be the highest kubernetes version supported by the init Cluster API version.
161
192
// This is to guarantee that both, the old and new CAPI version, support the defined version.
162
193
// Ensure all Kubernetes versions used here are covered in patch-vsphere-template.yaml
@@ -202,6 +233,15 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.10
202
233
InitWithInfrastructureProviders : []string {fmt .Sprintf (providerVSpherePrefix , capvStableRelease )},
203
234
InitWithRuntimeExtensionProviders : testSpecificSettingsGetter ().RuntimeExtensionProviders ,
204
235
InitWithIPAMProviders : []string {},
236
+ Upgrades : []capi_e2e.ClusterctlUpgradeSpecInputUpgrade {
237
+ { // Upgrade to latest v1beta1.
238
+ Contract : clusterv1 .GroupVersion .Version ,
239
+ PostUpgrade : func (proxy framework.ClusterProxy , namespace , clusterName string ) {
240
+ framework .ValidateCRDMigration (ctx , proxy , namespace , clusterName ,
241
+ crdShouldBeMigrated , clusterctlcluster .FilterClusterObjectsWithNameFilter (clusterName ))
242
+ },
243
+ },
244
+ },
205
245
// InitWithKubernetesVersion should be the highest kubernetes version supported by the init Cluster API version.
206
246
// This is to guarantee that both, the old and new CAPI version, support the defined version.
207
247
// Ensure all Kubernetes versions used here are covered in patch-vsphere-template.yaml
@@ -233,3 +273,8 @@ func kindManagementClusterNewClusterProxyFunc(name string, kubeconfigPath string
233
273
}
234
274
return framework .NewClusterProxy (name , kubeconfigPath , initScheme ())
235
275
}
276
+
277
+ func crdShouldBeMigrated (crd apiextensionsv1.CustomResourceDefinition ) bool {
278
+ return strings .HasSuffix (crd .Name , ".infrastructure.cluster.x-k8s.io" ) && // govmomi & supervisor
279
+ ! strings .HasSuffix (crd .Name , ".vcsim.infrastructure.cluster.x-k8s.io" ) // !vcsim
280
+ }
0 commit comments