Skip to content

Commit f3ecc73

Browse files
authored
Merge pull request #1423 from CecileRobertMichon/capi-test-templates
Refactor infrastructure-azure templates required by CAPI tests to match CAPD
2 parents 99748d4 + e834444 commit f3ecc73

File tree

29 files changed

+548
-910
lines changed

29 files changed

+548
-910
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ test/e2e/config/azure-dev-envsubst.yaml
6262
test/e2e/logs/*
6363
_artifacts
6464

65+
# E2E test templates
66+
test/e2e/data/infrastructure-azure/v1alpha4/cluster-template*.yaml
67+
6568
# boilerplate_test output
6669
hack/boilerplate/__pycache__
6770
hack/boilerplate/*.pyc

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ E2E_DATA_DIR ?= $(ROOT_DIR)/test/e2e/data
5050
KUBETEST_CONF_PATH ?= $(abspath $(E2E_DATA_DIR)/kubetest/conformance.yaml)
5151
KUBETEST_WINDOWS_CONF_PATH ?= $(abspath $(E2E_DATA_DIR)/kubetest/upstream-windows.yaml)
5252
KUBETEST_REPO_LIST_PATH ?= $(abspath $(E2E_DATA_DIR)/kubetest/repo-list.yaml)
53+
AZURE_TEMPLATES := $(E2E_DATA_DIR)/infrastructure-azure
5354

5455
# set --output-base used for conversion-gen which needs to be different for in GOPATH and outside GOPATH dev
5556
ifneq ($(abspath $(ROOT_DIR)),$(GOPATH)/src/sigs.k8s.io/cluster-api-provider-azure)
@@ -168,7 +169,7 @@ test-cover: envs-test $(KUBECTL) $(KUBE_APISERVER) $(ETCD) ## Run tests with cod
168169
go tool cover -html=coverage.out -o coverage.html
169170

170171
.PHONY: test-e2e-run
171-
test-e2e-run: $(ENVSUBST) $(KUBECTL) $(GINKGO) ## Run e2e tests
172+
test-e2e-run: generate-e2e-templates $(ENVSUBST) $(KUBECTL) $(GINKGO) ## Run e2e tests
172173
$(ENVSUBST) < $(E2E_CONF_FILE) > $(E2E_CONF_FILE_ENVSUBST) && \
173174
$(GINKGO) -v -trace -tags=e2e -focus="$(GINKGO_FOCUS)" -skip="$(GINKGO_SKIP)" -nodes=$(GINKGO_NODES) --noColor=$(GINKGO_NOCOLOR) $(GINKGO_ARGS) ./test/e2e -- \
174175
-e2e.artifacts-folder="$(ARTIFACTS)" \
@@ -289,6 +290,7 @@ generate: ## Generate code
289290
$(MAKE) generate-go
290291
$(MAKE) generate-manifests
291292
$(MAKE) generate-flavors
293+
$(MAKE) generate-e2e-templates
292294

293295
.PHONY: generate-go
294296
generate-go: $(CONTROLLER_GEN) $(MOCKGEN) $(CONVERSION_GEN) ## Runs Go related generate targets
@@ -328,6 +330,19 @@ generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
328330
generate-flavors: $(KUSTOMIZE)
329331
./hack/gen-flavors.sh
330332

333+
.PHONY: generate-e2e-templates ## Generate Azure infrastructure templates for the v1alpha4 CAPI test suite.
334+
generate-e2e-templates: $(KUSTOMIZE)
335+
$(KUSTOMIZE) build $(AZURE_TEMPLATES)/v1alpha4/cluster-template --load-restrictor LoadRestrictionsNone > $(AZURE_TEMPLATES)/v1alpha4/cluster-template.yaml
336+
$(KUSTOMIZE) build $(AZURE_TEMPLATES)/v1alpha4/cluster-template-md-remediation --load-restrictor LoadRestrictionsNone > $(AZURE_TEMPLATES)/v1alpha4/cluster-template-md-remediation.yaml
337+
$(KUSTOMIZE) build $(AZURE_TEMPLATES)/v1alpha4/cluster-template-kcp-remediation --load-restrictor LoadRestrictionsNone > $(AZURE_TEMPLATES)/v1alpha4/cluster-template-kcp-remediation.yaml
338+
$(KUSTOMIZE) build $(AZURE_TEMPLATES)/v1alpha4/cluster-template-kcp-adoption/step1 --load-restrictor LoadRestrictionsNone > $(AZURE_TEMPLATES)/v1alpha4/cluster-template-kcp-adoption.yaml
339+
echo "---" >> $(AZURE_TEMPLATES)/v1alpha4/cluster-template-kcp-adoption.yaml
340+
$(KUSTOMIZE) build $(AZURE_TEMPLATES)/v1alpha4/cluster-template-kcp-adoption/step2 --load-restrictor LoadRestrictionsNone >> $(AZURE_TEMPLATES)/v1alpha4/cluster-template-kcp-adoption.yaml
341+
$(KUSTOMIZE) build $(AZURE_TEMPLATES)/v1alpha4/cluster-template-machine-pool --load-restrictor LoadRestrictionsNone > $(AZURE_TEMPLATES)/v1alpha4/cluster-template-machine-pool.yaml
342+
$(KUSTOMIZE) build $(AZURE_TEMPLATES)/v1alpha4/cluster-template-node-drain --load-restrictor LoadRestrictionsNone > $(AZURE_TEMPLATES)/v1alpha4/cluster-template-node-drain.yaml
343+
$(KUSTOMIZE) build $(AZURE_TEMPLATES)/v1alpha4/cluster-template-upgrades --load-restrictor LoadRestrictionsNone > $(AZURE_TEMPLATES)/v1alpha4/cluster-template-upgrades.yaml
344+
$(KUSTOMIZE) build $(AZURE_TEMPLATES)/v1alpha4/cluster-template-kcp-scale-in --load-restrictor LoadRestrictionsNone > $(AZURE_TEMPLATES)/v1alpha4/cluster-template-kcp-scale-in.yaml
345+
331346
## --------------------------------------
332347
## Docker
333348
## --------------------------------------

test/e2e/azure_logcollector.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ func linuxLogs(execToPathFn func(outputFileName string, command string, args ...
231231
"cloud-init-output.log",
232232
"cat", "/var/log/cloud-init-output.log",
233233
),
234+
execToPathFn(
235+
"sentinel-file-dir.txt",
236+
"ls", "/run/cluster-api/",
237+
),
234238
}
235239
}
236240

test/e2e/capi_test.go

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
. "github.com/onsi/gomega"
2828

2929
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
30-
"sigs.k8s.io/cluster-api/test/framework"
3130
"sigs.k8s.io/cluster-api/util"
3231
)
3332

@@ -83,6 +82,20 @@ var _ = Describe("Running the Cluster API E2E tests", func() {
8382
})
8483
})
8584

85+
Context("Running the KCP upgrade spec in a HA cluster using scale in rollout", func() {
86+
capi_e2e.KCPUpgradeSpec(context.TODO(), func() capi_e2e.KCPUpgradeSpecInput {
87+
return capi_e2e.KCPUpgradeSpecInput{
88+
E2EConfig: e2eConfig,
89+
ClusterctlConfigPath: clusterctlConfigPath,
90+
BootstrapClusterProxy: bootstrapClusterProxy,
91+
ArtifactFolder: artifactFolder,
92+
ControlPlaneMachineCount: 3,
93+
SkipCleanup: skipCleanup,
94+
Flavor: "kcp-scale-in",
95+
}
96+
})
97+
})
98+
8699
Context("Running the MachineDeployment upgrade spec", func() {
87100
capi_e2e.MachineDeploymentUpgradesSpec(context.TODO(), func() capi_e2e.MachineDeploymentUpgradesSpecInput {
88101
return capi_e2e.MachineDeploymentUpgradesSpecInput{
@@ -126,7 +139,7 @@ var _ = Describe("Running the Cluster API E2E tests", func() {
126139
return capi_e2e.KCPAdoptionSpecInput{
127140
E2EConfig: e2eConfig,
128141
ClusterctlConfigPath: clusterctlConfigPath,
129-
BootstrapClusterProxy: bootstrapClusterProxy.(framework.ClusterProxy),
142+
BootstrapClusterProxy: bootstrapClusterProxy,
130143
ArtifactFolder: artifactFolder,
131144
SkipCleanup: skipCleanup,
132145
}
@@ -138,10 +151,35 @@ var _ = Describe("Running the Cluster API E2E tests", func() {
138151
return capi_e2e.MachinePoolInput{
139152
E2EConfig: e2eConfig,
140153
ClusterctlConfigPath: clusterctlConfigPath,
141-
BootstrapClusterProxy: bootstrapClusterProxy.(framework.ClusterProxy),
154+
BootstrapClusterProxy: bootstrapClusterProxy,
155+
ArtifactFolder: artifactFolder,
156+
SkipCleanup: skipCleanup,
157+
}
158+
})
159+
})
160+
161+
Context("Should successfully scale out and scale in a MachineDeployment", func() {
162+
capi_e2e.MachineDeploymentScaleSpec(context.TODO(), func() capi_e2e.MachineDeploymentScaleSpecInput {
163+
return capi_e2e.MachineDeploymentScaleSpecInput{
164+
E2EConfig: e2eConfig,
165+
ClusterctlConfigPath: clusterctlConfigPath,
166+
BootstrapClusterProxy: bootstrapClusterProxy,
142167
ArtifactFolder: artifactFolder,
143168
SkipCleanup: skipCleanup,
144169
}
145170
})
146171
})
172+
173+
// TODO: enable this with a longer timeout once https://github.com/kubernetes-sigs/cluster-api/pull/4830 is imported.
174+
//Context("Should successfully set and use node drain timeout", func() {
175+
// capi_e2e.NodeDrainTimeoutSpec(context.TODO(), func() capi_e2e.NodeDrainTimeoutSpecInput {
176+
// return capi_e2e.NodeDrainTimeoutSpecInput{
177+
// E2EConfig: e2eConfig,
178+
// ClusterctlConfigPath: clusterctlConfigPath,
179+
// BootstrapClusterProxy: bootstrapClusterProxy,
180+
// ArtifactFolder: artifactFolder,
181+
// SkipCleanup: skipCleanup,
182+
// }
183+
// })
184+
//})
147185
})

test/e2e/config/azure-dev.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,18 @@ providers:
5858
- sourcePath: "../data/shared/v1alpha4/metadata.yaml"
5959
- sourcePath: "${PWD}/templates/test/ci/cluster-template-prow.yaml"
6060
targetName: "cluster-template.yaml"
61-
- sourcePath: "../data/infrastructure-azure/cluster-template-kcp-adoption.yaml"
61+
- sourcePath: "../data/infrastructure-azure/v1alpha4/cluster-template-kcp-adoption.yaml"
6262
targetName: "cluster-template-kcp-adoption.yaml"
6363
- sourcePath: "${PWD}/templates/test/ci/cluster-template-prow-ipv6.yaml"
6464
targetName: "cluster-template-ipv6.yaml"
65-
- sourcePath: "../data/infrastructure-azure/cluster-template-md-remediation.yaml"
65+
- sourcePath: "../data/infrastructure-azure/v1alpha4/cluster-template-md-remediation.yaml"
6666
targetName: "cluster-template-md-remediation.yaml"
67-
- sourcePath: "../data/infrastructure-azure/cluster-template-kcp-remediation.yaml"
67+
- sourcePath: "../data/infrastructure-azure/v1alpha4/cluster-template-kcp-remediation.yaml"
6868
targetName: "cluster-template-kcp-remediation.yaml"
69-
- sourcePath: "../data/infrastructure-azure/cluster-template-kcp-scale-in.yaml"
69+
- sourcePath: "../data/infrastructure-azure/v1alpha4/cluster-template-kcp-scale-in.yaml"
7070
targetName: "cluster-template-kcp-scale-in.yaml"
71+
- sourcePath: "../data/infrastructure-azure/v1alpha4/cluster-template-node-drain.yaml"
72+
targetName: "cluster-template-node-drain.yaml"
7173
- sourcePath: "${PWD}/templates/test/ci/cluster-template-prow-machine-pool.yaml"
7274
targetName: "cluster-template-machine-pool.yaml"
7375
- sourcePath: "${PWD}/templates/test/ci/cluster-template-prow-nvidia-gpu.yaml"
@@ -108,6 +110,7 @@ variables:
108110
CONFORMANCE_NODES: "${CONFORMANCE_NODES:-1}"
109111
IP_FAMILY: "IPv4" # this is used by the CAPI quickstart spec
110112
MULTI_TENANCY_IDENTITY_NAME: "multi-tenancy-identity"
113+
NODE_DRAIN_TIMEOUT: "60s"
111114

112115
intervals:
113116
default/wait-controllers: ["3m", "10s"]
@@ -118,6 +121,7 @@ intervals:
118121
default/wait-machine-upgrade: ["60m", "10s"]
119122
default/wait-machine-remediation: ["30m", "10s"]
120123
default/wait-deployment: ["15m", "10s"]
124+
default/wait-deployment-available: ["15m", "10s"]
121125
default/wait-job: ["5m", "10s"]
122126
default/wait-service: ["5m", "10s"]
123127
default/wait-machine-pool-nodes: ["30m", "10s"]

0 commit comments

Comments
 (0)