summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-rpc-ops.c56
-rwxr-xr-xtests/bugs/distribute/bug-853258.t4
-rw-r--r--tests/bugs/distribute/bug-860663.t2
-rw-r--r--tests/bugs/glusterd/bug-1004744.t2
-rw-r--r--tests/volume.rc8
5 files changed, 51 insertions, 21 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index de3a382869d..25b1ccdd9cd 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -1561,13 +1561,32 @@ gf_cli_print_rebalance_status (dict_t *dict, enum gf_task_types task_type,
goto out;
}
+ memset (key, 0, 256);
+ snprintf (key, 256, "status-1");
+
+ ret = dict_get_int32 (dict, key, (int32_t *)&status_rcd);
+ if (ret) {
+ gf_log ("cli", GF_LOG_TRACE, "count %d %d", count, 1);
+ gf_log ("cli", GF_LOG_TRACE, "failed to get status");
+ goto out;
+ }
+
+ if (status_rcd >= GF_DEFRAG_STATUS_LAYOUT_FIX_STARTED) {
+ cli_out ("%10s %40s %18s", "Node", "status",
+ "run time in h:m:s");
+ cli_out ("%10s %40s %18s", "---------", "-----------",
+ "------------");
+ } else {
+ cli_out ("%40s %16s %13s %13s %13s %13s %20s %18s",
+ "Node", "Rebalanced-files", "size", "scanned",
+ "failures", "skipped", "status", "run time in"
+ " h:m:s");
+ cli_out ("%40s %16s %13s %13s %13s %13s %20s %18s",
+ "---------", "-----------", "-----------",
+ "-----------", "-----------", "-----------",
+ "------------", "--------------");
+ }
- cli_out ("%40s %16s %13s %13s %13s %13s %20s %18s", "Node",
- "Rebalanced-files", "size", "scanned", "failures", "skipped",
- "status", "run time in h:m:s");
- cli_out ("%40s %16s %13s %13s %13s %13s %20s %18s", "---------",
- "-----------", "-----------", "-----------", "-----------",
- "-----------", "------------", "--------------");
for (i = 1; i <= count; i++) {
/* Reset the variables to prevent carryover of values */
node_name = NULL;
@@ -1664,16 +1683,23 @@ gf_cli_print_rebalance_status (dict_t *dict, enum gf_task_types task_type,
min = ((int) elapsed % 3600) / 60;
sec = ((int) elapsed % 3600) % 60;
- if (size_str) {
- cli_out ("%40s %16"PRIu64 " %13s" " %13"PRIu64 " %13"
- PRIu64" %13"PRIu64 " %20s %8d:%d:%d",
- node_name, files, size_str, lookup, failures,
- skipped, status_str, hrs, min, sec);
+ if (status_rcd >= GF_DEFRAG_STATUS_LAYOUT_FIX_STARTED) {
+ cli_out ("%10s %40s %8d:%d:%d", node_name, status_str,
+ hrs, min, sec);
} else {
- cli_out ("%40s %16"PRIu64 " %13"PRIu64 " %13"PRIu64
- " %13"PRIu64" %13"PRIu64 " %20s %8d:%d:%d",
- node_name, files, size, lookup, failures,
- skipped, status_str, hrs, min, sec);
+ if (size_str) {
+ cli_out ("%40s %16"PRIu64 " %13s" " %13"PRIu64
+ " %13" PRIu64" %13"PRIu64 " %20s "
+ "%8d:%d:%d", node_name, files,
+ size_str, lookup, failures, skipped,
+ status_str, hrs, min, sec);
+ } else {
+ cli_out ("%40s %16"PRIu64 " %13"PRIu64 " %13"
+ PRIu64 " %13"PRIu64" %13"PRIu64 " %20s"
+ " %8d:%d:%d", node_name, files, size,
+ lookup, failures, skipped, status_str,
+ hrs, min, sec);
+ }
}
GF_FREE(size_str);
}
diff --git a/tests/bugs/distribute/bug-853258.t b/tests/bugs/distribute/bug-853258.t
index b2d7f2b771a..2f0e1b8b9b7 100755
--- a/tests/bugs/distribute/bug-853258.t
+++ b/tests/bugs/distribute/bug-853258.t
@@ -20,7 +20,7 @@ EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field $V0 'Status';
# Force assignment of initial ranges.
TEST $CLI volume rebalance $V0 fix-layout start
-EXPECT_WITHIN $REBALANCE_TIMEOUT "fix-layout completed" rebalance_status_field $V0
+EXPECT_WITHIN $REBALANCE_TIMEOUT "fix-layout completed" fix-layout_status_field $V0
# Get the original values.
xattrs=""
@@ -32,7 +32,7 @@ done
TEST $CLI volume add-brick $V0 $H0:$B0/${V0}3
# Force assignment of initial ranges.
TEST $CLI volume rebalance $V0 fix-layout start
-EXPECT_WITHIN $REBALANCE_TIMEOUT "fix-layout completed" rebalance_status_field $V0
+EXPECT_WITHIN $REBALANCE_TIMEOUT "fix-layout completed" fix-layout_status_field $V0
for i in $(seq 0 3); do
xattrs="$xattrs $(dht_get_layout $B0/${V0}$i)"
diff --git a/tests/bugs/distribute/bug-860663.t b/tests/bugs/distribute/bug-860663.t
index a4946718398..12b3e21a9be 100644
--- a/tests/bugs/distribute/bug-860663.t
+++ b/tests/bugs/distribute/bug-860663.t
@@ -44,7 +44,7 @@ EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/${V0}1
TEST $CLI volume rebalance $V0 fix-layout start
-EXPECT_WITHIN $REBALANCE_TIMEOUT "fix-layout completed" rebalance_status_field $V0;
+EXPECT_WITHIN $REBALANCE_TIMEOUT "fix-layout completed" fix-layout_status_field $V0;
# Unmount and remount to make sure we're doing fresh lookups.
TEST umount $M0
diff --git a/tests/bugs/glusterd/bug-1004744.t b/tests/bugs/glusterd/bug-1004744.t
index b48ed97fb52..66a827daa74 100644
--- a/tests/bugs/glusterd/bug-1004744.t
+++ b/tests/bugs/glusterd/bug-1004744.t
@@ -36,7 +36,7 @@ TEST $CLI volume add-brick $V0 $H0:$B0/${V0}{3,4};
#perform rebalance fix-layout
TEST $CLI volume rebalance $V0 fix-layout start
-EXPECT_WITHIN $REBALANCE_TIMEOUT "fix-layout completed" rebalance_status_field $V0;
+EXPECT_WITHIN $REBALANCE_TIMEOUT "fix-layout completed" fix-layout_status_field $V0;
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
TEST $CLI volume stop $V0
diff --git a/tests/volume.rc b/tests/volume.rc
index 6ff25cc79a3..331a8025eb4 100644
--- a/tests/volume.rc
+++ b/tests/volume.rc
@@ -41,12 +41,16 @@ function volume_option()
}
function rebalance_status_field {
- #The rebalance status can be upto 3 words, (ex:'fix-layout in progress'), hence the awk-print $7 thru $9.
+ $CLI volume rebalance $1 status | awk '{print $7}' | sed -n 3p
+}
+
+function fix-layout_status_field {
+ #The fix-layout status can be upto 3 words, (ex:'fix-layout in progress'), hence the awk-print $2 thru $4.
#But if the status is less than 3 words, it also prints the next field i.e the run_time_in_secs.(ex:'completed 3.00').
#So we trim the numbers out with `tr`. Finally remove the trailing white spaces with sed. What we get is one of the
#strings in the 'cli_vol_task_status_str' char array of cli-rpc-ops.c
- $CLI volume rebalance $1 status | awk '{print $7,$8,$9}' |sed -n 3p |tr -d '[^0-9+\.]'|sed 's/ *$//g'
+ $CLI volume rebalance $1 status | awk '{print $2,$3,$4}' |sed -n 3p |tr -d '[^0-9+\.]'|sed 's/ *$//g'
}
function detach_tier_status_field {