Skip to content

Commit b61d821

Browse files
committed
[test] Allow to use different linode uri
- Get linode token and url from linode secret under kube-system - Count number of nodes using chainsaw function - Allow to define KUBECONFIG file in Makefile
1 parent e1b061c commit b61d821

File tree

16 files changed

+343
-77
lines changed

16 files changed

+343
-77
lines changed

Makefile

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ GRAFANA_PORT ?= 3000
6969
GRAFANA_USERNAME ?= admin
7070
GRAFANA_PASSWORD ?= admin
7171
DATA_RETENTION_PERIOD ?= 15d # Prometheus data retention period
72+
KUBECONFIG ?= test-cluster-kubeconfig.yaml
7273

7374
.PHONY: build
7475
build:
@@ -111,18 +112,18 @@ create-capl-cluster:
111112
kubectl wait --for=condition=ControlPlaneReady cluster/$(CLUSTER_NAME) --timeout=600s || (kubectl get cluster -o yaml; kubectl get linodecluster -o yaml; kubectl get linodemachines -o yaml)
112113
kubectl wait --for=condition=NodeHealthy=true machines -l cluster.x-k8s.io/cluster-name=$(CLUSTER_NAME) --timeout=900s
113114
clusterctl get kubeconfig $(CLUSTER_NAME) > test-cluster-kubeconfig.yaml
114-
KUBECONFIG=test-cluster-kubeconfig.yaml kubectl wait --for=condition=Ready nodes --all --timeout=600s
115-
cat tests/e2e/setup/linode-secret.yaml | envsubst | KUBECONFIG=test-cluster-kubeconfig.yaml kubectl apply -f -
115+
KUBECONFIG=$(KUBECONFIG) kubectl wait --for=condition=Ready nodes --all --timeout=600s
116+
cat tests/e2e/setup/linode-secret.yaml | envsubst | KUBECONFIG=$(KUBECONFIG) kubectl apply -f -
116117

117118
.PHONY: generate-csi-driver-manifests
118119
generate-csi-driver-manifests:
119120
hack/generate-yaml.sh $(IMAGE_VERSION) $(DOCKER_USER)/$(IMAGE_NAME) > csi-manifests.yaml
120121

121122
.PHONY: install-csi
122123
install-csi:
123-
KUBECONFIG=test-cluster-kubeconfig.yaml kubectl apply -f csi-manifests.yaml
124-
KUBECONFIG=test-cluster-kubeconfig.yaml kubectl rollout status -n kube-system daemonset/csi-linode-node --timeout=600s
125-
KUBECONFIG=test-cluster-kubeconfig.yaml kubectl rollout status -n kube-system statefulset/csi-linode-controller --timeout=600s
124+
KUBECONFIG=$(KUBECONFIG) kubectl apply -f csi-manifests.yaml
125+
KUBECONFIG=$(KUBECONFIG) kubectl rollout status -n kube-system daemonset/csi-linode-node --timeout=600s
126+
KUBECONFIG=$(KUBECONFIG) kubectl rollout status -n kube-system statefulset/csi-linode-controller --timeout=600s
126127

127128
.PHONY: mgmt-cluster
128129
mgmt-cluster:
@@ -165,15 +166,15 @@ test:
165166
.PHONY: e2e-test
166167
e2e-test:
167168
openssl rand -out luks.key 64
168-
CONTROLPLANE_NODES=$(CONTROLPLANE_NODES) WORKER_NODES=$(WORKER_NODES) KUBECONFIG=test-cluster-kubeconfig.yaml LUKS_KEY=$$(base64 luks.key | tr -d '\n') chainsaw test ./tests/e2e --parallel 2 --selector $(E2E_SELECTOR)
169+
KUBECONFIG=$(KUBECONFIG) LUKS_KEY=$$(base64 luks.key | tr -d '\n') chainsaw test ./tests/e2e --parallel 2 --selector $(E2E_SELECTOR)
169170

170171
.PHONY: csi-sanity-test
171172
csi-sanity-test:
172-
KUBECONFIG=test-cluster-kubeconfig.yaml ./tests/csi-sanity/run-tests.sh
173+
KUBECONFIG=$(KUBECONFIG) ./tests/csi-sanity/run-tests.sh
173174

174175
.PHONY: upstream-e2e-tests
175176
upstream-e2e-tests:
176-
OS=$(OS) ARCH=$(ARCH_SHORT) K8S_VERSION=$(K8S_VERSION) KUBECONFIG=test-cluster-kubeconfig.yaml ./tests/upstream-e2e/run-tests.sh
177+
OS=$(OS) ARCH=$(ARCH_SHORT) K8S_VERSION=$(K8S_VERSION) KUBECONFIG=$(KUBECONFIG) ./tests/upstream-e2e/run-tests.sh
177178

