Skip to content

Commit 199a89a

Browse files
mcbenjemaawikkyk
andauthored
Add e2e tests (#48)
End-to-end tests. Can run automatically in an environment from a github action. --------- Co-authored-by: Vic Kerr <[email protected]>
1 parent 488f861 commit 199a89a

File tree

21 files changed

+7265
-6
lines changed

21 files changed

+7265
-6
lines changed

.github/actionlint.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
self-hosted-runner:
3+
# Labels of self-hosted runner in array of strings.
4+
labels:
5+
- "self-hosted"
6+
- "proxmox"
7+
- "e2e"
8+
- "capmox"
9+
- "dcd-playground"
10+
# Configuration variables in array of strings defined in your repository or
11+
# organization. `null` means disabling configuration variables check.
12+
# Empty array means no configuration variable is allowed.
13+
config-variables: null

.github/workflows/e2e.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: e2e tests
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request: {}
7+
8+
jobs:
9+
e2e:
10+
runs-on: [capmox,e2e,dcd-playground]
11+
environment: e2e
12+
env:
13+
PROXMOX_URL: ${{ secrets.PROXMOX_URL }}
14+
PROXMOX_TOKEN: ${{ secrets.PROXMOX_TOKEN }}
15+
PROXMOX_SECRET: ${{ secrets.PROXMOX_SECRET }}
16+
steps:
17+
- uses: actions/[email protected]
18+
- uses: actions/setup-go@v4
19+
with:
20+
go-version-file: go.mod
21+
- name: Run e2e tests
22+
run: "make test-e2e"

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ cluster-**.yaml
3838

3939
# direnv files
4040
.envrc
41+
42+
# e2e
43+
_artifacts
44+
**e2e.test
45+
test/e2e/config/*-envsubst.yaml

.yamllint

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ ignore:
2828
- config/certmanager
2929
- config/prometheus
3030
- config/rbac
31+
- test/e2e
3132
- out
3233
- .*.yaml
3334
- .*.yml

Makefile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,65 @@ release-manifests: $(KUSTOMIZE) ## Create kustomized release manifest in $RELEAS
250250
release-templates: ## Generate release templates
251251
@mkdir -p $(RELEASE_DIR)
252252
cp templates/cluster-template*.yaml $(RELEASE_DIR)/
253+
254+
255+
##@ e2e
256+
## --------------------------------------
257+
## E2e tests
258+
## --------------------------------------
259+
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
260+
E2E_CONF_FILE ?= $(ROOT_DIR)/test/e2e/config/proxmox-ci.yaml
261+
E2E_CONF_FILE_ENVSUBST := $(ROOT_DIR)/test/e2e/config/proxmox-ci-envsubst.yaml
262+
E2E_DATA_DIR ?= $(ROOT_DIR)/test/e2e/data
263+
KUBETEST_CONF_PATH ?= $(abspath $(E2E_DATA_DIR)/kubetest/conformance.yaml)
264+
265+
266+
# Allow overriding the e2e configurations
267+
GINKGO_FOCUS ?= Workload cluster creation
268+
GINKGO_SKIP ?= API Version Upgrade
269+
GINKGO_NODES ?= 1
270+
GINKGO_NOCOLOR ?= false
271+
GINKGO_ARGS ?=
272+
GINKGO_TIMEOUT ?= 2h
273+
GINKGO_POLL_PROGRESS_AFTER ?= 10m
274+
GINKGO_POLL_PROGRESS_INTERVAL ?= 1m
275+
ARTIFACTS ?= $(ROOT_DIR)/_artifacts
276+
SKIP_CLEANUP ?= false
277+
SKIP_CREATE_MGMT_CLUSTER ?= false
278+
279+
# Install tools
280+
281+
GINKGO_BIN := ginkgo
282+
GINKGO := $(LOCALBIN)/$(GINKGO_BIN)
283+
284+
ENVSUBST_VER := v1.4.2
285+
ENVSUBST_BIN := envsubst
286+
ENVSUBST := $(LOCALBIN)/$(ENVSUBST_BIN)
287+
288+
$(ENVSUBST): ## Build envsubst.
289+
test -s $(LOCALBIN)/$(ENVSUBST_BIN) || \
290+
GOBIN=$(LOCALBIN) go install github.com/a8m/envsubst/cmd/envsubst@$(ENVSUBST_VER)
291+
292+
$(GINKGO): ## Build ginkgo.
293+
GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/ginkgo
294+
295+
.PHONY: e2e-image
296+
e2e-image:
297+
docker build --tag="$(REPOSITORY):e2e" .
298+
299+
.PHONY: test-e2e
300+
test-e2e: $(ENVSUBST) $(KUBECTL) $(GINKGO) e2e-image ## Run the end-to-end tests
301+
$(ENVSUBST) < $(E2E_CONF_FILE) > $(E2E_CONF_FILE_ENVSUBST) && \
302+
time $(GINKGO) -v --trace -poll-progress-after=$(GINKGO_POLL_PROGRESS_AFTER) -poll-progress-interval=$(GINKGO_POLL_PROGRESS_INTERVAL) \
303+
--tags=e2e --focus="$(GINKGO_FOCUS)" -skip="$(GINKGO_SKIP)" --nodes=$(GINKGO_NODES) --no-color=$(GINKGO_NOCOLOR) \
304+
--timeout=$(GINKGO_TIMEOUT) --output-dir="$(ARTIFACTS)" --junit-report="junit.e2e_suite.1.xml" $(GINKGO_ARGS) ./test/e2e -- \
305+
-e2e.artifacts-folder="$(ARTIFACTS)" \
306+
-e2e.config="$(E2E_CONF_FILE_ENVSUBST)" \
307+
-e2e.skip-resource-cleanup=$(SKIP_CLEANUP) \
308+
-e2e.use-existing-cluster=$(SKIP_CREATE_MGMT_CLUSTER) $(E2E_ARGS)
309+
310+
CONFORMANCE_E2E_ARGS ?= -kubetest.config-file=$(KUBETEST_CONF_PATH)
311+
CONFORMANCE_E2E_ARGS += $(E2E_ARGS)
312+
.PHONY: test-conformance
313+
test-conformance: ## Run conformance test on workload cluster.
314+
$(MAKE) test-e2e GINKGO_FOCUS="Conformance Tests" E2E_ARGS='$(CONFORMANCE_E2E_ARGS)' GINKGO_ARGS='$(LOCAL_GINKGO_ARGS)'

go.mod

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ module github.com/ionos-cloud/cluster-api-provider-proxmox
22

33
go 1.20
44

5+
replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.6.1
6+
57
require (
68
github.com/go-logr/logr v1.4.1
79
github.com/google/uuid v1.6.0
810
github.com/jarcoal/httpmock v1.3.1
911
github.com/luthermonson/go-proxmox v0.0.0-beta2
10-
github.com/onsi/ginkgo/v2 v2.13.1
12+
github.com/onsi/ginkgo/v2 v2.13.2
1113
github.com/onsi/gomega v1.30.0
1214
github.com/pkg/errors v0.9.1
1315
github.com/spf13/pflag v1.0.5
@@ -21,16 +23,35 @@ require (
2123
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
2224
sigs.k8s.io/cluster-api v1.6.1
2325
sigs.k8s.io/cluster-api-ipam-provider-in-cluster v0.1.0-alpha.3
26+
sigs.k8s.io/cluster-api/test v1.6.1
2427
sigs.k8s.io/controller-runtime v0.16.3
2528
)
2629

2730
require (
31+
github.com/BurntSushi/toml v1.2.1 // indirect
32+
github.com/MakeNowJust/heredoc v1.0.0 // indirect
33+
github.com/Masterminds/goutils v1.1.1 // indirect
34+
github.com/Masterminds/semver/v3 v3.2.0 // indirect
35+
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
36+
github.com/Microsoft/go-winio v0.5.0 // indirect
37+
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
38+
github.com/adrg/xdg v0.4.0 // indirect
39+
github.com/alessio/shellescape v1.4.1 // indirect
40+
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df // indirect
41+
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
2842
github.com/beorn7/perks v1.0.1 // indirect
2943
github.com/blang/semver/v4 v4.0.0 // indirect
3044
github.com/buger/goterm v1.0.4 // indirect
3145
github.com/cespare/xxhash/v2 v2.2.0 // indirect
46+
github.com/cloudflare/circl v1.3.7 // indirect
3247
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
3348
github.com/diskfs/go-diskfs v1.2.0 // indirect
49+
github.com/distribution/reference v0.5.0 // indirect
50+
github.com/docker/distribution v2.8.3+incompatible // indirect
51+
github.com/docker/docker v24.0.7+incompatible // indirect
52+
github.com/docker/go-connections v0.4.0 // indirect
53+
github.com/docker/go-units v0.4.0 // indirect
54+
github.com/drone/envsubst/v2 v2.0.0-20210730161058-179042472c46 // indirect
3455
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
3556
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
3657
github.com/evanphx/json-patch/v5 v5.7.0 // indirect
@@ -44,49 +65,84 @@ require (
4465
github.com/gogo/protobuf v1.3.2 // indirect
4566
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
4667
github.com/golang/protobuf v1.5.3 // indirect
68+
github.com/google/cel-go v0.16.1 // indirect
4769
github.com/google/gnostic-models v0.6.8 // indirect
4870
github.com/google/go-cmp v0.6.0 // indirect
71+
github.com/google/go-github/v53 v53.2.0 // indirect
72+
github.com/google/go-querystring v1.1.0 // indirect
4973
github.com/google/gofuzz v1.2.0 // indirect
5074
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
75+
github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 // indirect
5176
github.com/gorilla/websocket v1.4.2 // indirect
77+
github.com/hashicorp/hcl v1.0.0 // indirect
78+
github.com/huandu/xstrings v1.3.3 // indirect
5279
github.com/imdario/mergo v0.3.15 // indirect
80+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
5381
github.com/jinzhu/copier v0.3.4 // indirect
5482
github.com/josharian/intern v1.0.0 // indirect
5583
github.com/json-iterator/go v1.1.12 // indirect
5684
github.com/magefile/mage v1.14.0 // indirect
85+
github.com/magiconair/properties v1.8.7 // indirect
5786
github.com/mailru/easyjson v0.7.7 // indirect
87+
github.com/mattn/go-isatty v0.0.20 // indirect
5888
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
89+
github.com/mitchellh/copystructure v1.2.0 // indirect
90+
github.com/mitchellh/mapstructure v1.5.0 // indirect
91+
github.com/mitchellh/reflectwalk v1.0.2 // indirect
5992
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
6093
github.com/modern-go/reflect2 v1.0.2 // indirect
6194
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
62-
github.com/pmezard/go-difflib v1.0.0 // indirect
95+
github.com/opencontainers/go-digest v1.0.0 // indirect
96+
github.com/opencontainers/image-spec v1.0.2 // indirect
97+
github.com/pelletier/go-toml v1.9.5 // indirect
98+
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
99+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
63100
github.com/prometheus/client_golang v1.17.0 // indirect
64101
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
65102
github.com/prometheus/common v0.44.0 // indirect
66103
github.com/prometheus/procfs v0.11.1 // indirect
104+
github.com/sagikazarmark/locafero v0.3.0 // indirect
105+
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
106+
github.com/shopspring/decimal v1.3.1 // indirect
107+
github.com/sourcegraph/conc v0.3.0 // indirect
108+
github.com/spf13/afero v1.10.0 // indirect
109+
github.com/spf13/cast v1.5.1 // indirect
110+
github.com/spf13/cobra v1.8.0 // indirect
111+
github.com/spf13/viper v1.17.0 // indirect
112+
github.com/stoewer/go-strcase v1.2.0 // indirect
67113
github.com/stretchr/objx v0.5.0 // indirect
114+
github.com/subosito/gotenv v1.6.0 // indirect
115+
github.com/valyala/fastjson v1.6.4 // indirect
68116
go.uber.org/goleak v1.3.0 // indirect
69117
go.uber.org/multierr v1.11.0 // indirect
70118
go.uber.org/zap v1.25.0 // indirect
119+
golang.org/x/crypto v0.17.0 // indirect
71120
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
72121
golang.org/x/mod v0.13.0 // indirect
73122
golang.org/x/net v0.18.0 // indirect
74123
golang.org/x/oauth2 v0.14.0 // indirect
124+
golang.org/x/sync v0.4.0 // indirect
75125
golang.org/x/sys v0.15.0 // indirect
76126
golang.org/x/term v0.15.0 // indirect
77127
golang.org/x/text v0.14.0 // indirect
78128
golang.org/x/time v0.3.0 // indirect
79129
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
80130
google.golang.org/appengine v1.6.7 // indirect
131+
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect
132+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect
81133
google.golang.org/protobuf v1.31.0 // indirect
82134
gopkg.in/djherbis/times.v1 v1.2.0 // indirect
83135
gopkg.in/inf.v0 v0.9.1 // indirect
136+
gopkg.in/ini.v1 v1.67.0 // indirect
84137
gopkg.in/yaml.v2 v2.4.0 // indirect
85138
gopkg.in/yaml.v3 v3.0.1 // indirect
86139
k8s.io/apiextensions-apiserver v0.28.4 // indirect
140+
k8s.io/apiserver v0.28.4 // indirect
141+
k8s.io/cluster-bootstrap v0.28.4 // indirect
87142
k8s.io/component-base v0.28.4 // indirect
88143
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
89144
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
145+
sigs.k8s.io/kind v0.20.0 // indirect
90146
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
91147
sigs.k8s.io/yaml v1.4.0 // indirect
92148
)

0 commit comments

Comments
 (0)