From 8d616d4d83974ccf25f6882abee095717af7073a Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Fri, 9 Mar 2012 15:20:39 +0100
Subject: [PATCH] Add utilisation and instance selection tests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: RenΓ© Nussbaumer <rn@google.com>
---
 htools/offline-test.sh | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/htools/offline-test.sh b/htools/offline-test.sh
index f5708a195..f225b7587 100755
--- a/htools/offline-test.sh
+++ b/htools/offline-test.sh
@@ -130,6 +130,28 @@ for suffix in standard tiered; do
 done
 echo OK
 
+echo Checking utilisation-based code
+BACKEND="-t $T/simu-onegroup.standard"
+echo a > $T/dynu
+(! hbal -U <(echo a) $BACKEND  2>&1 ) | grep -q "Cannot parse line"
+(! hbal -U <(echo a b c d e f g h) $BACKEND 2>&1 ) | \
+  grep -q "Cannot parse line"
+(! hbal -U <(echo inst cpu mem dsk net) $BACKEND 2>&1 ) | \
+  grep -Eq "cannot parse string '(cpu|mem|dsk|net)'"
+# unknown instances are currently just ignored
+hbal -U <(echo no-such-inst 2 2 2 2) $BACKEND >/dev/null 2>&1
+# new-0 is the name of the first instance allocated by hspace
+hbal -U <(echo new-0 2 2 2 2) $BACKEND >/dev/null 2>&1
+echo OK
+
+echo Checking selected/excluded instances
+(! hbal $BACKEND --exclude-instances no-such-instance 2>&1 ) | \
+  grep -q "Unknown instance"
+(! hbal $BACKEND --select-instances no-such-instances 2>&1 ) | \
+  grep -q "Unknown instance"
+hbal $BACKEND --exclude-instances new-0 --select-instances new-1 >/dev/null
+echo OK
+
 echo IAllocator checks
 # test that on invalid files it can't parse the request
 (! hail /dev/null 2>&1 ) | grep -q "Invalid JSON"
-- 
GitLab