Skip to content

Commit e032f0f

Browse files
authored
[CI] : add workflow to test upgrade (#636)
* add workflow to test upgrade * test upgrade * fetch tags as well * run kubeadm-capl-cluster chainsaw test as well * run local-release after checkout * increase assert timeout to fix test failures
1 parent 7fec5c9 commit e032f0f

File tree

3 files changed

+141
-4
lines changed

3 files changed

+141
-4
lines changed
+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Run e2e upgrade test
2+
3+
on:
4+
push:
5+
branches:
6+
- test-upgrade
7+
tags:
8+
- "*"
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
pull-requests: read
14+
actions: read
15+
16+
concurrency:
17+
group: e2e-upgrade-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
changes:
22+
runs-on: ubuntu-latest
23+
outputs:
24+
# Expose matched filters as job 'src' output variable
25+
paths: ${{ steps.filter.outputs.changes }}
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Harden Runner
29+
uses: step-security/harden-runner@v2
30+
with:
31+
disable-sudo: true
32+
egress-policy: block
33+
allowed-endpoints: >
34+
api.github.com:443
35+
github.com:443
36+
- uses: dorny/paths-filter@v3
37+
id: filter
38+
with:
39+
filters: .github/filters.yml
40+
e2e-upgrade-test:
41+
needs: changes
42+
name: e2e-upgrade-test
43+
if: ${{contains(fromJSON(needs.changes.outputs.paths), 'src')}}
44+
runs-on: ubuntu-latest
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.github_token }}
47+
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
48+
steps:
49+
- name: Harden Runner
50+
uses: step-security/harden-runner@v2
51+
with:
52+
disable-sudo: true
53+
egress-policy: audit
54+
allowed-endpoints: >
55+
*:6443
56+
api.linode.com:443
57+
api.github.com:443
58+
github.com:443
59+
gcr.io:443
60+
ghcr.io:443
61+
proxy.golang.org:443
62+
sum.golang.org:443
63+
*.githubusercontent.com:443
64+
docker.io:443
65+
registry-1.docker.io:443
66+
auth.docker.io:443
67+
production.cloudflare.docker.com:443
68+
storage.googleapis.com:443
69+
registry.k8s.io:443
70+
*.pkg.dev:443
71+
*.amazonaws.com:443
72+
*.blob.core.windows.net:443
73+
quay.io:443
74+
*.quay.io:443
75+
api.snapcraft.io:443
76+
cloud.tilt.dev:443
77+
kubernetes-sigs.github.io:443
78+
charts.jetstack.io:443
79+
helm.cilium.io:443
80+
linode.github.io:443
81+
82+
- uses: actions/checkout@v4
83+
with:
84+
fetch-depth: 0
85+
86+
- name: Run Upgrade Test
87+
env:
88+
LINODE_REGION: us-sea
89+
LINODE_CONTROL_PLANE_MACHINE_TYPE: g6-standard-2
90+
LINODE_MACHINE_TYPE: g6-standard-2
91+
CLUSTERCTL_CONFIG: /home/runner/work/cluster-api-provider-linode/cluster-api-provider-linode/e2e/gha-clusterctl-config.yaml
92+
run: make test-upgrade
93+
94+
- name: cleanup stale clusters
95+
if: ${{ always() }}
96+
run: make clean-child-clusters
97+
98+
- name: cleanup kind mgmt cluster
99+
if: ${{ always() }}
100+
run: make clean-kind-cluster

Makefile

+35-2
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,43 @@ test: generate fmt vet envtest ## Run tests.
159159
e2etest: generate local-release local-deploy chainsaw s5cmd
160160
GIT_REF=$(GIT_REF) SSE_KEY=$$(openssl rand -base64 32) LOCALBIN=$(CACHE_BIN) $(CHAINSAW) test ./e2e --selector $(E2E_SELECTOR) $(E2E_FLAGS)
161161

