From c64c385463cb51007c0c245234efe430c66c4054 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Fri, 21 Dec 2012 17:34:17 +0100
Subject: [PATCH] Extend the hcheck shell tests

This adds a few new hcheck tests, to extend the coverage.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 Makefile.am                            |  1 +
 htest/data/clean-nonzero-score.data    | 15 +++++++++++++++
 htest/shelltests/htools-balancing.test | 20 ++++++++++++++++++++
 3 files changed, 36 insertions(+)
 create mode 100644 htest/data/clean-nonzero-score.data

diff --git a/Makefile.am b/Makefile.am
index 338e7226a..87d0f7a81 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -867,6 +867,7 @@ maninput = \
 	man/footer.man man/footer.html $(mangen)
 
 TEST_FILES = \
+	htest/data/clean-nonzero-score.data \
 	htest/data/common-suffix.data \
 	htest/data/empty-cluster.data \
 	htest/data/hail-alloc-drbd.json \
diff --git a/htest/data/clean-nonzero-score.data b/htest/data/clean-nonzero-score.data
new file mode 100644
index 000000000..72762fa91
--- /dev/null
+++ b/htest/data/clean-nonzero-score.data
@@ -0,0 +1,15 @@
+group-01|fake-uuid-01|preferred|
+
+node-01-001|91552|0|91424|953674|953674|16|N|fake-uuid-01|1
+node-01-002|91552|0|91296|953674|953674|16|N|fake-uuid-01|1
+node-01-003|91552|0|91296|953674|953674|16|N|fake-uuid-01|1
+
+new-0|128|1024|1|running|Y|node-01-003||diskless||1
+new-1|128|1024|1|running|Y|node-01-002||diskless||1
+new-2|128|1024|1|running|Y|node-01-001||diskless||1
+new-3|128|1024|1|running|Y|node-01-003||diskless||1
+new-4|128|1024|1|running|Y|node-01-002||diskless||1
+
+
+|128,1,1024,1,1,1|128,1,1024,1,1,1|32768,8,1048576,16,8,12|diskless,file,sharedfile,plain,blockdev,drbd,rbd,ext|4.0|32.0
+group-01|128,1,1024,1,1,1|128,1,1024,1,1,1|32768,8,1048576,16,8,12|diskless,file,sharedfile,plain,blockdev,drbd,rbd,ext|4.0|32.0
diff --git a/htest/shelltests/htools-balancing.test b/htest/shelltests/htools-balancing.test
index 550cee984..6c54d5540 100644
--- a/htest/shelltests/htools-balancing.test
+++ b/htest/shelltests/htools-balancing.test
@@ -97,6 +97,26 @@ diff -u $T/simu-rebal-merged.tiered $T/simu-rebal.tiered.original
 >>>2
 >>>=0
 
+# and hcheck should report this as needs rebalancing
+./htest/hcheck -t$TESTDATA_DIR/n1-failure.data
+>>>/Cluster needs rebalancing./
+>>>= 1
+
+# ... unless we request no-simulation mode
+./htest/hcheck -t$TESTDATA_DIR/n1-failure.data --no-simulation
+>>>/Running in no-simulation mode./
+>>>= 0
+
+# and a clean cluster should be reported as such
+./htest/hcheck $BACKEND_BAL_STD
+>>>/No need to rebalance cluster, no problems found./
+>>>= 0
+
+# ... and even one with non-zero score
+./htest/hcheck -t $TESTDATA_DIR/clean-nonzero-score.data
+>>>/No need to rebalance cluster, no problems found./
+>>>= 0
+
 # hbal should work on empty groups as well
 ./htest/hbal -t$TESTDATA_DIR/n1-failure.data -G group-02
 >>>/Group size 0 nodes, 0 instances/
-- 
GitLab