summaryrefslogtreecommitdiffstats
path: root/tests/snapshot.rc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/snapshot.rc')
-rw-r--r--[-rwxr-xr-x]tests/snapshot.rc80
1 files changed, 69 insertions, 11 deletions
diff --git a/tests/snapshot.rc b/tests/snapshot.rc
index e893748eb9e..f6da514f826 100755..100644
--- a/tests/snapshot.rc
+++ b/tests/snapshot.rc
@@ -3,7 +3,7 @@
LVM_DEFINED=0
LVM_PREFIX="patchy_snap"
LVM_COUNT=0
-VHD_SIZE="1G"
+VHD_SIZE="300M"
#This function will init B# bricks
#This is used when launch_cluster is
@@ -16,6 +16,10 @@ function init_n_bricks() {
done
}
+count_snaps () {
+ ls $1/.snaps | wc -l
+}
+
function init_lvm() {
if [ "$1" == "" ]; then
echo "Error: Invalid argument supplied"
@@ -90,6 +94,11 @@ function cleanup_lvm() {
return 0
}
+# Find out how this file was sourced, source traps.rc the same way, and use
+# push_trapfunc to make sure cleanup_lvm gets called before we exit.
+. $(dirname ${BASH_SOURCE[0]})/traps.rc
+push_trapfunc cleanup_lvm
+
########################################################
# Private Functions
########################################################
@@ -123,7 +132,7 @@ function _cleanup_lvm() {
function _cleanup_lvm_again() {
local file
- mount | grep $LVM_PREFIX | awk '{print $3}' | xargs -r umount -f
+ mount | grep $LVM_PREFIX | awk '{print $3}' | xargs -r ${UMOUNT_F}
/sbin/vgs | grep $LVM_PREFIX | awk '{print $1}' | xargs -r vgremove -f
@@ -154,8 +163,8 @@ function _create_lv() {
local dir=$1
local num=$2
local vg="VG$num"
- local thinpoolsize="0.8G"
- local virtualsize="0.6G"
+ local thinpoolsize="200M"
+ local virtualsize="150M"
/sbin/pvcreate $dir/${LVM_PREFIX}_loop
/sbin/vgcreate ${!vg} $dir/${LVM_PREFIX}_loop
@@ -178,7 +187,7 @@ function _umount_lv() {
local num=$1
local l="L$num"
- umount -f ${!l} 2>/dev/null || true
+ ${UMOUNT_F} ${!l} 2>/dev/null || true
rmdir ${!l} 2>/dev/null || true
}
@@ -228,7 +237,7 @@ function create_n_snapshots() {
local snap_name=$3
local ret=0
for i in `seq 1 $snap_count`; do
- $CLI_1 snapshot create $snap_name$i ${vol}&
+ $CLI_1 snapshot create $snap_name$i ${vol} no-timestamp &
PID_1=$!
wait $PID_1
ret=$?
@@ -303,6 +312,33 @@ function snapshot_status()
}
+#Check the different status of a particular snapshot
+#Arg1 : <Snap name>
+#Arg2 : <Filed in status>
+#Arg3 : <Expected value>
+function snapshot_snap_status()
+{
+
+ local snap=$1;
+ local cli=$CLI_1;
+ local field=$2;
+ local expected=$3;
+ if [ "$cli" = "" ]; then
+ cli=$CLI
+ fi
+ for i in $($cli snapshot status $snap | grep "$field" | \
+ cut -d ':' -f2 | awk '{print $1}') ;
+ do
+ if [ "$i" != "$expected" ]; then
+ echo "Failed"
+ return 1;
+ fi;
+ done;
+echo "Success"
+return 0;
+}
+
+
# TODO: Cleanup code duplication
function volinfo_field()
{
@@ -314,12 +350,11 @@ function volinfo_field()
function volume_exists() {
- local volname=$1
- $CLI_1 volume info $volname 2>&1 | grep -q 'does not exist'
+ $CLI_1 volume info $1 > /dev/null 2>&1
if [ $? -eq 0 ]; then
- return 1
+ echo "Y"
else
- return 0
+ echo "N"
fi
}
@@ -337,7 +372,7 @@ function snap_create()
while [ $i -lt $limit ]
do
- $cli_index snapshot create snap$i $volname
+ $cli_index snapshot create snap$i $volname no-timestamp
i=$[$i+1]
done
}
@@ -401,6 +436,22 @@ function uss_count_snap_displayed() {
ls $path/.snaps | wc -l
}
+function snap_info_volume()
+{
+ eval local cli_index=\$$1
+ local var=$2
+ local vol=$3
+ $cli_index snapshot info volume $vol | grep "^$var" | sed 's/.*: //'
+}
+
+function snap_config_volume()
+{
+ eval local cli_index=\$$1
+ local var=$2
+ local vol=$3
+ $cli_index snapshot config $vol| grep "^$var" | sed 's/.*: //'
+}
+
#return specific fields of xml output
function get-cmd-field-xml()
{
@@ -415,6 +466,13 @@ function get-cmd-field-xml()
$cli $COMMAND --xml | xmllint --format - | grep $PATTERN
}
+function get_snap_brick_status()
+{
+ local snap=$1;
+
+ $CLI snapshot status $snap | grep "Brick Running" | sed 's/.*: //';
+}
+
case $OSTYPE in
NetBSD)
echo "Skip test on LVM which is not available on NetBSD" >&2