From d17ecbe00234a7f25f5f08eceb763f65494b4bbb Mon Sep 17 00:00:00 2001 From: jmontesi <100689165+jmontesi@users.noreply.github.com> Date: Tue, 16 Apr 2024 13:08:56 +0200 Subject: [PATCH] Add a PV, a PVC and a volume to the test pods (#420) * Add a PV, a PVC and a volume to the test pods This allows testing some storage related test cases in the CI. --- Makefile | 1 + scripts/clean.sh | 1 + scripts/delete-storage.sh | 14 +++++++++++++ scripts/deploy-storage.sh | 14 +++++++++++++ test-target/local-pod-under-test.yaml | 4 ++++ test-target/storage.yaml | 30 +++++++++++++++++++++++++++ 6 files changed, 64 insertions(+) create mode 100755 scripts/delete-storage.sh create mode 100755 scripts/deploy-storage.sh create mode 100644 test-target/storage.yaml diff --git a/Makefile b/Makefile index 2cd44801..4099cfa0 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ install: ./scripts/fix-node-labels.sh ./scripts/deploy-multus-network.sh ./scripts/deploy-resource-quota.sh + ./scripts/deploy-storage.sh ./scripts/deploy-test-pods.sh ./scripts/deploy-statefulset-test-pods.sh ./scripts/deploy-pod-disruption-budget.sh diff --git a/scripts/clean.sh b/scripts/clean.sh index 98f0ae3d..590e1e2c 100755 --- a/scripts/clean.sh +++ b/scripts/clean.sh @@ -18,3 +18,4 @@ source "$SCRIPT_DIR"/init-env.sh ./"$SCRIPT_DIR"/delete-resource-quota.sh ./"$SCRIPT_DIR"/delete-pod-disruption-budget.sh ./"$SCRIPT_DIR"/delete-cr-scale-operator.sh +./"$SCRIPT_DIR"/delete-storage.sh diff --git a/scripts/delete-storage.sh b/scripts/delete-storage.sh new file mode 100755 index 00000000..c0e3288e --- /dev/null +++ b/scripts/delete-storage.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# Initialization +SCRIPT_DIR=$(dirname "$0") + +# shellcheck disable=SC1091 # Not following. +source "$SCRIPT_DIR"/init-env.sh + +mkdir -p ./temp + +# shellcheck disable=SC2002 # Useless cat. +cat ./test-target/storage.yaml | "$SCRIPT_DIR"/mo >./temp/rendered-test-storage.yaml +oc delete --filename ./temp/rendered-test-storage.yaml -n "$TNF_EXAMPLE_CNF_NAMESPACE" --ignore-not-found=true +rm ./temp/rendered-test-storage.yaml diff --git a/scripts/deploy-storage.sh b/scripts/deploy-storage.sh new file mode 100755 index 00000000..32dc4c38 --- /dev/null +++ b/scripts/deploy-storage.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# Initialization +SCRIPT_DIR=$(dirname "$0") + +# shellcheck disable=SC1091 # Not following. +source "$SCRIPT_DIR"/init-env.sh + +mkdir -p ./temp + +# shellcheck disable=SC2002 # Useless cat. +cat ./test-target/storage.yaml | "$SCRIPT_DIR"/mo >./temp/rendered-test-storage.yaml +oc apply --filename ./temp/rendered-test-storage.yaml --namespace "$TNF_EXAMPLE_CNF_NAMESPACE" +rm ./temp/rendered-test-storage.yaml diff --git a/test-target/local-pod-under-test.yaml b/test-target/local-pod-under-test.yaml index 365c099d..309c7a54 100644 --- a/test-target/local-pod-under-test.yaml +++ b/test-target/local-pod-under-test.yaml @@ -73,6 +73,10 @@ spec: periodSeconds: 5 command: ["./bin/app"] terminationMessagePolicy: FallbackToLogsOnError + volumes: + - name: test-volume + persistentVolumeClaim: + claimName: test-pvc affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: diff --git a/test-target/storage.yaml b/test-target/storage.yaml new file mode 100644 index 00000000..e874d7fb --- /dev/null +++ b/test-target/storage.yaml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: test-pv + labels: + role: test +spec: + capacity: + storage: 10Mi + accessModes: + - ReadWriteOnce + hostPath: + path: /data + persistentVolumeReclaimPolicy: Delete +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: test-pvc + namespace: {{ TNF_EXAMPLE_CNF_NAMESPACE }} +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Mi + selector: + matchLabels: + role: test +