diff options
-rwxr-xr-x | tests/bugs/bug-861945.t | 51 | ||||
-rw-r--r-- | tests/include.rc | 17 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-geo-rep.c | 10 |
3 files changed, 77 insertions, 1 deletions
diff --git a/tests/bugs/bug-861945.t b/tests/bugs/bug-861945.t new file mode 100755 index 00000000000..29ccb33c8b1 --- /dev/null +++ b/tests/bugs/bug-861945.t @@ -0,0 +1,51 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc + +cleanup; + +function georep_start_and_check() +{ + local master=$1 + local slave=$2 + + $CLI volume geo-replication $master $slave start +} + +function georep_stop() +{ + local master=$1 + local slave=$2 + + $CLI volume geo-replication $master $slave stop +} + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 $H0:$B0/brick0 $H0:$B0/brick1 +TEST $CLI volume start $V0 + +sleep 5 + +slave=`mktemp -d` +mkdir -p $slave + +# check normal functionality of geo-replication +EXPECT_KEYWORD "successful" georep_start_and_check $V0 $slave +TEST georep_stop $V0 $slave + +# now invoke replace brick +TEST $CLI volume replace-brick $V0 $H0:$B0/brick1 $H0:$B0/brick2 start + +# check if CLI refuses to start geo replication +EXPECT_KEYWORD "failed" georep_start_and_check $V0 $slave + +# commit replace brick operation +TEST $CLI volume replace-brick $V0 $H0:$B0/brick1 $H0:$B0/brick2 commit + +# geo replication should work as usual +EXPECT_KEYWORD "successful" georep_start_and_check $V0 $slave +TEST georep_stop $V0 $slave + +rm -rf $slave +cleanup diff --git a/tests/include.rc b/tests/include.rc index b572fbc6379..7877bd5c129 100644 --- a/tests/include.rc +++ b/tests/include.rc @@ -13,7 +13,7 @@ mkdir -p $B0; mkdir -p $M0 $M1; mkdir -p $N0 $N1; -testcnt=`egrep '^[ \t]*(EXPECT|TEST|EXPECT_WITHIN)' $0 | wc -l`; +testcnt=`egrep '^[ \t]*(EXPECT|TEST|EXPECT_WITHIN|EXPECT_KEYWORD)' $0 | wc -l`; echo 1..$testcnt t=1 @@ -64,6 +64,20 @@ function _EXPECT() test_footer; } +function _EXPECT_KEYWORD() +{ + TESTLINE=$1; + shift; + + test_header "$@"; + + e="$1"; + shift; + "$@" | tail -1 | grep -q "$e" + + test_footer; +} + function _TEST() { @@ -128,4 +142,5 @@ function cleanup() alias EXPECT='_EXPECT $LINENO' alias TEST='_TEST $LINENO' alias EXPECT_WITHIN='_EXPECT_WITHIN $LINENO' +alias EXPECT_KEYWORD='_EXPECT_KEYWORD $LINENO' shopt -s expand_aliases diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c index eeb8e940db8..419f3ad025b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c @@ -1184,6 +1184,16 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr) switch (type) { case GF_GSYNC_OPTION_TYPE_START: + /* don't attempt to start gsync if replace-brick is + * in progress */ + if (glusterd_is_rb_ongoing (volinfo)) { + snprintf (errmsg, sizeof(errmsg),"replace-brick is in" + " progress, not starting geo-replication"); + *op_errstr = gf_strdup (errmsg); + ret = -1; + goto out; + } + ret = glusterd_op_verify_gsync_start_options (volinfo, slave, op_errstr); if (ret) |