Skip to content

Commit 20b3818

Browse files
shysankk8s-infra-cherrypick-robot
authored andcommitted
add v1alpha4 -> v1beta1 upgrade test
1 parent 569a4c3 commit 20b3818

File tree

5 files changed

+2825
-0
lines changed

5 files changed

+2825
-0
lines changed

test/e2e/capi_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
e2e_namespace "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/namespace"
3131
clusterctl "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
3232
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
33+
"sigs.k8s.io/cluster-api/test/framework"
3334
"sigs.k8s.io/cluster-api/util"
3435
)
3536

@@ -257,5 +258,54 @@ var _ = Describe("Running the Cluster API E2E tests", func() {
257258
}
258259
})
259260
})
261+
262+
Context("upgrade from v1alpha4 to v1beta1, and scale workload clusters created in v1alpha4", func() {
263+
BeforeEach(func() {
264+
// Unset resource group and vnet env variables, since we capi test creates 2 clusters,
265+
// and will result in both the clusters using the same vnet and resource group.
266+
Expect(os.Unsetenv(AzureResourceGroup)).To(Succeed())
267+
Expect(os.Unsetenv(AzureVNetName)).To(Succeed())
268+
269+
// Unset windows specific variables
270+
Expect(os.Unsetenv("WINDOWS_WORKER_MACHINE_COUNT")).To(Succeed())
271+
Expect(os.Unsetenv("K8S_FEATURE_GATES")).To(Succeed())
272+
})
273+
capi_e2e.ClusterctlUpgradeSpec(ctx, func() capi_e2e.ClusterctlUpgradeSpecInput {
274+
return capi_e2e.ClusterctlUpgradeSpecInput{
275+
E2EConfig: e2eConfig,
276+
ClusterctlConfigPath: clusterctlConfigPath,
277+
BootstrapClusterProxy: bootstrapClusterProxy,
278+
ArtifactFolder: artifactFolder,
279+
SkipCleanup: skipCleanup,
280+
InitWithProvidersContract: "v1alpha4",
281+
InitWithBinary: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.4/clusterctl-{OS}-{ARCH}",
282+
PreInit: getPreInitFunc(ctx),
283+
}
284+
})
285+
})
260286
}
261287
})
288+
289+
func getPreInitFunc(ctx context.Context) func(proxy framework.ClusterProxy) {
290+
return func(clusterProxy framework.ClusterProxy) {
291+
spClientSecret := os.Getenv(AzureClientSecret)
292+
secret := &corev1.Secret{
293+
ObjectMeta: metav1.ObjectMeta{
294+
Name: IdentitySecretName,
295+
Namespace: "default",
296+
Labels: map[string]string{
297+
clusterctl.ClusterctlMoveHierarchyLabelName: "true",
298+
},
299+
},
300+
Type: corev1.SecretTypeOpaque,
301+
Data: map[string][]byte{"clientSecret": []byte(spClientSecret)},
302+
}
303+
err := clusterProxy.GetClient().Create(ctx, secret)
304+
Expect(err).ToNot(HaveOccurred())
305+
306+
identityName := e2eConfig.GetVariable(ClusterIdentityName)
307+
Expect(os.Setenv(ClusterIdentityName, identityName)).NotTo(HaveOccurred())
308+
Expect(os.Setenv(ClusterIdentitySecretName, IdentitySecretName)).NotTo(HaveOccurred())
309+
Expect(os.Setenv(ClusterIdentitySecretNamespace, "default")).NotTo(HaveOccurred())
310+
}
311+
}

test/e2e/config/azure-dev.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ providers:
1717
replacements:
1818
- old: "imagePullPolicy: Always"
1919
new: "imagePullPolicy: IfNotPresent"
20+
- name: v0.4.4 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
21+
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.4/core-components.yaml"
22+
type: "url"
23+
contract: v1alpha4
24+
replacements:
25+
- old: --metrics-addr=127.0.0.1:8080
26+
new: --metrics-addr=:8080
27+
files:
28+
- sourcePath: "../data/shared/v1alpha4/metadata.yaml"
2029
- name: v1.0.0
2130
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.0/core-components.yaml
2231
type: url
@@ -39,6 +48,15 @@ providers:
3948
replacements:
4049
- old: "imagePullPolicy: Always"
4150
new: "imagePullPolicy: IfNotPresent"
51+
- name: v0.4.4 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
52+
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.4/bootstrap-components.yaml"
53+
type: "url"
54+
contract: v1alpha4
55+
replacements:
56+
- old: --metrics-addr=127.0.0.1:8080
57+
new: --metrics-addr=:8080
58+
files:
59+
- sourcePath: "../data/shared/v1alpha4/metadata.yaml"
4260
- name: v1.0.0
4361
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.0/bootstrap-components.yaml
4462
type: url
@@ -60,6 +78,15 @@ providers:
6078
replacements:
6179
- old: "imagePullPolicy: Always"
6280
new: "imagePullPolicy: IfNotPresent"
81+
- name: v0.4.4 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
82+
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.4/control-plane-components.yaml"
83+
type: "url"
84+
contract: v1alpha4
85+
replacements:
86+
- old: --metrics-addr=127.0.0.1:8080
87+
new: --metrics-addr=:8080
88+
files:
89+
- sourcePath: "../data/shared/v1alpha4/metadata.yaml"
6390
- name: v1.0.0
6491
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.0/control-plane-components.yaml
6592
type: url
@@ -83,6 +110,17 @@ providers:
83110
replacements:
84111
- old: "imagePullPolicy: Always"
85112
new: "imagePullPolicy: IfNotPresent"
113+
- name: v0.5.3 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
114+
value: https://github.com/kubernetes-sigs/cluster-api-provider-azure/releases/download/v0.5.3/infrastructure-components.yaml
115+
type: url
116+
contract: v1alpha4
117+
files:
118+
- sourcePath: "../data/shared/v1alpha4_provider/metadata.yaml"
119+
- sourcePath: "../data/infrastructure-azure/v1alpha4/cluster-template-prow.yaml"
120+
targetName: "cluster-template.yaml"
121+
replacements:
122+
- old: "imagePullPolicy: Always"
123+
new: "imagePullPolicy: IfNotPresent"
86124
- name: v1.0.99 # next; use manifest from source files
87125
value: "${PWD}/config/default"
88126
files:

0 commit comments

Comments
 (0)