From 591fa888905b45eb1eab52c87ded11e0caef418e Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Fri, 21 Dec 2012 17:14:20 +0100 Subject: [PATCH] Extend the hbal shell tests After this patch, almost all of hbal except the actual Luxi execution is being covered by unit- or shelltests. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- Makefile.am | 1 + htest/data/n1-failure.data | 25 +++++++++++++++++++ htest/shelltests/htools-balancing.test | 31 ++++++++++++++++++++++++ htest/shelltests/htools-multi-group.test | 6 +++-- 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 htest/data/n1-failure.data diff --git a/Makefile.am b/Makefile.am index 67876a0a7..338e7226a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -878,6 +878,7 @@ TEST_FILES = \ htest/data/hbal-split-insts.data \ htest/data/invalid-node.data \ htest/data/missing-resources.data \ + htest/data/n1-failure.data \ htest/data/rapi/groups.json \ htest/data/rapi/info.json \ htest/data/rapi/instances.json \ diff --git a/htest/data/n1-failure.data b/htest/data/n1-failure.data new file mode 100644 index 000000000..8a90223b2 --- /dev/null +++ b/htest/data/n1-failure.data @@ -0,0 +1,25 @@ +group-01|fake-uuid-01|preferred| +group-02|fake-uuid-02|unallocable| + +node-01-001|256|0|0|7629394|7625298|16|N|fake-uuid-01|1 +node-01-002|256|0|0|7629394|7625298|16|N|fake-uuid-01|1 +node-01-003|256|0|0|7629394|7625298|16|N|fake-uuid-01|1 +node-01-004|256|0|0|7629394|7625298|16|N|fake-uuid-01|1 +node-02-001|65536|0|65536|7629394|7629394|16|N|fake-uuid-01|1 +node-02-002|65536|0|65536|7629394|7629394|16|N|fake-uuid-01|1 +node-02-003|65536|0|65536|7629394|7629394|16|N|fake-uuid-01|1 +node-02-004|65536|0|65536|7629394|7629394|16|N|fake-uuid-01|1 + +new-0|128|1024|1|running|Y|node-01-004|node-01-003|drbd||1 +new-1|128|1024|1|running|Y|node-01-002|node-01-001|drbd||1 +new-2|128|1024|1|running|Y|node-01-003|node-01-001|drbd||1 +new-3|128|1024|1|running|Y|node-01-001|node-01-004|drbd||1 +new-4|128|1024|1|running|Y|node-01-002|node-01-004|drbd||1 +new-5|128|1024|1|running|Y|node-01-003|node-01-002|drbd||1 +new-6|128|1024|1|running|Y|node-01-004|node-01-002|drbd||1 +new-7|128|1024|1|running|Y|node-01-001|node-01-003|drbd||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 +group-02|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 004c56eb6..550cee984 100644 --- a/htest/shelltests/htools-balancing.test +++ b/htest/shelltests/htools-balancing.test @@ -13,6 +13,18 @@ >>> /gnt-instance (failover|migrate|replace-disks)/ >>>= 0 +# test that hbal won't execute rebalances when using the text backend +./htest/hbal $BACKEND_BAL_STD -G group-01 -X +>>>2 +Error: hbal: Execution of commands possible only on LUXI +>>>= !0 + +# test that hbal won't execute any moves if we request an absurdly-high +# minimum-improvement +./htest/hbal $BACKEND_BAL_STD -G group-01 -C --min-gain 10000 --min-gain-limit 10000 +>>>/No solution found/ +>>>= 0 + # test saving commands ./htest/hbal $BACKEND_BAL_STD -G group-01 -C$T/rebal-cmds.standard >>>= 0 @@ -70,3 +82,22 @@ diff -u $T/simu-rebal-merged.tiered $T/simu-rebal.tiered.original ./htest/hbal -t $T/simu-rebal.tiered.balanced -G group-01 >>> /(Nothing to do, exiting|No solution found)/ >>>= 0 + +### now some other custom tests + +# n+1 bad instances are reported as such +./htest/hbal -t$TESTDATA_DIR/n1-failure.data -G group-01 +>>>/Initial check done: 4 bad nodes, 8 bad instances./ +>>>=0 + +# same test again, different message check (shelltest can't test multiple +# messages via regexp +./htest/hbal -t$TESTDATA_DIR/n1-failure.data -G group-01 +>>>/Cluster is not N\+1 happy, continuing but no guarantee that the cluster will end N\+1 happy./ +>>>2 +>>>=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/ +>>>= 0 diff --git a/htest/shelltests/htools-multi-group.test b/htest/shelltests/htools-multi-group.test index b693a8a05..34a41b487 100644 --- a/htest/shelltests/htools-multi-group.test +++ b/htest/shelltests/htools-multi-group.test @@ -39,7 +39,9 @@ >>> /HCHECK_OK=1/ >>>= 0 -# hcheck should be able to improve a group with split instances -./htest/hbal -t $TESTDATA_DIR/hbal-split-insts.data -G group-01 -O node-01-001 +# hcheck should be able to improve a group with split instances, and also +# warn us about them +./htest/hbal -t $TESTDATA_DIR/hbal-split-insts.data -G group-01 -O node-01-001 -v >>> /Cluster score improved from .* to .*/ +>>>2/Found instances belonging to multiple node groups:/ >>>= 0 -- GitLab