Skip to content

Commit 8f7ffe5

Browse files
author
Richard Kovacs
committed
Replace Terroform to CAPL provider for E2E testing
1 parent 4899055 commit 8f7ffe5

19 files changed

+2688
-248
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ linode-cloud-controller-manager
99
# Folders
1010
_obj
1111
_test
12+
bin
1213

1314
# Architecture specific extensions/prefixes
1415
*.[568vq]

deploy/generate-manifest.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
: ${IMG:="linode/linode-cloud-controller-manager:latest"}
4+
35
set -o pipefail -o noclobber -o nounset
46

57
die() { echo "$*" 1>&2; exit 1; }
@@ -13,6 +15,8 @@ Second argument must be a Linode region.
1315
Example:
1416
$ ./generate-manifest.sh \$LINODE_API_TOKEN us-east"
1517

18+
rm -rf ccm-linode.yaml
19+
1620
BASE64FLAGS=""
1721
longstring="1234567890123456789012345678901234567890123456789012345678901234567890"
1822
if [ $(echo "$longstring" | base64 | wc -l) -gt 1 ]; then
@@ -26,4 +30,5 @@ ENCODED_REGION=$(echo -n $2 | base64 $BASE64FLAGS)
2630

2731
cat "$(dirname "$0")/ccm-linode-template.yaml" |
2832
sed -e "s|{{ .Values.apiTokenB64 }}|$ENCODED_TOKEN|" |
29-
sed -e "s|{{ .Values.linodeRegionB64 }}|$ENCODED_REGION|" > ccm-linode.yaml
33+
sed -e "s|{{ .Values.linodeRegionB64 }}|$ENCODED_REGION|" |
34+
sed "s|linode/linode-cloud-controller-manager:latest|$IMG|" > ccm-linode.yaml

devbox.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"packages": [
3+
"go_1_22@latest",
4+
5+
6+
7+
8+
9+
],
10+
"shell": {
11+
"init_hook": [
12+
"export GOROOT=$(go env GOROOT)",
13+
"export KUBECONFIG=${PWD}/e2e/test/kind-management.conf",
14+
"export K8S_VERSION=v1.28.7",
15+
"export REGION=eu-sea"
16+
],
17+
"scripts": {}
18+
}
19+
}

