Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Allow to use different linode uri #372

Merged
merged 5 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ GRAFANA_PORT ?= 3000
GRAFANA_USERNAME ?= admin
GRAFANA_PASSWORD ?= admin
DATA_RETENTION_PERIOD ?= 15d # Prometheus data retention period
KUBECONFIG ?= test-cluster-kubeconfig.yaml

.PHONY: build
build:
Expand Down Expand Up @@ -111,18 +112,18 @@ create-capl-cluster:
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)
kubectl wait --for=condition=NodeHealthy=true machines -l cluster.x-k8s.io/cluster-name=$(CLUSTER_NAME) --timeout=900s
clusterctl get kubeconfig $(CLUSTER_NAME) > test-cluster-kubeconfig.yaml
KUBECONFIG=test-cluster-kubeconfig.yaml kubectl wait --for=condition=Ready nodes --all --timeout=600s
cat tests/e2e/setup/linode-secret.yaml | envsubst | KUBECONFIG=test-cluster-kubeconfig.yaml kubectl apply -f -
KUBECONFIG=$(KUBECONFIG) kubectl wait --for=condition=Ready nodes --all --timeout=600s
cat tests/e2e/setup/linode-secret.yaml | envsubst | KUBECONFIG=$(KUBECONFIG) kubectl apply -f -

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

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

.PHONY: mgmt-cluster
mgmt-cluster:
Expand Down Expand Up @@ -165,15 +166,15 @@ test:
.PHONY: e2e-test
e2e-test:
openssl rand -out luks.key 64
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)
komer3 marked this conversation as resolved.
Show resolved Hide resolved
KUBECONFIG=$(KUBECONFIG) LUKS_KEY=$$(base64 luks.key | tr -d '\n') chainsaw test ./tests/e2e --parallel 2 --selector $(E2E_SELECTOR)

.PHONY: csi-sanity-test
csi-sanity-test:
KUBECONFIG=test-cluster-kubeconfig.yaml ./tests/csi-sanity/run-tests.sh
KUBECONFIG=$(KUBECONFIG) ./tests/csi-sanity/run-tests.sh

.PHONY: upstream-e2e-tests
upstream-e2e-tests:
OS=$(OS) ARCH=$(ARCH_SHORT) K8S_VERSION=$(K8S_VERSION) KUBECONFIG=test-cluster-kubeconfig.yaml ./tests/upstream-e2e/run-tests.sh
OS=$(OS) ARCH=$(ARCH_SHORT) K8S_VERSION=$(K8S_VERSION) KUBECONFIG=$(KUBECONFIG) ./tests/upstream-e2e/run-tests.sh

#####################################################################
# CI Setup
Expand Down Expand Up @@ -203,19 +204,19 @@ grafana-dashboard: install-prometheus install-grafana setup-dashboard
#####################################################################
.PHONY: install-prometheus
install-prometheus:
KUBECONFIG=test-cluster-kubeconfig.yaml DATA_RETENTION_PERIOD=$(DATA_RETENTION_PERIOD) \
KUBECONFIG=$(KUBECONFIG) DATA_RETENTION_PERIOD=$(DATA_RETENTION_PERIOD) \
./hack/install-prometheus.sh --timeout=600s

.PHONY: install-grafana
install-grafana:
KUBECONFIG=test-cluster-kubeconfig.yaml GRAFANA_PORT=$(GRAFANA_PORT) \
KUBECONFIG=$(KUBECONFIG) GRAFANA_PORT=$(GRAFANA_PORT) \
GRAFANA_USERNAME=$(GRAFANA_USERNAME) GRAFANA_PASSWORD=$(GRAFANA_PASSWORD) \
./hack/install-grafana.sh --timeout=600s

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

.PHONY: setup-tracing
setup-tracing:
KUBECONFIG=test-cluster-kubeconfig.yaml ./hack/setup-tracing.sh
KUBECONFIG=$(KUBECONFIG) ./hack/setup-tracing.sh
4 changes: 2 additions & 2 deletions tests/e2e/test/check-volume-deleted.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ "$#" -ne 1 ]; then
fi

