diff options
author | Prasanna Kumar Kalever <prasanna.kalever@redhat.com> | 2017-02-10 15:03:04 +0530 |
---|---|---|
committer | Prasanna Kumar Kalever <prasanna.kalever@redhat.com> | 2017-02-10 15:07:16 +0530 |
commit | 925dae9944160dc8a4d42704db3ff10332f8c88f (patch) | |
tree | 1aff172ed9c4aebbaadeda1013dc81deb9fe6463 /tests/basic.t | |
parent | d1943660a29bda2ae6f020bb621c2ff0f44b6ec3 (diff) |
tests: add basic test script
Make sure you have all the dependent binaries
Run:
$ ./tests/basic.t
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Diffstat (limited to 'tests/basic.t')
-rwxr-xr-x | tests/basic.t | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/basic.t b/tests/basic.t new file mode 100755 index 0000000..1897d12 --- /dev/null +++ b/tests/basic.t @@ -0,0 +1,88 @@ +#!/bin/env bash +#********************************************************************# +# # +# Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com> # +# This file is part of gluster-block. # +# # +# This file is licensed to you under your choice of the GNU Lesser # +# General Public License, version 3 or any later version (LGPLv3 or # +# later), or the GNU General Public License, version 2 (GPLv2), in # +# all cases as published by the Free Software Foundation. # +# # +# # +# Run: (Make sure you have all the dependent binaries installed) # +# $ ./tests/basic.t # +# # +#********************************************************************# + + +HOST=$(hostname) +VOLNAME="block-test" +BLKNAME="sample-block" +BRKDIR="/tmp/block/" + + +function TEST() +{ + + echo "TEST : $@" + eval $@ + if [ $? -ne 0 ]; then + echo -e "line $(caller | awk '{print $1}') : NOT OK\n" + exit 1; + fi + echo -e "line $(caller | awk '{print $1}') : OK\n" +} + + +function cleanup() +{ + echo -e "\nRunning test cleanup ..." + + # Block delete + gluster-block delete ${BLKNAME} volume ${VOLNAME} + + gluster --mode=script vol stop ${VOLNAME} + gluster --mode=script vol del ${VOLNAME} + + rm -rf ${BRKDIR} +} + + +function force_terminate () { + local ret=$?; + >&2 echo -e "\nreceived external"\ + "signal --$(kill -l $ret)--, calling 'cleanup' ...\n"; + cleanup; + exit $ret; +} + + +trap force_terminate INT TERM HUP + +pidof glusterd 2>&1 >/dev/null +if [ $? -eq 1 ]; then + TEST glusterd +fi + +# Create gluster volume +TEST gluster vol create ${VOLNAME} ${HOST}:${BRKDIR} force + +# Start the volume +TEST gluster vol start ${VOLNAME} + +# Start gluster-blockd.service +systemctl daemon-reload +TEST systemctl restart gluster-blockd.service +sleep 1; + +# Block create +TEST gluster-block create ${BLKNAME} volume ${VOLNAME} volserver ${HOST} mpath 1 size 1GiB servers ${HOST} + +# Block list +TEST gluster-block list volume ${VOLNAME} + +# Block info +TEST gluster-block info ${BLKNAME} volume ${VOLNAME} + +cleanup; |