devbox.lock

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{
2+
"lockfile_version": "1",
3+
"packages": {
4+
5+
"last_modified": "2024-03-22T11:26:23Z",
6+
"resolved": "github:NixOS/nixpkgs/a3ed7406349a9335cb4c2a71369b697cecd9d351#clusterctl",
7+
"source": "devbox-search",
8+
"version": "1.6.3",
9+
"systems": {
10+
"aarch64-darwin": {
11+
"store_path": "/nix/store/s5i9i38fvpgf69x994n8v1sb82lpyl5f-clusterctl-1.6.3"
12+
},
13+
"aarch64-linux": {
14+
"store_path": "/nix/store/pj9x3qd0yz5bpk19snjwz25cm7bxnz5m-clusterctl-1.6.3"
15+
},
16+
"x86_64-darwin": {
17+
"store_path": "/nix/store/0vhfm1fkqx3wyrjiyam70zbakg9qmyra-clusterctl-1.6.3"
18+
},
19+
"x86_64-linux": {
20+
"store_path": "/nix/store/mjc4miffskqdby7ah5f66crxgydlns82-clusterctl-1.6.3"
21+
}
22+
}
23+
},
24+
25+
"last_modified": "2024-03-22T11:26:23Z",
26+
"resolved": "github:NixOS/nixpkgs/a3ed7406349a9335cb4c2a71369b697cecd9d351#ctlptl",
27+
"source": "devbox-search",
28+
"version": "0.8.28",
29+
"systems": {
30+
"aarch64-darwin": {
31+
"store_path": "/nix/store/3arviljap22bf4j6cwlks443kvmyaa9g-ctlptl-0.8.28"
32+
},
33+
"aarch64-linux": {
34+
"store_path": "/nix/store/35xjh902dsvq8n584g6jqk971gpsbl40-ctlptl-0.8.28"
35+
},
36+
"x86_64-darwin": {
37+
"store_path": "/nix/store/724aylc9p18xnj1i26qx86ql49vvpj2d-ctlptl-0.8.28"
38+
},
39+
"x86_64-linux": {
40+
"store_path": "/nix/store/9451r473b34va2ap5i1k830wdy3nbc9l-ctlptl-0.8.28"
41+
}
42+
}
43+
},
44+
45+
"last_modified": "2024-03-22T11:26:23Z",
46+
"resolved": "github:NixOS/nixpkgs/a3ed7406349a9335cb4c2a71369b697cecd9d351#ginkgo",
47+
"source": "devbox-search",
48+
"version": "2.17.0",
49+
"systems": {
50+
"aarch64-darwin": {
51+
"store_path": "/nix/store/3xjbbhq85x3iix4db5bky7x9h92l8mr9-ginkgo-2.17.0"
52+
},
53+
"aarch64-linux": {
54+
"store_path": "/nix/store/9fgwgs6q82q5r3z4d6sqh9nmpkkllz7i-ginkgo-2.17.0"
55+
},
56+
"x86_64-darwin": {
57+
"store_path": "/nix/store/3kkdi5gvy9gwm6ncc8ggvxk68wn0nfcp-ginkgo-2.17.0"
58+
},
59+
"x86_64-linux": {
60+
"store_path": "/nix/store/ifbjn9vcrplax832613bc0vz08qymwm9-ginkgo-2.17.0"
61+
}
62+
}
63+
},
64+
"go_1_22@latest": {
65+
"last_modified": "2024-03-22T11:26:23Z",
66+
"resolved": "github:NixOS/nixpkgs/a3ed7406349a9335cb4c2a71369b697cecd9d351#go",
67+
"source": "devbox-search",
68+
"version": "1.22.1",
69+
"systems": {
70+
"aarch64-darwin": {
71+
"store_path": "/nix/store/n1k6wf8q10q7k0863gb78b1rf0j07r7r-go-1.22.1"
72+
},
73+
"aarch64-linux": {
74+
"store_path": "/nix/store/fl6cjlp5bvykfz1kxrw687zxzld25pn7-go-1.22.1"
75+
},
76+
"x86_64-darwin": {
77+
"store_path": "/nix/store/xgdp7gnf6vzr2ick2ip1lhq4cww65p7w-go-1.22.1"
78+
},
79+
"x86_64-linux": {
80+
"store_path": "/nix/store/bp39dh48cdqp89hk5mpdi1lxdf0mjl7x-go-1.22.1"
81+
}
82+
}
83+
},
84+
85+
"last_modified": "2024-03-22T11:26:23Z",
86+
"resolved": "github:NixOS/nixpkgs/a3ed7406349a9335cb4c2a71369b697cecd9d351#kind",
87+
"source": "devbox-search",
88+
"version": "0.22.0",
89+
"systems": {
90+
"aarch64-darwin": {
91+
"store_path": "/nix/store/cff6f3a0av9pmak5w1wm9w2n1niq223b-kind-0.22.0"
92+
},
93+
"aarch64-linux": {
94+
"store_path": "/nix/store/xkkw8di5pmlgj7mw7mhq12mjigvh033l-kind-0.22.0"
95+
},
96+
"x86_64-darwin": {
97+
"store_path": "/nix/store/fxh74m2g045xwqv90lbvdg57bvk99pf6-kind-0.22.0"
98+
},
99+
"x86_64-linux": {
100+
"store_path": "/nix/store/m362mrwv0419cj176nwg31zcs4af6wrs-kind-0.22.0"
101+
}
102+
}
103+
},
104+
105+
"last_modified": "2024-02-10T18:15:24Z",
106+
"resolved": "github:NixOS/nixpkgs/10b813040df67c4039086db0f6eaf65c536886c6#kubectl",
107+
"source": "devbox-search",
108+
"version": "1.28.4",
109+
"systems": {
110+
"aarch64-darwin": {
111+
"store_path": "/nix/store/9awcbcg079c6v9crrxv1s9r5lrxcjjyi-kubectl-1.28.4"
112+
},
113+
"aarch64-linux": {
114+
"store_path": "/nix/store/vvrzf6y3xn6ynfykkimjqrgirdhb9c8i-kubectl-1.28.4"
115+
},
116+
"x86_64-darwin": {
117+
"store_path": "/nix/store/3z0fannmka27ggzaqhfxangy11c80f1f-kubectl-1.28.4"
118+
},
119+
"x86_64-linux": {
120+
"store_path": "/nix/store/77vmp37rm1vqmb37km04fwzp8rpcqys4-kubectl-1.28.4"
121+
}
122+
}
123+
}
124+
}
125+
}

e2e/Makefile

Lines changed: 88 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
1+
ROOT_DIR="$(shell git rev-parse --show-toplevel)"
2+
13
IMG ?= linode/linode-cloud-controller-manager:latest
2-
GINKGO_PATH := $(shell go env GOPATH)/bin/ginkgo
4+
K8S_VERSION?="v1.28.7"
35

46
REUSED_KUBECONFIG := test/ccm-linode-for-reuse.conf
7+
MANAGEMENT_KUBECONFIG := test/kind-management.conf
58

