Skip to content

Commit cf92b88

Browse files
committed
add TopoLVM e2e tests
Signed-off-by: Evgeny Slutsky <eslutsky@redhat.com>
1 parent 3f77ab5 commit cf92b88

3 files changed

Lines changed: 107 additions & 0 deletions

File tree

src/topolvm/assets/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ resources:
66
patches:
77
- path: topolvm_mutatingwebhook_patch.yaml
88
- path: topolvm_service_patch.yaml
9+
- path: topolvm_configmap-lvmd_patch.yaml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: topolvm-lvmd-0
5+
namespace: topolvm-system
6+
data:
7+
lvmd.yaml: "socket-name: /run/topolvm/lvmd.sock\ndevice-classes: \n - default: true\n name: ssd\n spare-gb: 0\n volume-group: myvg1\n"
8+
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/bin/bash
2+
3+
set -eux
4+
5+
# Set KUBECONFIG path - use dynamic IP-based path
6+
KUBECONFIG=${KUBECONFIG:-/var/lib/microshift/resources/kubeadmin/kubeconfig}
7+
8+
ns="test-lvms"
9+
appLabel="app-lvms"
10+
11+
echo "INFO:" "Create Namespace, PVC and Deployment resources......"
12+
oc --kubeconfig "${KUBECONFIG}" create ns ${ns}
13+
14+
cat <<EOF | oc --kubeconfig "${KUBECONFIG}" -n ${ns} apply -f -
15+
kind: PersistentVolumeClaim
16+
apiVersion: v1
17+
metadata:
18+
name: mypvc-lvms
19+
spec:
20+
accessModes:
21+
- ReadWriteOnce
22+
storageClassName: topolvm-provisioner
23+
volumeMode: Filesystem
24+
resources:
25+
requests:
26+
storage: 1Mi
27+
---
28+
kind: Deployment
29+
apiVersion: apps/v1
30+
metadata:
31+
name: mydep-lvms
32+
spec:
33+
replicas: 1
34+
selector:
35+
matchLabels:
36+
app: ${appLabel}
37+
template:
38+
metadata:
39+
labels:
40+
app: ${appLabel}
41+
spec:
42+
containers:
43+
- name: http-server
44+
image: quay.io/openshifttest/hello-openshift@sha256:b1aabe8c8272f750ce757b6c4263a2712796297511e0c6df79144ee188933623
45+
ports:
46+
- name: httpd
47+
containerPort: 80
48+
volumeMounts:
49+
- name: local
50+
mountPath: /mnt/storage
51+
volumes:
52+
- name: local
53+
persistentVolumeClaim:
54+
claimName: mypvc-lvms
55+
EOF
56+
57+
echo "INFO:" "Check if deployment Pod is 'Running'......."
58+
iter=48
59+
period=5
60+
podName=""
61+
set +e
62+
while [[ "${podName=}" == "" && ${iter} -gt 0 ]]; do
63+
sleep ${period}
64+
podName=$(oc --kubeconfig "${KUBECONFIG}" get pod -n ${ns} -l app=${appLabel} --no-headers | awk '{print $1}')
65+
(( iter -- ))
66+
done
67+
if [ "${podName}" == "" ]; then
68+
echo "ERROR:" "Deployment Pod not found."
69+
exit 1
70+
fi
71+
echo "INFO:" "Waiting for Pod to become ready(max 4-minutes)....."
72+
iter=48
73+
result=""
74+
while [[ "${result}" != "Running" && ${iter} -gt 0 ]]; do
75+
#shellcheck disable=SC1083
76+
result=$(oc --kubeconfig "${KUBECONFIG}" get pod "${podName}" -n ${ns} -o=jsonpath={.status.phase})
77+
(( iter -- ))
78+
sleep ${period}
79+
done
80+
set -e
81+
if [ "${result}" == "Running" ]; then
82+
echo "INFO:" "Deployment Pod is Running."
83+
else
84+
echo "ERROR:" "Deployment Pod creation Failed."
85+
oc --kubeconfig "${KUBECONFIG}" -n ${ns} describe pod "${podName}"
86+
exit 1
87+
fi
88+
89+
echo "INFO:" "Check if data can be read/write into Pod mounted volume......."
90+
#shellcheck disable=SC2016
91+
oc --kubeconfig "${KUBECONFIG}" exec -n ${ns} "${podName}" -- /bin/sh -c 'echo Storage_Test $(date) > /mnt/storage/testfile'
92+
data=$(oc --kubeconfig "${KUBECONFIG}" exec -n ${ns} "${podName}" -- /bin/sh -c 'cat /mnt/storage/testfile')
93+
if [[ ${data} =~ "Storage_Test" ]]; then
94+
echo "SUCCESS:" "Data successfully written into Pod"
95+
else
96+
echo "ERROR:" "Failed to write data into the Pod"
97+
exit 1
98+
fi

0 commit comments

Comments
 (0)