Skip to content

Commit

Permalink
Merge pull request #1810 from shysank/v1alpha4_v1beta1_upgrade_test
Browse files Browse the repository at this point in the history
v1alpha4 -> v1beta1 clusterctl upgrade test
  • Loading branch information
k8s-ci-robot authored Nov 18, 2021
2 parents 894e80e + ee7a6ed commit 5cb4494
Show file tree
Hide file tree
Showing 8 changed files with 2,862 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test/e2e/logs/*
_artifacts

# E2E test templates
test/e2e/data/infrastructure-azure/v1alpha4/cluster-template*.yaml
test/e2e/data/infrastructure-azure/v1beta1/cluster-template*.yaml

# boilerplate_test output
hack/boilerplate/__pycache__
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ require (
k8s.io/klog/v2 v2.9.0
k8s.io/kubectl v0.22.2
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b
sigs.k8s.io/cluster-api v1.0.0
sigs.k8s.io/cluster-api/test v1.0.0
sigs.k8s.io/controller-runtime v0.10.2
sigs.k8s.io/cluster-api v1.0.1
sigs.k8s.io/cluster-api/test v1.0.1
sigs.k8s.io/controller-runtime v0.10.3
sigs.k8s.io/kind v0.11.1
sigs.k8s.io/yaml v1.3.0
)

replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.0.0
replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.0.1
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1619,12 +1619,12 @@ rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.14/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.22/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
sigs.k8s.io/cluster-api v1.0.0 h1:GcVA2ObQTXo/+jzSLWPy4Bd3NeiwJyAB8n19kyJIotA=
sigs.k8s.io/cluster-api v1.0.0/go.mod h1:V230kMSaYENTUcx1QRkoRCklb3vfphQGV3/z4ODNGWo=
sigs.k8s.io/cluster-api/test v1.0.0 h1:PeWOLXtDGYMmzXwGX+NtH7Xxx6BtS83DT7vKzITY5X0=
sigs.k8s.io/cluster-api/test v1.0.0/go.mod h1:8WQozDv62x2qHkCB1wTUeFjuwawuHKUTh8IMH5hePQs=
sigs.k8s.io/controller-runtime v0.10.2 h1:jW8qiY+yMnnPx6O9hu63tgcwaKzd1yLYui+mpvClOOc=
sigs.k8s.io/controller-runtime v0.10.2/go.mod h1:CQp8eyUQZ/Q7PJvnIrB6/hgfTC1kBkGylwsLgOQi1WY=
sigs.k8s.io/cluster-api v1.0.1 h1:0YXQoemI4WnZF8RzT9T2vCtnXAi22rD4Fx1Tj2hhCEM=
sigs.k8s.io/cluster-api v1.0.1/go.mod h1:/LkJXtsvhxTV4U0z1Y2Y1Gr2xebJ0/ce09Ab2M0XU/U=
sigs.k8s.io/cluster-api/test v1.0.1 h1:bqyRhJ/Nc2Go+A7tl15QkCfNVyNOEPsTgJgZOiUwoJs=
sigs.k8s.io/cluster-api/test v1.0.1/go.mod h1:D8eLfLrzKcPbm/TzYexoRJISaDleOGSpBrBvH0yVEuA=
sigs.k8s.io/controller-runtime v0.10.3 h1:s5Ttmw/B4AuIbwrXD3sfBkXwnPMMWrqpVj4WRt1dano=
sigs.k8s.io/controller-runtime v0.10.3/go.mod h1:CQp8eyUQZ/Q7PJvnIrB6/hgfTC1kBkGylwsLgOQi1WY=
sigs.k8s.io/kind v0.11.1 h1:pVzOkhUwMBrCB0Q/WllQDO3v14Y+o2V0tFgjTqIUjwA=
sigs.k8s.io/kind v0.11.1/go.mod h1:fRpgVhtqAWrtLB9ED7zQahUimpUXuG/iHT88xYqEGIA=
sigs.k8s.io/kustomize/api v0.8.11/go.mod h1:a77Ls36JdfCWojpUqR6m60pdGY1AYFix4AH83nJtY1g=
Expand Down
100 changes: 76 additions & 24 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 @@ -230,32 +231,83 @@ var _ = Describe("Running the Cluster API E2E tests", func() {
})

if os.Getenv("LOCAL_ONLY") != "true" {
Context("upgrade from v1alpha3 to v1beta1, and scale workload clusters created in v1alpha3", 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())

// Set base64 encoded values for v1alpha3 cluster.
Expect(os.Setenv("AZURE_CLIENT_ID_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv(AzureClientId))))).To(Succeed())
Expect(os.Setenv("AZURE_CLIENT_SECRET_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv(AzureClientSecret))))).To(Succeed())
Expect(os.Setenv("AZURE_SUBSCRIPTION_ID_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv("AZURE_SUBSCRIPTION_ID"))))).To(Succeed())
Expect(os.Setenv("AZURE_TENANT_ID_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv("AZURE_TENANT_ID"))))).To(Succeed())

// Unset windows specific variables
Expect(os.Unsetenv("WINDOWS_WORKER_MACHINE_COUNT")).To(Succeed())
Expect(os.Unsetenv("K8S_FEATURE_GATES")).To(Succeed())
Context("API Version Upgrade", func() {
Context("upgrade from v1alpha3 to v1beta1, and scale workload clusters created in v1alpha3 ", 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())

// Set base64 encoded values for v1alpha3 cluster.
Expect(os.Setenv("AZURE_CLIENT_ID_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv(AzureClientId))))).To(Succeed())
Expect(os.Setenv("AZURE_CLIENT_SECRET_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv(AzureClientSecret))))).To(Succeed())
Expect(os.Setenv("AZURE_SUBSCRIPTION_ID_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv("AZURE_SUBSCRIPTION_ID"))))).To(Succeed())
Expect(os.Setenv("AZURE_TENANT_ID_B64", base64.StdEncoding.EncodeToString([]byte(os.Getenv("AZURE_TENANT_ID"))))).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,
}
})
})
capi_e2e.ClusterctlUpgradeSpec(ctx, func() capi_e2e.ClusterctlUpgradeSpecInput {
return capi_e2e.ClusterctlUpgradeSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
}

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 5cb4494

Please sign in to comment.