From 31728b11d4f7af90711c352962446051d5363c30 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 2 Dec 2009 17:49:38 +0100
Subject: [PATCH] Add a live-test script

This can be used to test that all the existing commands work correctly. It
needs a running cluster with at least one instance to run all the tests.
---
 live-test.sh | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)
 create mode 100755 live-test.sh

diff --git a/live-test.sh b/live-test.sh
new file mode 100755
index 000000000..ee0153746
--- /dev/null
+++ b/live-test.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+# Copyright (C) 2009 Google Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# This is a live-testing script for most/all of the htools
+# programs. It needs either to run on a live cluster or access to a
+# cluster via ssh and an exported LUXI interface (via socat, for
+# example).
+
+# Use: if running on a cluster master, just running it should be
+# enough. If running remotely, set env vars as follows: LUXI to the
+# export unix socket, RAPI to the cluster IP, CLUSTER to the command
+# used to login on the cluster (e.g. CLUSTER="ssh root@cluster").
+
+set -e
+: ${RAPI:=localhost}
+T=`mktemp -d`
+trap 'rm -rf $T' EXIT
+echo Using $T as temporary dir
+
+echo Testing hscan
+./hscan -d$T $RAPI
+
+echo Testing hbal/luxi
+./hbal -L$LUXI
+echo Testing hbal/rapi
+./hbal -m$RAPI
+echo Testing hbal/text
+./hbal -n$T/$RAPI.nodes -i $T/$RAPI.instances
+
+echo Getting data files for hail
+IR=`$CLUSTER head -n1 /var/lib/ganeti/ssconf_instance_list`
+$CLUSTER gnt-debug allocator --dir in --mode allocate --mem 128m \
+    --disks 128m -t drbd -o no_such_os no_such_instance \
+    > $T/h-alloc.json
+$CLUSTER gnt-debug allocator --dir in --mode relocate --mem 128m \
+    --disks 128m -t drbd -o no_such_os $IR > $T/h-reloc.json
+echo Testing hail/allocate
+./hail $T/h-alloc.json
+echo Testing hail/relocate
+./hail $T/h-reloc.json
+
+HOUT="$T/hspace.out"
+
+check_hspace_out() {
+    set -u
+    set -e
+    source "$HOUT"
+    echo ALLOC_INSTANCES=$HTS_ALLOC_INSTANCES
+    echo TSPEC=$HTS_TSPEC
+    echo OK=$HTS_OK
+}
+
+TIER="--tiered 102400,8192,2"
+echo Testing hspace/luxi
+./hspace -L$LUXI $TIER > $HOUT
+( check_hspace_out ) || exit 1
+echo Testing hspace/rapi
+./hspace -m$RAPI $TIER > $HOUT
+( check_hspace_out ) || exit 1
+echo Testing hspace/text
+./hspace -n$T/$RAPI.nodes -i $T/$RAPI.instances $TIER > $HOUT
+( check_hspace_out ) || exit 1
+echo Testing hspace/simu
+# ~6T disk space, 32G ram, 4 VCPUs
+./hspace --simu=10,6835937,32768,4 $TIER > $HOUT
+( check_hspace_out ) || exit 1
+echo All OK
-- 
GitLab