glusterd: Added validation function for stripe-block-size.
Change-Id: I050d01b01eac46550aa435da7d96a972e0393d35 BUG: 770655 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/4561 Reviewed-by: Jeff Darcy <jdarcy@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
This commit is contained in:
parent
202bcaee24
commit
4579609e33
168
tests/bugs/bug-770655.t
Executable file
168
tests/bugs/bug-770655.t
Executable file
@ -0,0 +1,168 @@
|
||||
#!/bin/bash
|
||||
|
||||
. $(dirname $0)/../include.rc
|
||||
. $(dirname $0)/../volume.rc
|
||||
|
||||
cleanup;
|
||||
|
||||
## Start and create a distribute-replicate volume
|
||||
TEST glusterd;
|
||||
TEST pidof glusterd;
|
||||
TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2,3,4,5,6,7,8};
|
||||
|
||||
## Verify volume is created
|
||||
EXPECT "$V0" volinfo_field $V0 'Volume Name';
|
||||
EXPECT 'Created' volinfo_field $V0 'Status';
|
||||
EXPECT 'Distributed-Replicate' volinfo_field $V0 'Type';
|
||||
|
||||
## Start volume and verify
|
||||
TEST $CLI volume start $V0;
|
||||
EXPECT 'Started' volinfo_field $V0 'Status';
|
||||
|
||||
## Setting stripe-block-size as 10MB
|
||||
TEST ! $CLI volume set $V0 stripe-block-size 10MB
|
||||
EXPECT '' volinfo_field $V0 'cluster.stripe-block-size';
|
||||
|
||||
## Finish up
|
||||
TEST $CLI volume stop $V0;
|
||||
EXPECT 'Stopped' volinfo_field $V0 'Status';
|
||||
|
||||
TEST $CLI volume delete $V0;
|
||||
TEST ! $CLI volume info $V0;
|
||||
|
||||
cleanup;
|
||||
|
||||
## Start and create a replicate volume
|
||||
TEST glusterd;
|
||||
TEST pidof glusterd;
|
||||
TEST $CLI volume create $V0 replica 8 $H0:$B0/${V0}{1,2,3,4,5,6,7,8};
|
||||
|
||||
## Verify volume is created
|
||||
EXPECT "$V0" volinfo_field $V0 'Volume Name';
|
||||
EXPECT 'Created' volinfo_field $V0 'Status';
|
||||
EXPECT 'Replicate' volinfo_field $V0 'Type';
|
||||
|
||||
## Start volume and verify
|
||||
TEST $CLI volume start $V0;
|
||||
EXPECT 'Started' volinfo_field $V0 'Status';
|
||||
|
||||
## Setting stripe-block-size as 10MB
|
||||
TEST ! $CLI volume set $V0 stripe-block-size 10MB
|
||||
EXPECT '' volinfo_field $V0 'cluster.stripe-block-size';
|
||||
|
||||
## Finish up
|
||||
TEST $CLI volume stop $V0;
|
||||
EXPECT 'Stopped' volinfo_field $V0 'Status';
|
||||
|
||||
TEST $CLI volume delete $V0;
|
||||
TEST ! $CLI volume info $V0;
|
||||
|
||||
cleanup;
|
||||
|
||||
## Start and create a distribute volume
|
||||
TEST glusterd;
|
||||
TEST pidof glusterd;
|
||||
TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2,3,4,5,6,7,8};
|
||||
|
||||
## Verify volume is created
|
||||
EXPECT "$V0" volinfo_field $V0 'Volume Name';
|
||||
EXPECT 'Created' volinfo_field $V0 'Status';
|
||||
EXPECT 'Distribute' volinfo_field $V0 'Type';
|
||||
|
||||
## Start volume and verify
|
||||
TEST $CLI volume start $V0;
|
||||
EXPECT 'Started' volinfo_field $V0 'Status';
|
||||
|
||||
## Setting stripe-block-size as 10MB
|
||||
TEST ! $CLI volume set $V0 stripe-block-size 10MB
|
||||
EXPECT '' volinfo_field $V0 'cluster.stripe-block-size';
|
||||
|
||||
## Finish up
|
||||
TEST $CLI volume stop $V0;
|
||||
EXPECT 'Stopped' volinfo_field $V0 'Status';
|
||||
|
||||
TEST $CLI volume delete $V0;
|
||||
TEST ! $CLI volume info $V0;
|
||||
|
||||
cleanup;
|
||||
|
||||
## Start and create a stripe volume
|
||||
TEST glusterd;
|
||||
TEST pidof glusterd;
|
||||
TEST $CLI volume create $V0 stripe 8 $H0:$B0/${V0}{1,2,3,4,5,6,7,8};
|
||||
|
||||
## Verify volume is created
|
||||
EXPECT "$V0" volinfo_field $V0 'Volume Name';
|
||||
EXPECT 'Created' volinfo_field $V0 'Status';
|
||||
EXPECT 'Stripe' volinfo_field $V0 'Type';
|
||||
|
||||
## Start volume and verify
|
||||
TEST $CLI volume start $V0;
|
||||
EXPECT 'Started' volinfo_field $V0 'Status';
|
||||
|
||||
## Setting stripe-block-size as 10MB
|
||||
TEST $CLI volume set $V0 stripe-block-size 10MB
|
||||
EXPECT '10MB' volinfo_field $V0 'cluster.stripe-block-size';
|
||||
|
||||
## Finish up
|
||||
TEST $CLI volume stop $V0;
|
||||
EXPECT 'Stopped' volinfo_field $V0 'Status';
|
||||
|
||||
TEST $CLI volume delete $V0;
|
||||
TEST ! $CLI volume info $V0;
|
||||
|
||||
cleanup;
|
||||
|
||||
## Start and create a distributed stripe volume
|
||||
TEST glusterd;
|
||||
TEST pidof glusterd;
|
||||
TEST $CLI volume create $V0 stripe 4 $H0:$B0/${V0}{1,2,3,4,5,6,7,8};
|
||||
|
||||
## Verify volume is created
|
||||
EXPECT "$V0" volinfo_field $V0 'Volume Name';
|
||||
EXPECT 'Created' volinfo_field $V0 'Status';
|
||||
EXPECT 'Distributed-Stripe' volinfo_field $V0 'Type';
|
||||
|
||||
## Start volume and verify
|
||||
TEST $CLI volume start $V0;
|
||||
EXPECT 'Started' volinfo_field $V0 'Status';
|
||||
|
||||
## Setting stripe-block-size as 10MB
|
||||
TEST $CLI volume set $V0 stripe-block-size 10MB
|
||||
EXPECT '10MB' volinfo_field $V0 'cluster.stripe-block-size';
|
||||
|
||||
## Finish up
|
||||
TEST $CLI volume stop $V0;
|
||||
EXPECT 'Stopped' volinfo_field $V0 'Status';
|
||||
|
||||
TEST $CLI volume delete $V0;
|
||||
TEST ! $CLI volume info $V0;
|
||||
|
||||
cleanup;
|
||||
|
||||
## Start and create a distributed stripe replicate volume
|
||||
TEST glusterd;
|
||||
TEST pidof glusterd;
|
||||
TEST $CLI volume create $V0 stripe 2 replica 2 $H0:$B0/${V0}{1,2,3,4,5,6,7,8};
|
||||
|
||||
## Verify volume is created
|
||||
EXPECT "$V0" volinfo_field $V0 'Volume Name';
|
||||
EXPECT 'Created' volinfo_field $V0 'Status';
|
||||
EXPECT 'Distributed-Striped-Replicate' volinfo_field $V0 'Type';
|
||||
|
||||
## Start volume and verify
|
||||
TEST $CLI volume start $V0;
|
||||
EXPECT 'Started' volinfo_field $V0 'Status';
|
||||
|
||||
## Setting stripe-block-size as 10MB
|
||||
TEST $CLI volume set $V0 stripe-block-size 10MB
|
||||
EXPECT '10MB' volinfo_field $V0 'cluster.stripe-block-size';
|
||||
|
||||
## Finish up
|
||||
TEST $CLI volume stop $V0;
|
||||
EXPECT 'Stopped' volinfo_field $V0 'Status';
|
||||
|
||||
TEST $CLI volume delete $V0;
|
||||
TEST ! $CLI volume info $V0;
|
||||
|
||||
cleanup;
|
@ -94,7 +94,7 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
validate_cache_max_min_size (dict_t *dict, char *key, char *value,
|
||||
char **op_errstr)
|
||||
{
|
||||
@ -208,6 +208,44 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
validate_stripe (dict_t *dict, char *key, char *value, char **op_errstr)
|
||||
{
|
||||
char errstr[2048] = "";
|
||||
char *volname = NULL;
|
||||
glusterd_conf_t *priv = NULL;
|
||||
glusterd_volinfo_t *volinfo = NULL;
|
||||
int ret = 0;
|
||||
xlator_t *this = NULL;
|
||||
|
||||
this = THIS;
|
||||
GF_ASSERT (this);
|
||||
priv = this->private;
|
||||
GF_ASSERT (priv);
|
||||
|
||||
ret = check_dict_key_value (dict, key, value);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = get_volname_volinfo (dict, &volname, &volinfo);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
if (volinfo->stripe_count == 1) {
|
||||
snprintf (errstr, sizeof (errstr),
|
||||
"Cannot set %s for a non-stripe volume.", key);
|
||||
gf_log (this->name, GF_LOG_ERROR, "%s", errstr);
|
||||
*op_errstr = gf_strdup (errstr);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* dispatch table for VOLUME SET
|
||||
* -----------------------------
|
||||
*
|
||||
@ -417,7 +455,8 @@ struct volopt_map_entry glusterd_volopt_map[] = {
|
||||
{ .key = "cluster.stripe-block-size",
|
||||
.voltype = "cluster/stripe",
|
||||
.option = "block-size",
|
||||
.op_version = 1
|
||||
.op_version = 1,
|
||||
.validate_fn = validate_stripe
|
||||
},
|
||||
{ .key = "cluster.stripe-coalesce",
|
||||
.voltype = "cluster/stripe",
|
||||
|
Loading…
x
Reference in New Issue
Block a user