69
ifneq ("$(wildcard $(REUSED_KUBECONFIG))","")
710
CONTROL_PLANE_IP := $(shell grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" $(REUSED_KUBECONFIG))
811
endif
912

1013
.PHONY: test reuse-and-test clean
1114

12-
${GINKGO_PATH}:
13-
go install github.com/onsi/ginkgo/v2/[email protected]
15+
test-cluster: ctlptl kind clean-cluster
16+
./test/scripts/create_management_cluster.sh $(K8S_VERSION)
17+
18+
clean-cluster: ctlptl
19+
ctlptl delete cluster kind-management --ignore-not-found
20+
rm -rf $(MANAGEMENT_KUBECONFIG)
1421

1522
reuse-and-test: SUITE_ARGS='--reuse'
1623

17-
test reuse-and-test: ${GINKGO_PATH} check-token
24+
test reuse-and-test: clusterctl ginkgo check-token test-cluster
1825
go list -m; \
19-
ginkgo -r --vv --trace $(TEST_ARGS) -- --image=${IMG} $(SUITE_ARGS)
26+
MANAGEMENT_KUBECONFIG=$(ROOT_DIR)/e2e/$(MANAGEMENT_KUBECONFIG) ginkgo -r --vv --trace $(TEST_ARGS) -- --image=${IMG} --k8s_version=${K8S_VERSION} $(SUITE_ARGS)
27+
28+
$(MAKE) clean-cluster
2029

2130
clean: check-token
2231
cd test; \
23-
./scripts/delete_cluster.sh ccm-linode-for-reuse; \
24-
rm terraform.tfstate; \
25-
rm -rf terraform.tfstate.d
32+
./scripts/delete_cluster.sh ccm-linode-for-reuse
2633

2734
check-token:
2835
@if test "$(LINODE_API_TOKEN)" = "" ; then \
@@ -32,3 +39,76 @@ check-token:
3239

3340
control-plane-ssh: $(REUSED_KUBECONFIG)
3441
ssh root@$(CONTROL_PLANE_IP)
42+
43+
#####################################################################
44+
# OS / ARCH
45+
#####################################################################
46+
OS=$(shell uname -s | tr '[:upper:]' '[:lower:]')
47+
ARCH=$(shell uname -m)
48+
ARCH_SHORT=$(ARCH)
49+
ifeq ($(ARCH_SHORT),x86_64)
50+
ARCH_SHORT := amd64
51+
else ifeq ($(ARCH_SHORT),aarch64)
52+
ARCH_SHORT := arm64
53+
endif
54+
55+
## --------------------------------------
56+
## Build Dependencies
57+
## --------------------------------------
58+
59+
##@ Build Dependencies:
60+
61+
## Location to install dependencies to
62+
63+
# Use CACHE_BIN for tools that cannot use devbox and LOCALBIN for tools that can use either method
64+
CACHE_BIN ?= $(CURDIR)/../bin
65+
LOCALBIN ?= $(CACHE_BIN)
66+
67+
DEVBOX_BIN ?= $(DEVBOX_PACKAGES_DIR)/bin
68+
69+
# if the $DEVBOX_PACKAGES_DIR env variable exists that means we are within a devbox shell and can safely
70+
# use devbox's bin for our tools
71+
ifdef DEVBOX_PACKAGES_DIR
72+
LOCALBIN = $(DEVBOX_BIN)
73+
endif
74+
75+
export PATH := $(CACHE_BIN):$(PATH)
76+
$(LOCALBIN):
77+
mkdir -p $(LOCALBIN)
78+
79+
##@ Tooling Binaries:
80+
GINKGO ?= $(LOCALBIN)/ginkgo
81+
CTLPTL ?= $(LOCALBIN)/ctlptl
82+
CLUSTERCTL ?= $(LOCALBIN)/clusterctl
83+
KIND ?= $(LOCALBIN)/kind
84+
85+
## Tool Versions
86+
GINKGO_VERSION ?= v2.17.0
87+
CTLPTL_VERSION ?= v0.8.28
88+
CLUSTERCTL_VERSION ?= v1.6.3
89+
KIND_VERSION ?= v0.22.0
90+
91+
.PHONY: tools
92+
tools: ginkgo ctlptl clusterctl
93+
94+
.PHONY: ginkgo
95+
ginkgo: $(GINKGO)
96+
$(GINKGO): $(LOCALBIN) ## Download ginkgo locally if necessary.
97+
GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/ginkgo@$(GINKGO_VERSION)
98+
99+
.PHONY: ctlptl
100+
ctlptl: $(CTLPTL) ## Download ctlptl locally if necessary.
101+
$(CTLPTL): $(LOCALBIN)
102+
GOBIN=$(LOCALBIN) go install github.com/tilt-dev/ctlptl/cmd/ctlptl@$(CTLPTL_VERSION)
103+
104+
.PHONY: clusterctl
105+
clusterctl: $(CLUSTERCTL) ## Download clusterctl locally if necessary.
106+
$(CLUSTERCTL): $(LOCALBIN)
107+
curl -fsSL https://github.com/kubernetes-sigs/cluster-api/releases/download/$(CLUSTERCTL_VERSION)/clusterctl-$(OS)-$(ARCH_SHORT) -o $(CLUSTERCTL)
108+
chmod +x $(CLUSTERCTL)
109+
110+
.PHONY: kind
111+
kind: $(KIND) ## Download kustomize locally if necessary.
112+
$(KIND): $(LOCALBIN)
113+
curl -fsSL https://github.com/kubernetes-sigs/kind/releases/download/$(KIND_VERSION)/kind-$(OS)-$(ARCH_SHORT) -o $(KIND)
114+
chmod +x $(KIND)

0 commit comments

Comments
 (0)