+echo Running offline htools tests
+
+export T=`mktemp -d`
+trap 'rm -rf $T' EXIT
+trap 'echo FAIL to build test files' ERR
+echo Using $T as temporary dir
+
+echo -n Generating hspace simulation data for hinfo and hbal...
+# this cluster spec should be fine
+./test/hspace --simu p,4,8T,64g,16 -S $T/simu-onegroup \
+ --disk-template drbd -l 8 -v -v -v >/dev/null 2>&1
+echo OK
+
+echo -n Generating hinfo and hbal test files for multi-group...
+./test/hspace --simu p,4,8T,64g,16 --simu p,4,8T,64g,16 \
+ -S $T/simu-twogroups --disk-template drbd -l 8 >/dev/null 2>&1
+echo OK
+
+echo -n Generating test files for rebalancing...
+# we generate a cluster with two node groups, one with unallocable
+# policy, then we change all nodes from this group to the allocable
+# one, and we check for rebalancing
+FROOT="$T/simu-rebal-orig"
+./test/hspace --simu u,4,8T,64g,16 --simu p,4,8T,64g,16 \
+ -S $FROOT --disk-template drbd -l 8 >/dev/null 2>&1
+for suffix in standard tiered; do
+ RELOC="$T/simu-rebal-merged.$suffix"
+ # this relocates the nodes
+ sed -re 's/^(node-.*|fake-uuid-)-02(|.*)/\1-01\2/' \
+ < $FROOT.$suffix > $RELOC
+done
+export BACKEND_BAL_STD="-t$T/simu-rebal-merged.standard"
+export BACKEND_BAL_TIER="-t$T/simu-rebal-merged.tiered"
+echo OK
+
+# For various tests
+export BACKEND_DYNU="-t $T/simu-onegroup.standard"
+export BACKEND_EXCL="-t $T/simu-onegroup.standard"
+
+echo -n Generating data files for IAllocator checks...
+for evac_mode in primary-only secondary-only all; do
+ sed -e 's/"evac_mode": "all"/"evac_mode": "'${evac_mode}'"/' \
+ < $TESTDATA_DIR/hail-node-evac.json \
+ > $T/hail-node-evac.json.$evac_mode