Skip to content

Commit ef60cd0

Browse files
committed
Add clusterctl upgrade tests
These tests make use of the CAPI e2e framework. The test spec creates a secondary management cluster with older versions of the controllers. A workload cluster is created to test the functionality of the old controllers before they are upgraded. Then clusterctl upgrade is used to upgrade them and the workload cluster is scaled to check that things are working also after the upgrade.
1 parent c9cca1d commit ef60cd0

File tree

6 files changed

+90
-3
lines changed

6 files changed

+90
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,6 @@ sshuttle.pid
173173

174174
# Book
175175
docs/book/book/
176+
177+
# venv
178+
.venv

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ LDFLAGS := $(shell source ./hack/version.sh; version::ldflags)
120120
## --------------------------------------
121121

122122
# The number of ginkgo tests to run concurrently
123-
E2E_GINKGO_PARALLEL=2
123+
E2E_GINKGO_PARALLEL ?= 2
124124

125125
E2E_ARGS ?=
126126

@@ -143,6 +143,7 @@ E2E_KUSTOMIZE_DIR=test/e2e/data/kustomize
143143
.PHONY: e2e-templates
144144
e2e-templates: ## Generate cluster templates for e2e tests
145145
e2e-templates: $(addprefix $(E2E_TEMPLATES_DIR)/, \
146+
cluster-template-v1alpha5.yaml \
146147
cluster-template-external-cloud-provider.yaml \
147148
cluster-template-multi-az.yaml \
148149
cluster-template-multi-network.yaml \

test/e2e/data/e2e_conf.yaml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ providers:
3535
- name: v1.2.4
3636
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.4/core-components.yaml"
3737
type: url
38+
contract: v1beta1
3839
files:
3940
- sourcePath: "../data/shared/v1beta1/metadata.yaml"
4041
replacements:
@@ -48,6 +49,7 @@ providers:
4849
- name: v1.2.4
4950
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.4/bootstrap-components.yaml"
5051
type: url
52+
contract: v1beta1
5153
files:
5254
- sourcePath: "../data/shared/v1beta1/metadata.yaml"
5355
replacements:
@@ -61,6 +63,7 @@ providers:
6163
- name: v1.2.4
6264
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.4/control-plane-components.yaml"
6365
type: url
66+
contract: v1beta1
6467
files:
6568
- sourcePath: "../data/shared/v1beta1/metadata.yaml"
6669
replacements:
@@ -71,17 +74,36 @@ providers:
7174
- name: openstack
7275
type: InfrastructureProvider
7376
versions:
77+
# This is only for clusterctl upgrade tests
78+
- name: v0.6.3
79+
value: "https://github.com/kubernetes-sigs/cluster-api-provider-openstack/releases/download/v0.6.3/infrastructure-components.yaml"
80+
type: url
81+
contract: v1beta1
82+
files:
83+
- sourcePath: "../data/shared/v1beta1_provider/metadata.yaml"
84+
- sourcePath: "./infrastructure-openstack/cluster-template.yaml"
85+
replacements:
86+
- old: "imagePullPolicy: Always"
87+
new: "imagePullPolicy: IfNotPresent"
88+
- old: "--v=2"
89+
new: "--v=4"
90+
- old: "--leader-elect"
91+
new: "--leader-elect=false\n - --sync-period=1m"
7492
- name: v0.6.99
7593
value: ../../../config/default
76-
contract: v1beta1
94+
# This is the upcoming version.
95+
# Specify no contract so that upgrade tests that start from a specific contract won't pick it up.
96+
# contract: v1beta1
7797
files:
7898
- sourcePath: "../data/shared/v1beta1_provider/metadata.yaml"
7999
- sourcePath: "./infrastructure-openstack/cluster-template.yaml"
80100
- sourcePath: "./infrastructure-openstack/cluster-template-external-cloud-provider.yaml"
81101
- sourcePath: "./infrastructure-openstack/cluster-template-without-lb.yaml"
82102
replacements:
103+
# TODO: We should use e2e here instead of main, but we need a way to get it into the workload cluster
104+
# for upgrade tests for that to work.
83105
- old: gcr.io/k8s-staging-capi-openstack/capi-openstack-controller:dev
84-
new: gcr.io/k8s-staging-capi-openstack/capi-openstack-controller:e2e
106+
new: gcr.io/k8s-staging-capi-openstack/capi-openstack-controller:main
85107
- old: "imagePullPolicy: Always"
86108
new: "imagePullPolicy: IfNotPresent"
87109
- old: "--v=2"
@@ -116,6 +138,7 @@ variables:
116138
OPENSTACK_VOLUME_TYPE_ALT: "test-volume-type"
117139
CONFORMANCE_WORKER_MACHINE_COUNT: "5"
118140
CONFORMANCE_CONTROL_PLANE_MACHINE_COUNT: "1"
141+
INIT_WITH_KUBERNETES_VERSION: "v1.25.0"
119142

120143
intervals:
121144
conformance/wait-control-plane: ["30m", "10s"]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
resources:
3+
- ../../../../../kustomize/v1alpha5/default
4+
5+
components:
6+
- ../common-patches

test/e2e/shared/defaults.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const (
4848
FlavorExternalCloudProvider = "external-cloud-provider-ci-artifacts"
4949
FlavorMultiNetwork = "multi-network-ci-artifacts"
5050
FlavorMultiAZ = "multi-az-ci-artifacts"
51+
FlavorV1alpha5 = "v1alpha5-ci-artifacts"
5152
)
5253

5354
// DefaultScheme returns the default scheme to use for testing.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//go:build e2e
2+
// +build e2e
3+
4+
/*
5+
Copyright 2021 The Kubernetes Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
*/
19+
20+
package e2e
21+
22+
import (
23+
"context"
24+
25+
. "github.com/onsi/ginkgo"
26+
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
27+
28+
"sigs.k8s.io/cluster-api-provider-openstack/test/e2e/shared"
29+
)
30+
31+
// Note: There isn't really anything fixing this to the v0.6 release. The test will
32+
// simply pick the latest release with the correct contract from the E2EConfig, as seen here
33+
// https://github.com/kubernetes-sigs/cluster-api/blob/3abb9089485f51d46054096c17ccb8b59f0f7331/test/e2e/clusterctl_upgrade.go#L265
34+
// When new minor releases are added (with the same contract) we will need to work on this
35+
// if we want to continue testing v0.6.
36+
var _ = Describe("When testing clusterctl upgrades (v0.6=>current) [clusterctl-upgrade]", func() {
37+
ctx := context.TODO()
38+
shared.SetEnvVar("USE_CI_ARTIFACTS", "true", false)
39+
40+
capi_e2e.ClusterctlUpgradeSpec(ctx, func() capi_e2e.ClusterctlUpgradeSpecInput {
41+
return capi_e2e.ClusterctlUpgradeSpecInput{
42+
E2EConfig: e2eCtx.E2EConfig,
43+
ClusterctlConfigPath: e2eCtx.Environment.ClusterctlConfigPath,
44+
BootstrapClusterProxy: e2eCtx.Environment.BootstrapClusterProxy,
45+
ArtifactFolder: e2eCtx.Settings.ArtifactFolder,
46+
SkipCleanup: false,
47+
InitWithBinary: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.4/clusterctl-{OS}-{ARCH}",
48+
InitWithProvidersContract: "v1beta1",
49+
MgmtFlavor: shared.FlavorDefault,
50+
WorkloadFlavor: shared.FlavorV1alpha5,
51+
}
52+
})
53+
})

0 commit comments

Comments
 (0)