162-
local-deploy: kind ctlptl tilt kustomize clusterctl
163-
$(CTLPTL) apply -f .tilt/ctlptl-config.yaml
162+
.PHONY: local-deploy
163+
local-deploy: kind-cluster tilt kustomize clusterctl
164164
$(TILT) ci -f Tiltfile
165165

166+
.PHONY: kind-cluster
167+
kind-cluster: kind ctlptl
168+
$(CTLPTL) apply -f .tilt/ctlptl-config.yaml
169+
170+
##@ Test Upgrade:
171+
172+
LATEST_REF := $(shell git rev-parse --short HEAD)
173+
LAST_RELEASE := $(shell git describe --abbrev=0 --tags)
174+
COMMON_CLUSTER_REF := $(shell echo "up-$(LATEST_REF)" | cut -c1-8)
175+
COMMON_NAMESPACE := test-upgrade
176+
177+
.PHONY: checkout-latest-commit
178+
checkout-latest-commit:
179+
git checkout $(LATEST_REF)
180+
181+
.PHONY: checkout-last-release
182+
checkout-last-release:
183+
git checkout $(LAST_RELEASE)
184+
185+
.PHONY: last-release-cluster
186+
last-release-cluster: kind ctlptl tilt kustomize clusterctl chainsaw kind-cluster checkout-last-release local-release local-deploy
187+
GIT_REF=$(COMMON_CLUSTER_REF) LOCALBIN=$(CACHE_BIN) CLUSTERCTL_CONFIG=$(CLUSTERCTL_CONFIG) $(CHAINSAW) test --namespace $(COMMON_NAMESPACE) --assert-timeout 600s --skip-delete ./e2e/capl-cluster-flavors/kubeadm-capl-cluster
188+
189+
.PHONY: test-upgrade
190+
test-upgrade: last-release-cluster checkout-latest-commit
191+
$(MAKE) local-release
192+
$(MAKE) local-deploy
193+
GIT_REF=$(COMMON_CLUSTER_REF) LOCALBIN=$(CACHE_BIN) CLUSTERCTL_CONFIG=$(CLUSTERCTL_CONFIG) $(CHAINSAW) test --namespace $(COMMON_NAMESPACE) --assert-timeout 600s ./e2e/capl-cluster-flavors/kubeadm-capl-cluster
194+
195+
.PHONY: clean-kind-cluster
196+
clean-kind-cluster: ctlptl
197+
$(CTLPTL) delete -f .tilt/ctlptl-config.yaml
198+
166199
## --------------------------------------
167200
## Build
168201
## --------------------------------------

e2e/capl-cluster-flavors/kubeadm-capl-cluster/chainsaw-test.yaml

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ spec:
1616
value: (join('-', ['e2e', 'default-cluster', env('GIT_REF')]))
1717
- name: cluster
1818
# Format the cluster name
19-
value: (trim((truncate(($run), `32`)), '-'))
19+
# linode firewall has limit of max 32 chars, so we truncate the cluster name to 29 chars
20+
# for firewall named as <cluster>-nb
21+
value: (trim((truncate(($run), `29`)), '-'))
2022
template: true
2123
steps:
2224
- name: Check if CAPI provider resources exist
@@ -33,10 +35,12 @@ spec:
3335
value: ($namespace)
3436
- name: CLUSTERCTL_CONFIG
3537
value: (env('CLUSTERCTL_CONFIG'))
38+
- name: KUBERNETES_VERSION
39+
value: (env('KUBERNETES_VERSION') || 'v1.29.1')
3640
content: |
3741
set -e
3842
clusterctl generate cluster $CLUSTER -n $NAMESPACE \
39-
--kubernetes-version v1.29.1 \
43+
--kubernetes-version $KUBERNETES_VERSION \
4044
--infrastructure local-linode:v0.0.0 \
4145
--control-plane-machine-count 1 --worker-machine-count 1 \
4246
--config ${CLUSTERCTL_CONFIG:=${HOME}/.cluster-api/clusterctl.yaml} > default-cluster.yaml

0 commit comments

Comments
 (0)