diff options
author | Sachin Pandit <spandit@redhat.com> | 2014-06-11 09:03:16 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-06-13 02:12:29 -0700 |
commit | 10cd2bc38e1f0a1297d59c0791a85ed9d01c93ff (patch) | |
tree | e7230795e97b668c04011fa018597aae0619ef10 /tests | |
parent | 6ba178fd9ebf9fc98415c30bcd338a68ee5eb601 (diff) |
glusterd/snapshot : Provide enable/disable option for snapshot auto-delete feature.
This patch provides an interface to enable or disable
the auto-delete feature.
Syntax : gluster snapshot config auto-delete <enable/disable>
DETAILS :
1) When auto-delete feature is disabled, If the the soft-limit is
reached then user is given a warning about exceeding soft-limit
along with successful snapshot creation message (oldest snapshot is
not deleted). And upon reaching hard-limit further snapshot creation
is not allowed.
Example :
------------------------------------------------------------------
|Case - 1: Upon reaching soft-limit
|
|Snapshot create : snap successfully created.
|Warning : soft-limit of volume (vol) is reached. Snapshot creation
|is not possible once hard-limit is reached.
|
|-----------------------------------------------------
|Case - 2: Upon reaching hard-limit
|
|Snapshot create : snap creation failed.
|Error : hard-limit of volume (vol) is reached, Hence it is not
|possible to take further snapshots. Please delete few snapshots
|of the volume (vol) before taking another snapshot.
------------------------------------------------------------------
2) When auto-delete feature is enabled, then as soon as the soft-limit
is reached the oldest snapshot is deleted for every successful snapshot
creation (same as existing method), With this it is made sure that
number of snapshot created is not more than snap-max-hard-limit.
Change-Id: Ie3ca64bbd2c763371f541cd2e378314e73b695b4
BUG: 1105415
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Reviewed-on: http://review.gluster.org/8017
Tested-by: Justin Clift <justin@gluster.org>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bugs/bug-1087203.t | 127 |
1 files changed, 105 insertions, 22 deletions
diff --git a/tests/bugs/bug-1087203.t b/tests/bugs/bug-1087203.t index acbb826013d..8926274dac7 100644 --- a/tests/bugs/bug-1087203.t +++ b/tests/bugs/bug-1087203.t @@ -2,45 +2,128 @@ . $(dirname $0)/../include.rc . $(dirname $0)/../volume.rc +. $(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 glusterd; -TEST $CLI volume info; +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 volume create $V0 replica 2 $H0:$B0/${V0}-{0,1}; -EXPECT "$V0" volinfo_field $V0 'Volume Name'; -EXPECT 'Created' volinfo_field $V0 'Status'; +TEST $CLI_1 volume create $V0 $H1:$L1 $H2:$L2 +EXPECT "$V0" get_volume_info 'Volume Name'; +EXPECT 'Created' get_volume_info 'Status'; -TEST $CLI volume start $V0 -EXPECT 'Started' volinfo_field $V0 'Status'; +TEST $CLI_1 volume start $V0 +EXPECT 'Started' get_volume_info 'Status'; # Setting system limit -TEST $CLI snapshot config snap-max-hard-limit 100 +TEST $CLI_1 snapshot config snap-max-hard-limit 100 # Volume limit cannot exceed system limit, as limit is set to 100, # this should fail. -TEST ! $CLI snapshot config $V0 snap-max-hard-limit 101 +TEST ! $CLI_1 snapshot config $V0 snap-max-hard-limit 101 # Following are the invalid cases -TEST ! $CLI snapshot config $V0 snap-max-hard-limit a10 -TEST ! $CLI snapshot config snap-max-hard-limit 10a -TEST ! $CLI snapshot config snap-max-hard-limit 10% -TEST ! $CLI snapshot config snap-max-soft-limit 50%1 -TEST ! $CLI snapshot config snap-max-soft-limit 0111 -TEST ! $CLI snapshot config snap-max-hard-limit OXA -TEST ! $CLI snapshot config snap-max-hard-limit 11.11 -TEST ! $CLI snapshot config snap-max-soft-limit 50% -TEST ! $CLI snapshot config snap-max-hard-limit -100 -TEST ! $CLI snapshot config snap-max-soft-limit -90 +TEST ! $CLI_1 snapshot config $V0 snap-max-hard-limit a10 +TEST ! $CLI_1 snapshot config snap-max-hard-limit 10a +TEST ! $CLI_1 snapshot config snap-max-hard-limit 10% +TEST ! $CLI_1 snapshot config snap-max-soft-limit 50%1 +TEST ! $CLI_1 snapshot config snap-max-soft-limit 0111 +TEST ! $CLI_1 snapshot config snap-max-hard-limit OXA +TEST ! $CLI_1 snapshot config snap-max-hard-limit 11.11 +TEST ! $CLI_1 snapshot config snap-max-soft-limit 50% +TEST ! $CLI_1 snapshot config snap-max-hard-limit -100 +TEST ! $CLI_1 snapshot config snap-max-soft-limit -90 # Soft limit cannot be assigned to volume -TEST ! $CLI snapshot config $V0 snap-max-soft-limit 10 +TEST ! $CLI_1 snapshot config $V0 snap-max-soft-limit 10 # Valid case -TEST $CLI snapshot config snap-max-soft-limit 50 -TEST $CLI snapshot config $V0 snap-max-hard-limit 10 +TEST $CLI_1 snapshot config snap-max-soft-limit 50 +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' + +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; + +# If auto-delete is disabled then oldest snapshot +# should not be deleted automatically. +EXPECT '4' get_snap_count; + +TEST snap_delete 4; + +# After all those 4 snaps are deleted, There will not be any snaps present +EXPECT 'No snapshots present' is_snapshot_present; + +TEST $CLI_1 snapshot config auto-delete enable +# auto-delete is already enabled, Hence expect a failure. +TEST ! $CLI_1 snapshot config auto-delete enable +EXPECT 'enable' config_validate '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 $CLI_1 snapshot config auto-delete disable +EXPECT 'disable' config_validate 'auto-delete' cleanup; |