diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/bug-1087203.t | 61 | ||||
| -rw-r--r-- | tests/bugs/bug-1112613.t | 49 | ||||
| -rwxr-xr-x | tests/snapshot.rc | 66 | 
3 files changed, 128 insertions, 48 deletions
diff --git a/tests/bugs/bug-1087203.t b/tests/bugs/bug-1087203.t index 585ecf440ac..e41d601fb66 100644 --- a/tests/bugs/bug-1087203.t +++ b/tests/bugs/bug-1087203.t @@ -5,50 +5,12 @@  . $(dirname $0)/../snapshot.rc  . $(dirname $0)/../cluster.rc -function config_validate () -{ -        local var=$1 -        $CLI_1 snapshot config | grep "^$var" | sed 's/.*: //' -} - -function snap_create () -{ -        local limit=$1; -        local i=0 -        while [ $i -lt $limit ] -        do -                $CLI_1 snapshot create snap$i ${V0} -                i=$[$i+1] -        done -} - -function snap_delete () -{ -        local limit=$1; -        local i=0 -        while [ $i -lt $limit ] -        do -                $CLI_1 snapshot delete snap$i -                i=$[$i+1] -        done -} - -function get_snap_count () -{ -        $CLI_1 snapshot list | wc -l -} -  function get_volume_info ()  {          local var=$1          $CLI_1 volume info $V0 | grep "^$var" | sed 's/.*: //'  } -function is_snapshot_present () -{ -        $CLI_1 snapshot list -} -  cleanup;  TEST verify_lvm_version @@ -94,7 +56,7 @@ TEST $CLI_1 snapshot config $V0 snap-max-hard-limit 10  # Validating auto-delete feature  # Make sure auto-delete is disabled by default -EXPECT 'disable' config_validate 'auto-delete' +EXPECT 'disable' snap_config CLI_1 'auto-delete'  # Test for invalid value for auto-delete  TEST ! $CLI_1 snapshot config auto-delete test @@ -103,36 +65,39 @@ TEST $CLI_1 snapshot config snap-max-hard-limit 6  TEST $CLI_1 snapshot config snap-max-soft-limit 50  # Create 4 snapshots -TEST snap_create 4; +snap_index=1 +snap_count=4 +TEST snap_create CLI_1 $V0 $snap_index $snap_count  # If auto-delete is disabled then oldest snapshot  # should not be deleted automatically. -EXPECT '4' get_snap_count; +EXPECT '4' get_snap_count CLI_1; -TEST snap_delete 4; +TEST snap_delete CLI_1 $snap_index $snap_count;  # After all those 4 snaps are deleted, There will not be any snaps present -EXPECT 'No snapshots present' is_snapshot_present; +EXPECT '0' get_snap_count CLI_1;  TEST $CLI_1 snapshot config auto-delete enable +  # auto-delete is already enabled, Hence expect a failure.  TEST ! $CLI_1 snapshot config auto-delete on  # Testing other boolean values with auto-delete  TEST $CLI_1 snapshot config auto-delete off -EXPECT 'off' config_validate 'auto-delete' +EXPECT 'off' snap_config CLI_1 'auto-delete'  TEST $CLI_1 snapshot config auto-delete true -EXPECT 'true' config_validate 'auto-delete' +EXPECT 'true' snap_config CLI_1 'auto-delete'  # Try to create 4 snaps again, As auto-delete is enabled  # oldest snap should be deleted and snapcount should be 3 -TEST snap_create 4; -EXPECT '3' get_snap_count; +TEST snap_create CLI_1 $V0 $snap_index $snap_count; +EXPECT '3' get_snap_count CLI_1;  TEST $CLI_1 snapshot config auto-delete disable -EXPECT 'disable' config_validate 'auto-delete' +EXPECT 'disable' snap_config CLI_1 'auto-delete'  cleanup; diff --git a/tests/bugs/bug-1112613.t b/tests/bugs/bug-1112613.t new file mode 100644 index 00000000000..17302eaa427 --- /dev/null +++ b/tests/bugs/bug-1112613.t @@ -0,0 +1,49 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../snapshot.rc +. $(dirname $0)/../cluster.rc + +cleanup; + +V1="patchy2" + +TEST verify_lvm_version; +TEST launch_cluster 2 +TEST setup_lvm 2 + +TEST $CLI_1 peer probe $H2 +EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count + +TEST $CLI_1 volume create $V0 $H1:$L1 +TEST $CLI_1 volume start $V0 +TEST $CLI_1 volume create $V1 $H2:$L2 +TEST $CLI_1 volume start $V1 + +# Create 3 snapshots for volume $V0 +snap_count=3 +snap_index=1 +TEST snap_create CLI_1 $V0 $snap_index $snap_count; + +# Create 3 snapshots for volume $V1 +snap_count=4 +snap_index=11 +TEST snap_create CLI_1 $V1 $snap_index $snap_count; + +EXPECT '3' get_snap_count CLI_1 $V0; +EXPECT '4' get_snap_count CLI_1 $V1; +EXPECT '7' get_snap_count CLI_1 + +TEST $CLI_1 snapshot delete volume $V0 +EXPECT '0' get_snap_count CLI_1 $V0; +EXPECT '4' get_snap_count CLI_1 $V1; +EXPECT '4' get_snap_count CLI_1 + +TEST $CLI_1 snapshot delete all +EXPECT '0' get_snap_count CLI_1 $V0; +EXPECT '0' get_snap_count CLI_1 $V1; +EXPECT '0' get_snap_count CLI_1 + +cleanup; + diff --git a/tests/snapshot.rc b/tests/snapshot.rc index a208fa3d410..408b5a72a0c 100755 --- a/tests/snapshot.rc +++ b/tests/snapshot.rc @@ -318,3 +318,69 @@ function volume_exists() {                  return 0          fi  } + +# arg-1 : From which node the command should be trigerred +#         Ex : $CLI_1, $CLI_2, etc. +# arg-2 : Volume name +# arg-3 : Starting index for the snapname "snap$i" +# arg-4 : Number of snapshots to be taken +function snap_create() +{ +        eval local cli_index=\$$1 +        local volname=$2 +        local i=$3 +        local limit=$[$i + $4] + +        while [ $i -lt $limit ] +        do +                $cli_index snapshot create snap$i $volname +                i=$[$i+1] +        done +} + +# arg-1 : From which node the command should be trigerred +#         Ex : $CLI_1. $CLI_2, etc. +# arg-2 : Volume name. +function get_snap_count() +{ +        eval local cli_index=\$$1 +        local volname=$2 + + +        if [ -z "$2" ] +        then +                $cli_index snapshot list | grep -v "No snapshots present"\ +                                         | wc -l +        else +                $cli_index snapshot list $volname\ +                                         | grep -v "No snapshots present"\ +                                         | wc -l +        fi +} + +# arg-1 : From which node the command should be trigerred +#         Ex : $CLI_1, $CLI_2, etc. +# arg-2 : Starting index for the snapname "snap$i" +# arg-3 : Number of snapshots to be deleted. +function snap_delete() +{ +        eval local cli_index=\$$1 +        local i=$2 +        local limit=$[$i + $3] + +        while [ $i -lt $limit ] +        do +                $cli_index snapshot delete snap$i +                i=$[$i+1] +        done +} + +# arg-1 : From which node the command should be triggered +#         Ex : $CLI_1, $CLI_2, etc. +# arg-2 : key value +function snap_config() +{ +        eval local cli_index=\$$1 +        local var=$2 +        $cli_index snapshot config | grep "^$var" | sed 's/.*: //' +}  | 
