From 8abeb641492d4da45c05d9027664eef0d87d98a9 Mon Sep 17 00:00:00 2001
From: Bernardo Dal Seno <bdalseno@google.com>
Date: Wed, 24 Apr 2013 03:15:14 +0200
Subject: [PATCH] Add shelltests for hspace allocation

Both tiered and standard allocations are tested, with a single and a double
min/max instance specification.

Signed-off-by: Bernardo Dal Seno <bdalseno@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>
---
 Makefile.am                                  |  2 ++
 test/data/htools/hspace-tiered-dualspec.data | 11 +++++++++++
 test/data/htools/hspace-tiered.data          | 11 +++++++++++
 test/hs/shelltests/htools-hspace.test        |  9 +++++++++
 4 files changed, 33 insertions(+)
 create mode 100644 test/data/htools/hspace-tiered-dualspec.data
 create mode 100644 test/data/htools/hspace-tiered.data

diff --git a/Makefile.am b/Makefile.am
index f34ada2f9..dcc85c821 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1003,6 +1003,8 @@ TEST_FILES = \
 	test/data/htools/hail-reloc-drbd.json \
 	test/data/htools/hbal-excl-tags.data \
 	test/data/htools/hbal-split-insts.data \
+	test/data/htools/hspace-tiered-dualspec.data \
+	test/data/htools/hspace-tiered.data \
 	test/data/htools/invalid-node.data \
 	test/data/htools/missing-resources.data \
 	test/data/htools/multiple-master.data \
diff --git a/test/data/htools/hspace-tiered-dualspec.data b/test/data/htools/hspace-tiered-dualspec.data
new file mode 100644
index 000000000..46e44ce4d
--- /dev/null
+++ b/test/data/htools/hspace-tiered-dualspec.data
@@ -0,0 +1,11 @@
+group-01|fake-uuid-01|preferred|
+
+node-01-001|262144|65536|196608|2097152|2097152|8|N|fake-uuid-01|1
+node-01-002|262144|65536|196608|2097152|2097152|8|N|fake-uuid-01|1
+node-01-003|262144|1024|261120|2097152|2097152|8|N|fake-uuid-01|1
+node-01-004|262144|1024|261120|2097152|2097152|8|N|fake-uuid-01|1
+
+
+
+|63488,2,522240,1,1,1|129024,4,1047552,1,1,1;131072,4,1048576,16,8,12;63488,2,522240,1,1,1;65536,2,524288,16,8,12|plain,diskless,file,sharedfile,blockdev,drbd,rbd,ext|4.0|32.0
+group-01|63488,2,522240,1,1,1|129024,4,1047552,1,1,1;131072,4,1048576,16,8,12;63488,2,522240,1,1,1;65536,2,524288,16,8,12|plain,diskless,file,sharedfile,blockdev,drbd,rbd,ext|4.0|32.0
diff --git a/test/data/htools/hspace-tiered.data b/test/data/htools/hspace-tiered.data
new file mode 100644
index 000000000..61ee4c1a4
--- /dev/null
+++ b/test/data/htools/hspace-tiered.data
@@ -0,0 +1,11 @@
+group-01|fake-uuid-01|preferred|
+
+node-01-001|262144|65536|196608|2097152|2097152|8|N|fake-uuid-01|1
+node-01-002|262144|65536|196608|2097152|2097152|8|N|fake-uuid-01|1
+node-01-003|262144|1024|261120|2097152|2097152|8|N|fake-uuid-01|1
+node-01-004|262144|1024|261120|2097152|2097152|8|N|fake-uuid-01|1
+
+
+
+|129024,4,1047552,1,1,1|129024,4,1047552,1,1,1;131072,4,1048576,16,8,12|plain,diskless,file,sharedfile,blockdev,drbd,rbd,ext|4.0|32.0
+group-01|129024,4,1047552,1,1,1|129024,4,1047552,1,1,1;131072,4,1048576,16,8,12|plain,diskless,file,sharedfile,blockdev,drbd,rbd,ext|4.0|32.0
diff --git a/test/hs/shelltests/htools-hspace.test b/test/hs/shelltests/htools-hspace.test
index 553c98dff..43f7ea0a1 100644
--- a/test/hs/shelltests/htools-hspace.test
+++ b/test/hs/shelltests/htools-hspace.test
@@ -6,3 +6,12 @@
 # test again via a file and shell parsing
 ./test/hs/hspace --simu p,4,8T,64g,16 --machine-readable --disk-template drbd -l 8 > $T/capacity && sh -c ". $T/capacity && test x\$HTS_OK = x1"
 >>>= 0
+
+# standard & tiered allocation, using shell parsing to do multiple checks
+./test/hs/hspace --machine-readable -t $TESTDATA_DIR/hspace-tiered.data > $T/capacity && sh -c ". $T/capacity && test \"\${HTS_TSPEC}\" = '131072,1048576,4=4 129984,1048320,4=2' && test \"\${HTS_ALLOC_INSTANCES}\" = 6"
+>>>=0
+
+# again, but with a policy containing two min/max specs pairs
+./test/hs/hspace --machine-readable -t $TESTDATA_DIR/hspace-tiered-dualspec.data > $T/capacity && sh -c ". $T/capacity && test \"\${HTS_TSPEC}\" = '131072,1048576,4=4 129984,1048320,4=2 65472,524288,2=2' && test \"\${HTS_ALLOC_INSTANCES}\" = 14"
+>>>2
+>>>=0
-- 
GitLab