Skip to content

Commit

Permalink
- Simplify LVM setup in test script
Browse files Browse the repository at this point in the history
- Keep all the test functions in single file (hack/ci/check.sh)
  • Loading branch information
Praveenrajmani authored and wlan0 committed Aug 24, 2021
1 parent 59e20c2 commit 7e01f9e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 115 deletions.
24 changes: 1 addition & 23 deletions .github/workflows/minikube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ jobs:
run: |
docker build -t quay.io/minio/direct-csi:${BUILD_TAG} .
- name: Setup lvms
run: |
sudo hack/ci/lvm-setup.sh
- name: Setup Minikube
uses: manusa/actions-setup-minikube@v2.4.2
with:
Expand All @@ -52,24 +48,6 @@ jobs:
kubectl get nodes
kubectl get pods -A
- name: Install direct-csi
run: |
./kubectl-direct_csi install --image "direct-csi:${BUILD_TAG}"
sleep 1m
kubectl describe pods -n direct-csi-min-io
- name: Check direct-csi
run: |
hack/ci/check.sh
- name: Uninstall direct-csi
run: |
./kubectl-direct_csi uninstall --crd --force
sleep 1m
kubectl get pods -n direct-csi-min-io
nscount=$(kubectl get ns | grep direct-csi-min-io | wc -l)
if [[ $nscount -gt 0 ]]
then
echo "direct-csi namespace not cleared up after uninstallation"
exit 1
fi
hack/ci/check.sh ${BUILD_TAG}
68 changes: 46 additions & 22 deletions hack/ci/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,82 @@

set -ex

function check_installation()
{
IMAGE_TAG="$1"

function setup_lvm() {
sudo truncate --size=1G disk-{1..4}.img
for disk in disk-{1..4}.img; do sudo losetup --find $disk; done
devices=( $(for disk in disk-{1..4}.img; do sudo losetup --noheadings --output NAME --associated $disk; done) )
sudo pvcreate "${devices[@]}"
vgname="test-vg-$RANDOM"
sudo vgcreate "$vgname" "${devices[@]}"
for i in {1..4}; do sudo lvcreate --size=800MiB "$vgname"; done
}

function install_directcsi() {
./kubectl-direct_csi install --image "direct-csi:${IMAGE_TAG}"
sleep 1m
kubectl describe pods -n direct-csi-min-io
./kubectl-direct_csi info
./kubectl-direct_csi drives list --all

if ! ./kubectl-direct_csi drives list | grep -q Available; then
./kubectl-direct_csi drives list -o wide --all
echo "No available disks found in the list"
exit 1
fi

./kubectl-direct_csi drives format --all
sleep 5
./kubectl-direct_csi drives list --all
./kubectl-direct_csi drives list -o wide --all
}

function deploy_minio()
{
function deploy_minio() {
kubectl apply -f hack/ci/minio.yaml
sleep 1m
kubectl get pods
kubectl get pods -o wide

runningpods=$(kubectl get pods --field-selector=status.phase=Running --no-headers | wc -l)
if [[ $runningpods -ne 4 ]]
then
if [[ $runningpods -ne 4 ]]; then
echo "MinIO deployment failed"
exit 1
fi
}

function uninstall_minio()
{
function uninstall_minio() {
kubectl delete -f hack/ci/minio.yaml
sleep 1m
kubectl delete pvc --all
sleep 1m
sleep 10s
./kubectl-direct_csi volumes ls
./kubectl-direct_csi drives ls --all

directcsivolumes=$(./kubectl-direct_csi volumes ls | wc -l)
if [[ $directcsivolumes -gt 1 ]]
then
if [[ $directcsivolumes -gt 1 ]]; then
echo "Volumes were not cleared upon deletion"
exit 1
fi

inusedrives=$(./kubectl-direct_csi drives ls | grep -q InUse | wc -l)
if [[ $inusedrives -gt 0 ]]
then
echo "Drives were not released upon volume deletion"
if ./kubectl-direct_csi drives ls | grep -q InUse; then
echo "disks are still inuse after clearing up volumes"
exit 1
fi
}

function uninstall_directcsi() {
./kubectl-direct_csi uninstall --crd --force
sleep 1m
kubectl get pods -n direct-csi-min-io
if kubectl get ns | grep -q direct-csi-min-io; then
echo "namespace not cleared upon uninstallation"
exit 1
fi
}

function main()
{
check_installation
function main() {
setup_lvm
install_directcsi
deploy_minio
uninstall_minio
uninstall_directcsi
}

main
61 changes: 0 additions & 61 deletions hack/ci/lvm-setup.sh

This file was deleted.

13 changes: 4 additions & 9 deletions hack/ci/minio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,31 @@ spec:
name: minio-data-1
spec:
accessModes: [ "ReadWriteOnce" ]
# selector: // claim Selector is not supported for dynamic provisioning
# matchLabels:
# direct.csi.min.io/access-tier: "Hot"
# matchExpressions:
# - {key: direct.csi.min.io/access-tier, operator: In, values: [Hot]}
resources:
requests:
storage: 5Mi
storage: 80Mi
storageClassName: direct-csi-min-io # This field references the existing StorageClass
- metadata:
name: minio-data-2
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 5Mi
storage: 80Mi
storageClassName: direct-csi-min-io # This field references the existing StorageClass
- metadata:
name: minio-data-3
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 5Mi
storage: 80Mi
storageClassName: direct-csi-min-io # This field references the existing StorageClass
- metadata:
name: minio-data-4
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 5Mi
storage: 80Mi
storageClassName: direct-csi-min-io # This field references the existing StorageClass

0 comments on commit 7e01f9e

Please sign in to comment.