# Set environment variables (if not already set)
TARGET_API=${TARGET_API:-api.linode.com}
TARGET_API=${TARGET_API:-https://api.linode.com}
TARGET_API_VERSION=${TARGET_API_VERSION:-v4}
URI=${URI:-volumes}
FILTER=$1
Expand All @@ -19,7 +19,7 @@ curl_command() {
-H "Authorization: Bearer $LINODE_TOKEN" \
-H "X-Filter: $FILTER" \
-H "Content-Type: application/json" \
"https://$TARGET_API/$TARGET_API_VERSION/$URI"
"$TARGET_API/$TARGET_API_VERSION/$URI"
}

echo "Checking Linode API for volume status..."
Expand Down
5 changes: 2 additions & 3 deletions tests/e2e/test/check-volume-detached.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fi
INTERVAL=3 # Time in seconds between checks

# Set environment variables for the second part
TARGET_API=${TARGET_API:-api.linode.com}
TARGET_API=${TARGET_API:-https://api.linode.com}
TARGET_API_VERSION=${TARGET_API_VERSION:-v4}
URI=${URI:-volumes}
FILTER=$1
Expand All @@ -21,14 +21,13 @@ curl_command() {
-H "Authorization: Bearer $LINODE_TOKEN" \
-H "X-Filter: $FILTER" \
-H "Content-Type: application/json" \
"https://$TARGET_API/$TARGET_API_VERSION/$URI"
"$TARGET_API/$TARGET_API_VERSION/$URI"
}

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

for ((i=1; i<=$MAX_RETRIES; i++)); do
response=$(curl_command)

if [ $? -eq 0 ]; then
# Check if the response is valid JSON
if jq -e . >/dev/null 2>&1 <<< "$response"; then
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/test/check-volume-size.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ "$#" -ne 2 ]; then
fi

# Set environment variables (if not already set)
TARGET_API=${TARGET_API:-api.linode.com}
TARGET_API=${TARGET_API:-https://api.linode.com}
TARGET_API_VERSION=${TARGET_API_VERSION:-v4}
URI=${URI:-volumes}
FILTER=$1
Expand All @@ -20,7 +20,7 @@ curl_command() {
-H "Authorization: Bearer $LINODE_TOKEN" \
-H "X-Filter: $FILTER" \
-H "Content-Type: application/json" \
"https://$TARGET_API/$TARGET_API_VERSION/$URI"
"$TARGET_API/$TARGET_API_VERSION/$URI"
}

echo "Checking Linode API for volume status..."
Expand Down
32 changes: 27 additions & 5 deletions tests/e2e/test/pod-pvc-basic-filesystem/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ spec:
bindings:
- name: nodes
# number of nodes in cluster
value: ((env('WORKER_NODES') | to_number(@)) + (env('CONTROLPLANE_NODES') | to_number(@)))
value: (length(x_k8s_list($client, 'v1', 'Node', '').items))
- name: linode_url
value: (base64_decode(x_k8s_get($client, 'v1', 'Secret', 'kube-system', 'linode').data.apiurl || base64_encode('https://api.linode.com')))
- name: linode_token
value: (base64_decode(x_k8s_get($client, 'v1', 'Secret', 'kube-system', 'linode').data.token))
steps:
- name: Check if CSI Driver is deployed
try:
Expand Down Expand Up @@ -44,20 +48,22 @@ spec:
- script:
env:
- name: TARGET_API
value: api.linode.com
value: ($linode_url)
- name: TARGET_API_VERSION
value: v4beta
value: v4
- name: URI
value: volumes
- name: LINODE_TOKEN
value: ($linode_token)
- name: FILTER
value: (to_string({"tags":($namespace)}))
content: |
set -e
curl -s \
-H "Authorization: Bearer $LINODE_TOKEN" \
-H "Authorization: Bearer ${LINODE_TOKEN}" \
-H "X-Filter: $FILTER" \
-H "Content-Type: application/json" \
"https://api.linode.com/v4beta/volumes"
"${TARGET_API}/${TARGET_API_VERSION}/${URI}"
check:
($error): ~
(json_parse($stdout)):
Expand All @@ -84,6 +90,14 @@ spec:
try:
- script:
env:
- name: TARGET_API
value: ($linode_url)
- name: TARGET_API_VERSION
value: v4
- name: URI
value: volumes
- name: LINODE_TOKEN
value: ($linode_token)
- name: FILTER
value: (to_string({"tags":($namespace)}))
content: |
Expand All @@ -102,6 +116,14 @@ spec:
try:
- script:
env:
- name: TARGET_API
value: ($linode_url)
- name: TARGET_API_VERSION
value: v4
- name: URI
value: volumes
- name: LINODE_TOKEN
value: ($linode_token)
- name: FILTER
value: (to_string({"tags":($namespace)}))
content: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ spec:
bindings:
- name: nodes
# number of nodes in cluster
value: ((env('WORKER_NODES') | to_number(@)) + (env('CONTROLPLANE_NODES') | to_number(@)))
value: (length(x_k8s_list($client, 'v1', 'Node', '').items))
- name: linode_url
value: (base64_decode(x_k8s_get($client, 'v1', 'Secret', 'kube-system', 'linode').data.apiurl || base64_encode('https://api.linode.com')))
- name: linode_token
value: (base64_decode(x_k8s_get($client, 'v1', 'Secret', 'kube-system', 'linode').data.token))
steps:
- name: Check if CSI Driver is deployed
try:
Expand Down Expand Up @@ -44,20 +48,22 @@ spec:
- script:
env:
- name: TARGET_API
value: api.linode.com
value: ($linode_url)
- name: TARGET_API_VERSION
value: v4beta
value: v4
- name: URI
value: volumes
- name: LINODE_TOKEN
value: ($linode_token)
- name: FILTER
value: (to_string({"tags":($namespace)}))
content: |
set -e
curl -s \
-H "Authorization: Bearer $LINODE_TOKEN" \
-H "Authorization: Bearer ${LINODE_TOKEN}" \
-H "X-Filter: $FILTER" \
-H "Content-Type: application/json" \
"https://api.linode.com/v4beta/volumes"
"${TARGET_API}/${TARGET_API_VERSION}/${URI}"
check:
($error): ~
(json_parse($stdout)):
Expand Down Expand Up @@ -93,6 +99,14 @@ spec:
try:
- script:
env:
- name: TARGET_API
value: ($linode_url)
- name: TARGET_API_VERSION
value: v4
- name: URI
value: volumes
- name: LINODE_TOKEN
value: ($linode_token)
- name: FILTER
value: (to_string({"tags":($namespace)}))
content: |
Expand All @@ -111,6 +125,14 @@ spec:
try:
- script:
env:
- name: TARGET_API
value: ($linode_url)
- name: TARGET_API_VERSION
value: v4
- name: URI
value: volumes
- name: LINODE_TOKEN
value: ($linode_token)
- name: FILTER
value: (to_string({"tags":($namespace)}))
content: |
Expand Down
32 changes: 27 additions & 5 deletions tests/e2e/test/pod-pvc-create-xfs-filesystem/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ spec:
bindings:
- name: nodes
# number of nodes in cluster
value: ((env('WORKER_NODES') | to_number(@)) + (env('CONTROLPLANE_NODES') | to_number(@)))
value: (length(x_k8s_list($client, 'v1', 'Node', '').items))
- name: linode_url
value: (base64_decode(x_k8s_get($client, 'v1', 'Secret', 'kube-system', 'linode').data.apiurl || base64_encode('https://api.linode.com')))
- name: linode_token
value: (base64_decode(x_k8s_get($client, 'v1', 'Secret', 'kube-system', 'linode').data.token))
steps:
- name: Check if CSI Driver is deployed
try:
Expand Down Expand Up @@ -44,20 +48,22 @@ spec:
- script:
env:
- name: TARGET_API
value: api.linode.com
value: ($linode_url)
- name: TARGET_API_VERSION
value: v4beta
value: v4
- name: URI
value: volumes
- name: LINODE_TOKEN
value: ($linode_token)
- name: FILTER
value: (to_string({"tags":($namespace)}))
content: |
set -e
curl -s \
-H "Authorization: Bearer $LINODE_TOKEN" \
-H "Authorization: Bearer ${LINODE_TOKEN}" \
-H "X-Filter: $FILTER" \
-H "Content-Type: application/json" \
"https://api.linode.com/v4beta/volumes"
"${TARGET_API}/${TARGET_API_VERSION}/${URI}"
check:
($error): ~
(json_parse($stdout)):
Expand Down Expand Up @@ -92,6 +98,14 @@ spec:
try:
- script:
env:
- name: TARGET_API
value: ($linode_url)
- name: TARGET_API_VERSION
value: v4
- name: URI
value: volumes
- name: LINODE_TOKEN
value: ($linode_token)
- name: FILTER
value: (to_string({"tags":($namespace)}))
content: |
Expand All @@ -110,6 +124,14 @@ spec:
try:
- script:
env:
- name: TARGET_API
value: ($linode_url)
- name: TARGET_API_VERSION
value: v4
- name: URI
value: volumes
- name: LINODE_TOKEN
value: ($linode_token)
- name: FILTER
value: (to_string({"tags":($namespace)}))
content: |
Expand Down
Loading
Loading