summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-rpc-ops.c47
-rwxr-xr-xtests/basic/tier/bug-1214222-directories_miising_after_attach_tier.t67
-rwxr-xr-xtests/basic/tier/tier.t18
-rw-r--r--tests/bugs/tier/bug-1205545-CTR-and-trash-integration.t2
4 files changed, 122 insertions, 12 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 49c8761bbab..e45baa062a1 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -3894,9 +3894,17 @@ int32_t
gf_cli_attach_tier (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf_cli_req req = {{0,} };
- int ret = 0;
- dict_t *dict = NULL;
+ gf_cli_req req = {{0,} };
+ int ret = 0;
+ dict_t *dict = NULL;
+ dict_t *newdict = NULL;
+ char *tierwords[] = {"volume", "rebalance", "",
+ "tier", "start", NULL};
+ const char **words = (const char **)tierwords;
+ int wordcount = 5;
+ char *volname = NULL;
+ cli_local_t *local = NULL;
+ cli_local_t *oldlocal = NULL;
if (!frame || !this || !data) {
ret = -1;
@@ -3912,6 +3920,39 @@ gf_cli_attach_tier (call_frame_t *frame, xlator_t *this,
(xdrproc_t) xdr_gf_cli_req, dict,
GLUSTER_CLI_ATTACH_TIER, this,
cli_rpc_prog, NULL);
+ if (ret)
+ goto out;
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to get volume name");
+ goto notify_cli;
+ }
+
+ words[2] = volname;
+ ret = cli_cmd_volume_defrag_parse ((const char **)words,
+ wordcount, &newdict);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to parse tier start "
+ "command");
+ goto notify_cli;
+ }
+
+ gf_log ("cli", GF_LOG_DEBUG, "Sending tier start");
+
+ oldlocal = frame->local;
+ CLI_LOCAL_INIT (local, words, frame, newdict);
+ ret = gf_cli_defrag_volume (frame, this, newdict);
+ frame->local = oldlocal;
+ cli_local_wipe (local);
+
+notify_cli:
+ if (ret) {
+ cli_out ("Failed to run tier start. Please execute tier start "
+ "command explictly");
+ cli_out ("Usage : gluster volume rebalance <volname> tier "
+ "start");
+ }
+
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
diff --git a/tests/basic/tier/bug-1214222-directories_miising_after_attach_tier.t b/tests/basic/tier/bug-1214222-directories_miising_after_attach_tier.t
new file mode 100755
index 00000000000..028bc6a47d0
--- /dev/null
+++ b/tests/basic/tier/bug-1214222-directories_miising_after_attach_tier.t
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+
+LAST_BRICK=3
+CACHE_BRICK_FIRST=4
+CACHE_BRICK_LAST=5
+DEMOTE_TIMEOUT=12
+PROMOTE_TIMEOUT=5
+
+function confirm_tier_removed {
+ $CLI system getspec $V0 | grep $1
+ if [ $? == 0 ]; then
+ echo "1"
+ else
+ echo "0"
+ fi
+}
+
+function confirm_vol_stopped {
+ $CLI volume stop $1
+ if [ $? == 0 ]; then
+ echo "0"
+ else
+ echo "1"
+ fi
+}
+
+LAST_BRICK=1
+CACHE_BRICK=2
+DEMOTE_TIMEOUT=12
+PROMOTE_TIMEOUT=5
+MIGRATION_TIMEOUT=10
+cleanup
+
+
+TEST glusterd
+TEST pidof glusterd
+
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..$LAST_BRICK}
+TEST $CLI volume start $V0
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;
+
+# Basic operations.
+cd $M0
+TEST stat .
+TEST mkdir d1
+TEST [ -d d1 ]
+TEST touch file1
+TEST [ -e file1 ]
+
+TEST $CLI volume attach-tier $V0 replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
+TEST $CLI volume set $V0 features.ctr-enabled on
+
+#check whether the directory's and files are present on mount or not.
+TEST [ -d d1 ]
+TEST [ -e file1 ]
+
+TEST $CLI volume detach-tier $V0 start
+TEST $CLI volume detach-tier $V0 commit
+
+EXPECT "0" confirm_tier_removed ${V0}${CACHE_BRICK_FIRST}
+
+EXPECT_WITHIN $REBALANCE_TIMEOUT "0" confirm_vol_stopped $V0
+
+cleanup
diff --git a/tests/basic/tier/tier.t b/tests/basic/tier/tier.t
index 8bee3bbd998..afe1e8cf053 100755
--- a/tests/basic/tier/tier.t
+++ b/tests/basic/tier/tier.t
@@ -65,9 +65,18 @@ TEST pidof glusterd
TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..$LAST_BRICK}
# testing bug 1215122, ie should fail if replica count and bricks are not compatible.
TEST ! $CLI volume attach-tier $V0 replica 5 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
-TEST $CLI volume attach-tier $V0 replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
+
TEST $CLI volume start $V0
+TEST $CLI volume set $V0 cluster.tier-demote-frequency 4
+TEST $CLI volume set $V0 cluster.tier-promote-frequency 4
+TEST $CLI volume set $V0 cluster.read-freq-threshold 0
+TEST $CLI volume set $V0 cluster.write-freq-threshold 0
+TEST $CLI volume set $V0 performance.quick-read off
+TEST $CLI volume set $V0 performance.io-cache off
TEST $CLI volume set $V0 features.ctr-enabled on
+
+TEST $CLI volume attach-tier $V0 replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
+
TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;
# Basic operations.
@@ -88,13 +97,6 @@ TEST file_on_fast_tier d1/data.txt
#TEST setfattr -n trusted.distribute.migrate-data d1/data.txt
#TEST file_on_slow_tier d1/data.txt
-TEST $CLI volume set $V0 cluster.tier-demote-frequency 4
-TEST $CLI volume set $V0 cluster.tier-promote-frequency 4
-TEST $CLI volume set $V0 cluster.read-freq-threshold 0
-TEST $CLI volume set $V0 cluster.write-freq-threshold 0
-TEST $CLI volume set $V0 performance.quick-read off
-TEST $CLI volume set $V0 performance.io-cache off
-TEST $CLI volume rebalance $V0 tier start
uuidgen > d1/data2.txt
uuidgen > d1/data3.txt
EXPECT "0" file_on_fast_tier d1/data2.txt
diff --git a/tests/bugs/tier/bug-1205545-CTR-and-trash-integration.t b/tests/bugs/tier/bug-1205545-CTR-and-trash-integration.t
index 979c3e8c83a..dc16fed0052 100644
--- a/tests/bugs/tier/bug-1205545-CTR-and-trash-integration.t
+++ b/tests/bugs/tier/bug-1205545-CTR-and-trash-integration.t
@@ -15,12 +15,12 @@ TEST pidof glusterd
# Set-up tier cluster [3-4]
TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..$LAST_BRICK}
+TEST $CLI volume start $V0
TEST $CLI volume attach-tier $V0 replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
# Start and mount the volume after enabling CTR and trash [5-8]
TEST $CLI volume set $V0 features.ctr-enabled on
TEST $CLI volume set $V0 features.trash on
-TEST $CLI volume start $V0
TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;
# Create an empty file