Skip to content

Commit

Permalink
add v1alpha4 -> v1beta1 upgrade test
Browse files Browse the repository at this point in the history
  • Loading branch information
shysank committed Nov 15, 2021
1 parent 91d283a commit 73c13e6
Show file tree
Hide file tree
Showing 5 changed files with 2,825 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test/e2e/capi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
e2e_namespace "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/namespace"
clusterctl "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
"sigs.k8s.io/cluster-api/test/framework"
"sigs.k8s.io/cluster-api/util"
)

Expand Down Expand Up @@ -257,5 +258,54 @@ var _ = Describe("Running the Cluster API E2E tests", func() {
}
})
})

Context("upgrade from v1alpha4 to v1beta1, and scale workload clusters created in v1alpha4", func() {
BeforeEach(func() {
// Unset resource group and vnet env variables, since we capi test creates 2 clusters,
// and will result in both the clusters using the same vnet and resource group.
Expect(os.Unsetenv(AzureResourceGroup)).To(Succeed())
Expect(os.Unsetenv(AzureVNetName)).To(Succeed())

// Unset windows specific variables
Expect(os.Unsetenv("WINDOWS_WORKER_MACHINE_COUNT")).To(Succeed())
Expect(os.Unsetenv("K8S_FEATURE_GATES")).To(Succeed())
})
capi_e2e.ClusterctlUpgradeSpec(ctx, func() capi_e2e.ClusterctlUpgradeSpecInput {
return capi_e2e.ClusterctlUpgradeSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
InitWithProvidersContract: "v1alpha4",
InitWithBinary: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.4/clusterctl-{OS}-{ARCH}",
PreInit: getPreInitFunc(ctx),
}
})
})
}
})

func getPreInitFunc(ctx context.Context) func(proxy framework.ClusterProxy) {
return func(clusterProxy framework.ClusterProxy) {
spClientSecret := os.Getenv(AzureClientSecret)
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: IdentitySecretName,
Namespace: "default",
Labels: map[string]string{
clusterctl.ClusterctlMoveHierarchyLabelName: "true",
},
},
Type: corev1.SecretTypeOpaque,
Data: map[string][]byte{"clientSecret": []byte(spClientSecret)},
}
err := clusterProxy.GetClient().Create(ctx, secret)
Expect(err).ToNot(HaveOccurred())

identityName := e2eConfig.GetVariable(ClusterIdentityName)
Expect(os.Setenv(ClusterIdentityName, identityName)).NotTo(HaveOccurred())
Expect(os.Setenv(ClusterIdentitySecretName, IdentitySecretName)).NotTo(HaveOccurred())
Expect(os.Setenv(ClusterIdentitySecretNamespace, "default")).NotTo(HaveOccurred())
}
}
38 changes: 38 additions & 0 deletions test/e2e/config/azure-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ providers:
replacements:
- old: "imagePullPolicy: Always"
new: "imagePullPolicy: IfNotPresent"
- name: v0.4.4 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.4/core-components.yaml"
type: "url"
contract: v1alpha4
replacements:
- old: --metrics-addr=127.0.0.1:8080
new: --metrics-addr=:8080
files:
- sourcePath: "../data/shared/v1alpha4/metadata.yaml"
- name: v1.0.0
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.0/core-components.yaml
type: url
Expand All @@ -39,6 +48,15 @@ providers:
replacements:
- old: "imagePullPolicy: Always"
new: "imagePullPolicy: IfNotPresent"
- name: v0.4.4 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.4/bootstrap-components.yaml"
type: "url"
contract: v1alpha4
replacements:
- old: --metrics-addr=127.0.0.1:8080
new: --metrics-addr=:8080
files:
- sourcePath: "../data/shared/v1alpha4/metadata.yaml"
- name: v1.0.0
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.0/bootstrap-components.yaml
type: url
Expand All @@ -60,6 +78,15 @@ providers:
replacements:
- old: "imagePullPolicy: Always"
new: "imagePullPolicy: IfNotPresent"
- name: v0.4.4 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.4/control-plane-components.yaml"
type: "url"
contract: v1alpha4
replacements:
- old: --metrics-addr=127.0.0.1:8080
new: --metrics-addr=:8080
files:
- sourcePath: "../data/shared/v1alpha4/metadata.yaml"
- name: v1.0.0
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.0/control-plane-components.yaml
type: url
Expand All @@ -83,6 +110,17 @@ providers:
replacements:
- old: "imagePullPolicy: Always"
new: "imagePullPolicy: IfNotPresent"
- name: v0.5.3 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
value: https://github.com/kubernetes-sigs/cluster-api-provider-azure/releases/download/v0.5.3/infrastructure-components.yaml
type: url
contract: v1alpha4
files:
- sourcePath: "../data/shared/v1alpha4_provider/metadata.yaml"
- sourcePath: "../data/infrastructure-azure/v1alpha4/cluster-template-prow.yaml"
targetName: "cluster-template.yaml"
replacements:
- old: "imagePullPolicy: Always"
new: "imagePullPolicy: IfNotPresent"
- name: v1.0.99 # next; use manifest from source files
value: "${PWD}/config/default"
files:
Expand Down
Loading

0 comments on commit 73c13e6

Please sign in to comment.