178179
#####################################################################
179180
# CI Setup
@@ -203,19 +204,19 @@ grafana-dashboard: install-prometheus install-grafana setup-dashboard
203204
#####################################################################
204205
.PHONY: install-prometheus
205206
install-prometheus:
206-
KUBECONFIG=test-cluster-kubeconfig.yaml DATA_RETENTION_PERIOD=$(DATA_RETENTION_PERIOD) \
207+
KUBECONFIG=$(KUBECONFIG) DATA_RETENTION_PERIOD=$(DATA_RETENTION_PERIOD) \
207208
./hack/install-prometheus.sh --timeout=600s
208209

209210
.PHONY: install-grafana
210211
install-grafana:
211-
KUBECONFIG=test-cluster-kubeconfig.yaml GRAFANA_PORT=$(GRAFANA_PORT) \
212+
KUBECONFIG=$(KUBECONFIG) GRAFANA_PORT=$(GRAFANA_PORT) \
212213
GRAFANA_USERNAME=$(GRAFANA_USERNAME) GRAFANA_PASSWORD=$(GRAFANA_PASSWORD) \
213214
./hack/install-grafana.sh --timeout=600s
214215

215216
.PHONY: setup-dashboard
216217
setup-dashboard:
217-
KUBECONFIG=test-cluster-kubeconfig.yaml ./hack/setup-dashboard.sh --namespace=monitoring --dashboard-file=observability/metrics/dashboard.json
218+
KUBECONFIG=$(KUBECONFIG) ./hack/setup-dashboard.sh --namespace=monitoring --dashboard-file=observability/metrics/dashboard.json
218219

219220
.PHONY: setup-tracing
220221
setup-tracing:
221-
KUBECONFIG=test-cluster-kubeconfig.yaml ./hack/setup-tracing.sh
222+
KUBECONFIG=$(KUBECONFIG) ./hack/setup-tracing.sh

tests/csi-sanity/mkdir_in_pod.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/sh
2-
kubectl exec csi-linode-controller-0 -n kube-system -c csi-linode-plugin -- mktemp -d /tmp/csi-sanity.XXXXXX
2+
kubectl exec csi-linode-controller-0 -n kube-system -c csi-linode-plugin -- mktemp -d /var/lib/csi/sockets/pluginproxy/csi-sanity.XXXXXX

tests/e2e/test/check-volume-deleted.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if [ "$#" -ne 1 ]; then
77
fi
88

