Skip to content
Open
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
4 changes: 3 additions & 1 deletion .github/actions/build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ runs:
make run-ready
make run-healthy

# Run a test to verify that TopoLVM is functioning properly
make env "CMD=./src/topolvm/tests/createWorkloads.sh"

for i in $(seq 2 ${{ inputs.node-count }}); do
make add-node
done
Expand All @@ -113,7 +116,6 @@ runs:
# Clean is necessary to avoid conflicts with other actions that may
# potentially run in subsequent actions
make clean

# Uncomment this to enable tmate-debug on failure
# - name: Pause and open tmate debug session
# if: failure()
Expand Down
1 change: 1 addition & 0 deletions src/topolvm/assets/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ resources:
patches:
- path: topolvm_mutatingwebhook_patch.yaml
- path: topolvm_service_patch.yaml
- path: topolvm_configmap-lvmd_patch.yaml
8 changes: 8 additions & 0 deletions src/topolvm/assets/topolvm_configmap-lvmd_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: topolvm-lvmd-0
namespace: topolvm-system
data:
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"

12 changes: 12 additions & 0 deletions src/topolvm/generate_manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ metadata:
annotations:
service.beta.openshift.io/serving-cert-secret-name: topolvm-mutatingwebhook
EOF
# lvmd configmap patch to override the spare-db:0
cat >"${ASSETS_DIR}/topolvm_configmap-lvmd_patch.yaml" <<'EOF'
apiVersion: v1
kind: ConfigMap
metadata:
name: topolvm-lvmd-0
namespace: topolvm-system
data:
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"
EOF


# Generate kustomize
cat >"${ASSETS_DIR}/kustomization.yaml" <<'EOF'
Expand All @@ -103,6 +114,7 @@ resources:
patches:
- path: topolvm_mutatingwebhook_patch.yaml
- path: topolvm_service_patch.yaml
- path: topolvm_configmap-lvmd_patch.yaml
EOF
}

Expand Down
98 changes: 98 additions & 0 deletions src/topolvm/tests/createWorkloads.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash

set -eux

# Set KUBECONFIG path - use dynamic IP-based path
KUBECONFIG=${KUBECONFIG:-/var/lib/microshift/resources/kubeadmin/kubeconfig}

ns="test-lvms"
appLabel="app-lvms"

echo "INFO:" "Create Namespace, PVC and Deployment resources......"
oc --kubeconfig "${KUBECONFIG}" create ns ${ns}

cat <<EOF | oc --kubeconfig "${KUBECONFIG}" -n ${ns} apply -f -
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mypvc-lvms
spec:
accessModes:
- ReadWriteOnce
storageClassName: topolvm-provisioner
volumeMode: Filesystem
resources:
requests:
storage: 1Mi
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: mydep-lvms
spec:
replicas: 1
selector:
matchLabels:
app: ${appLabel}
template:
metadata:
labels:
app: ${appLabel}
spec:
containers:
- name: http-server
image: quay.io/openshifttest/hello-openshift@sha256:b1aabe8c8272f750ce757b6c4263a2712796297511e0c6df79144ee188933623
ports:
- name: httpd
containerPort: 80
volumeMounts:
- name: local
mountPath: /mnt/storage
volumes:
- name: local
persistentVolumeClaim:
claimName: mypvc-lvms
EOF

echo "INFO:" "Check if deployment Pod is 'Running'......."
iter=48
period=5
podName=""
set +e
while [[ "${podName=}" == "" && ${iter} -gt 0 ]]; do
sleep ${period}
podName=$(oc --kubeconfig "${KUBECONFIG}" get pod -n ${ns} -l app=${appLabel} --no-headers | awk '{print $1}')
(( iter -- ))
done
if [ "${podName}" == "" ]; then
echo "ERROR:" "Deployment Pod not found."
exit 1
fi
echo "INFO:" "Waiting for Pod to become ready(max 4-minutes)....."
iter=48
result=""
while [[ "${result}" != "Running" && ${iter} -gt 0 ]]; do
#shellcheck disable=SC1083
result=$(oc --kubeconfig "${KUBECONFIG}" get pod "${podName}" -n ${ns} -o=jsonpath={.status.phase})
(( iter -- ))
sleep ${period}
done
set -e
if [ "${result}" == "Running" ]; then
echo "INFO:" "Deployment Pod is Running."
else
echo "ERROR:" "Deployment Pod creation Failed."
oc --kubeconfig "${KUBECONFIG}" -n ${ns} describe pod "${podName}"
exit 1
fi

echo "INFO:" "Check if data can be read/write into Pod mounted volume......."
#shellcheck disable=SC2016
oc --kubeconfig "${KUBECONFIG}" exec -n ${ns} "${podName}" -- /bin/sh -c 'echo Storage_Test $(date) > /mnt/storage/testfile'
data=$(oc --kubeconfig "${KUBECONFIG}" exec -n ${ns} "${podName}" -- /bin/sh -c 'cat /mnt/storage/testfile')
if [[ ${data} =~ "Storage_Test" ]]; then
echo "SUCCESS:" "Data successfully written into Pod"
else
echo "ERROR:" "Failed to write data into the Pod"
exit 1
fi
Loading