99
# Set environment variables (if not already set)
10-
TARGET_API=${TARGET_API:-api.linode.com}
10+
TARGET_API=${TARGET_API:-https://api.linode.com}
1111
TARGET_API_VERSION=${TARGET_API_VERSION:-v4}
1212
URI=${URI:-volumes}
1313
FILTER=$1
@@ -19,7 +19,7 @@ curl_command() {
1919
-H "Authorization: Bearer $LINODE_TOKEN" \
2020
-H "X-Filter: $FILTER" \
2121
-H "Content-Type: application/json" \
22-
"https://$TARGET_API/$TARGET_API_VERSION/$URI"
22+
"$TARGET_API/$TARGET_API_VERSION/$URI"
2323
}
2424

2525
echo "Checking Linode API for volume status..."

tests/e2e/test/check-volume-detached.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fi
99
INTERVAL=3 # Time in seconds between checks
1010

1111
# Set environment variables for the second part
12-
TARGET_API=${TARGET_API:-api.linode.com}
12+
TARGET_API=${TARGET_API:-https://api.linode.com}
1313
TARGET_API_VERSION=${TARGET_API_VERSION:-v4}
1414
URI=${URI:-volumes}
1515
FILTER=$1
@@ -21,14 +21,13 @@ curl_command() {
2121
-H "Authorization: Bearer $LINODE_TOKEN" \
2222
-H "X-Filter: $FILTER" \
2323
-H "Content-Type: application/json" \
24-
"https://$TARGET_API/$TARGET_API_VERSION/$URI"
24+
"$TARGET_API/$TARGET_API_VERSION/$URI"
2525
}
2626

2727
echo "Checking Linode API for volume status..."
2828

2929
for ((i=1; i<=$MAX_RETRIES; i++)); do
3030
response=$(curl_command)
31-
3231
if [ $? -eq 0 ]; then
3332
# Check if the response is valid JSON
3433
if jq -e . >/dev/null 2>&1 <<< "$response"; then

tests/e2e/test/check-volume-size.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if [ "$#" -ne 2 ]; then
77
fi
88

99
# Set environment variables (if not already set)
10-
TARGET_API=${TARGET_API:-api.linode.com}
10+
TARGET_API=${TARGET_API:-https://api.linode.com}
1111
TARGET_API_VERSION=${TARGET_API_VERSION:-v4}
1212
URI=${URI:-volumes}
1313
FILTER=$1
@@ -20,7 +20,7 @@ curl_command() {
2020
-H "Authorization: Bearer $LINODE_TOKEN" \
2121
-H "X-Filter: $FILTER" \
2222
-H "Content-Type: application/json" \
23-
"https://$TARGET_API/$TARGET_API_VERSION/$URI"
23+
"$TARGET_API/$TARGET_API_VERSION/$URI"
2424
}
2525

2626
echo "Checking Linode API for volume status..."

tests/e2e/test/pod-pvc-basic-filesystem/chainsaw-test.yaml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ spec:
1111
bindings:
1212
- name: nodes
1313
# number of nodes in cluster
14-
value: ((env('WORKER_NODES') | to_number(@)) + (env('CONTROLPLANE_NODES') | to_number(@)))
14+
value: (length(x_k8s_list($client, 'v1', 'Node', '').items))
15+
- name: linode_url
16+
value: (base64_decode(x_k8s_get($client, 'v1', 'Secret', 'kube-system', 'linode').data.apiurl || base64_encode('https://api.linode.com')))
17+
- name: linode_token
18+
value: (base64_decode(x_k8s_get($client, 'v1', 'Secret', 'kube-system', 'linode').data.token))
1519
steps:
1620
- name: Check if CSI Driver is deployed
1721
try:
@@ -44,20 +48,22 @@ spec:
4448
- script:
4549
env:
4650
- name: TARGET_API
47-
value: api.linode.com
51+
value: ($linode_url)
4852
- name: TARGET_API_VERSION
49-
value: v4beta
53+
value: v4
5054
- name: URI
5155
value: volumes
56+
- name: LINODE_TOKEN
57+
value: ($linode_token)
5258
- name: FILTER
5359
value: (to_string({"tags":($namespace)}))
5460
content: |
5561
set -e
5662
curl -s \
57-
-H "Authorization: Bearer $LINODE_TOKEN" \
63+
-H "Authorization: Bearer ${LINODE_TOKEN}" \
5864
-H "X-Filter: $FILTER" \
5965
-H "Content-Type: application/json" \
60-
"https://api.linode.com/v4beta/volumes"
66+
"${TARGET_API}/${TARGET_API_VERSION}/${URI}"
6167
check:
6268
($error): ~
6369
(json_parse($stdout)):
@@ -84,6 +90,14 @@ spec:
8490
try:
8591
- script:
8692
env:
93+
- name: TARGET_API
94+
value: ($linode_url)
95+
- name: TARGET_API_VERSION
96+
value: v4
97+
- name: URI
98+
value: volumes
99+
- name: LINODE_TOKEN
100+
value: ($linode_token)
87101
- name: FILTER
88102
value: (to_string({"tags":($namespace)}))
89103
content: |
@@ -102,6 +116,14 @@ spec:
102116
try:
103117
- script:
104118
env:
119+
- name: TARGET_API
120+
value: ($linode_url)
121+
- name: TARGET_API_VERSION
122+
value: v4
123+
- name: URI
124+
value: volumes
125+
- name: LINODE_TOKEN
126+
value: ($linode_token)
105127
- name: FILTER
106128
value: (to_string({"tags":($namespace)}))
107129
content: |

tests/e2e/test/pod-pvc-create-ext4-filesystem/chainsaw-test.yaml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ spec:
1111
bindings:
1212
- name: nodes
1313
# number of nodes in cluster
14-
value: ((env('WORKER_NODES') | to_number(@)) + (env('CONTROLPLANE_NODES') | to_number(@)))
14+
value: (length(x_k8s_list($client, 'v1', 'Node', '').items))
15+
- name: linode_url
16+
value: (base64_decode(x_k8s_get($client, 'v1', 'Secret', 'kube-system', 'linode').data.apiurl || base64_encode('https://api.linode.com')))
17+
- name: linode_token
18+
value: (base64_decode(x_k8s_get($client, 'v1', 'Secret', 'kube-system', 'linode').data.token))
1519
steps:
1620
- name: Check if CSI Driver is deployed
1721
try:
@@ -44,20 +48,22 @@ spec:
4448
- script:
4549
env:
4650
- name: TARGET_API
47-
value: api.linode.com
51+
value: ($linode_url)
4852
- name: TARGET_API_VERSION
49-
value: v4beta
53+
value: v4
5054
- name: URI
5155
value: volumes
56+
- name: LINODE_TOKEN
57+
value: ($linode_token)
5258
- name: FILTER
5359
value: (to_string({"tags":($namespace)}))
5460
content: |
5561
set -e
5662
curl -s \
57-
-H "Authorization: Bearer $LINODE_TOKEN" \
63+
-H "Authorization: Bearer ${LINODE_TOKEN}" \
5864
-H "X-Filter: $FILTER" \
5965
-H "Content-Type: application/json" \
60-
"https://api.linode.com/v4beta/volumes"
66+
"${TARGET_API}/${TARGET_API_VERSION}/${URI}"
6167
check:
6268
($error): ~
6369
(json_parse($stdout)):
@@ -93,6 +99,14 @@ spec:
9399
try:
94100
- script:
95101
env:
102+
- name: TARGET_API
103+
value: ($linode_url)
104+
- name: TARGET_API_VERSION
105+
value: v4
106+
- name: URI
107+
value: volumes
108+
- name: LINODE_TOKEN
109+
value: ($linode_token)
96110
- name: FILTER
97111
value: (to_string({"tags":($namespace)}))
98112
content: |
@@ -111,6 +125,14 @@ spec:
111125
try:
112126
- script:
113127
env:
128+
- name: TARGET_API
129+
value: ($linode_url)
130+
- name: TARGET_API_VERSION
131+
value: v4
132+
- name: URI
133+
value: volumes
134+
- name: LINODE_TOKEN
135+
value: ($linode_token)
114136
- name: FILTER
115137
value: (to_string({"tags":($namespace)}))
116138
content: |

tests/e2e/test/pod-pvc-create-xfs-filesystem/chainsaw-test.yaml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ spec:
1111
bindings:
1212
- name: nodes
1313
# number of nodes in cluster
14-
value: ((env('WORKER_NODES') | to_number(@)) + (env('CONTROLPLANE_NODES') | to_number(@)))
14+
value: (length(x_k8s_list($client, 'v1', 'Node', '').items))
15+
- name: linode_url
16+
value: (base64_decode(x_k8s_get($client, 'v1', 'Secret', 'kube-system', 'linode').data.apiurl || base64_encode('https://api.linode.com')))
17+
- name: linode_token
18+
value: (base64_decode(x_k8s_get($client, 'v1', 'Secret', 'kube-system', 'linode').data.token))
1519
steps:
1620
- name: Check if CSI Driver is deployed
1721
try:
@@ -44,20 +48,22 @@ spec:
4448
- script:
4549
env:
4650
- name: TARGET_API
47-
value: api.linode.com
51+
value: ($linode_url)
4852
- name: TARGET_API_VERSION
49-
value: v4beta
53+
value: v4
5054
- name: URI
5155
value: volumes
56+
- name: LINODE_TOKEN
57+
value: ($linode_token)
5258
- name: FILTER
5359
value: (to_string({"tags":($namespace)}))
5460
content: |
5561
set -e
5662
curl -s \
57-
-H "Authorization: Bearer $LINODE_TOKEN" \
63+
-H "Authorization: Bearer ${LINODE_TOKEN}" \
5864
-H "X-Filter: $FILTER" \
5965
-H "Content-Type: application/json" \
60-
"https://api.linode.com/v4beta/volumes"
66+
"${TARGET_API}/${TARGET_API_VERSION}/${URI}"
6167
check:
6268
($error): ~
6369
(json_parse($stdout)):
@@ -92,6 +98,14 @@ spec:
9298
try:
9399
- script:
94100
env:
101+
- name: TARGET_API
102+
value: ($linode_url)
103+
- name: TARGET_API_VERSION
104+
value: v4
105+
- name: URI
106+
value: volumes
107+
- name: LINODE_TOKEN
108+
value: ($linode_token)
95109
- name: FILTER
96110
value: (to_string({"tags":($namespace)}))
97111
content: |
@@ -110,6 +124,14 @@ spec:
110124
try:
111125
- script:
112126
env:
127+
- name: TARGET_API
128+
value: ($linode_url)
129+
- name: TARGET_API_VERSION
130+
value: v4
131+
- name: URI
132+
value: volumes
133+
- name: LINODE_TOKEN
134+
value: ($linode_token)
113135
- name: FILTER
114136
value: (to_string({"tags":($namespace)}))
115137
content: |

0 commit comments

Comments
 (0)