Permalink
Browse files

adding timeouts

  • Loading branch information...
1 parent 503f2b2 commit 1e3b5f92575d120cb7721dc93ec762bbefb7cb75 @buzztroll buzztroll committed Nov 21, 2011
Showing with 34 additions and 35 deletions.
  1. +11 −11 tests/cc-nimbusAdminList-test.py
  2. +23 −24 tests/cc-nimbusAdminShutdown-test.py
@@ -21,11 +21,11 @@
pass
cmd = "%s/bin/nimbus-list-users %%" % (nimbus_home)
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to)
print x
cmd = "%s/bin/cloud-client.sh --transfer --sourcefile %s" % (cc_home, tst_image_src)
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to)
cmd = "%s/bin/cloud-client.sh --run --name %s --hours .25" % (cc_home, tst_image_name)
child = pexpect.spawn (cmd, timeout=to, maxread=20000, logfile=logfile)
@@ -41,47 +41,47 @@
cmd = "%s/bin/nimbus-admin --list --user %s" % (nimbus_home, nimbus_user)
print cmd
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to)
print x
if rc != 0 or not re.match(".*id\s*?:\s*?\d.*", x):
print "error"
sys.exit(1)
cmd = "%s/bin/nimbus-admin --list --dn /O=Auto/OU=CA/CN=%s" % (nimbus_home, nimbus_user)
print cmd
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to)
print x
if rc != 0 or not re.match(".*id\s*?:\s*?\d.*", x):
print "error"
sys.exit(1)
cmd = "%s/bin/nimbus-admin --list --host localhost" % (nimbus_home)
print cmd
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to)
print x
if rc != 0 or not re.match(".*id\s*?:\s*?\d.*", x):
print "error"
sys.exit(1)
cmd = "%s/bin/nimbus-admin --list --gid 1" % (nimbus_home)
print cmd
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to)
print x
if rc != 0 or not re.match(".*id\s*?:\s*?\d.*", x):
print "error"
sys.exit(1)
cmd = "%s/bin/nimbus-admin --list --gname UNLIMITED" % (nimbus_home)
print cmd
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to)
print x
if rc != 0 or not re.match(".*id\s*?:\s*?\d.*", x):
print "error"
sys.exit(1)
cmd = "%s/bin/nimbus-admin --list" % (nimbus_home)
print cmd
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to)
print x
if rc != 0 or not re.match(".*id\s*?:\s*?\d.*", x):
print "error"
@@ -101,7 +101,7 @@
cmd = "%s/bin/nimbus-admin --nodes" % (nimbus_home)
print cmd
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to)
print x
if rc != 0:
print "error"
@@ -115,14 +115,14 @@
cmd = "%s/bin/nimbus-admin --batch --shutdown --all" % (nimbus_home)
print cmd
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to)
print x
if rc != 0:
print "error"
sys.exit(1)
cmd = "%s/bin/cloud-client.sh --delete --name %s" % (cc_home, tst_image_name)
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to)
if rc != 0:
print "error"
sys.exit(1)
@@ -13,13 +13,12 @@
nimbus_home=os.environ['NIMBUS_HOME']
nimbus_user=os.environ['NIMBUS_TEST_USER']
group_name="UNLIMITED"
-#logfile = sys.stdout
-logfile = None
+logfile = sys.stdout
def id_from_handle(handle):
cmd = "%s/bin/cloud-client.sh --status " % (cc_home)
#print cmd
- (out, rc)=pexpect.run(cmd, withexitstatus=1)
+ (out, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
m = re.search(".*Workspace #(\d*?)\..*Handle: %s.*" % handle, out, re.S|re.M)
if m:
id = m.group(1)
@@ -46,18 +45,18 @@ def start_vm():
def assert_no_vms():
cmd = "%s/bin/nimbus-admin --list " % (nimbus_home)
#print cmd
- (x, rc)=pexpect.run(cmd, withexitstatus=1)
+ (x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
if rc != 0 or x != "":
- print "error"
+ print "error 1"
sys.exit(1)
def assert_vms():
cmd = "%s/bin/nimbus-admin --list " % (nimbus_home)
#print cmd
- (x, rc)=pexpect.run(cmd, withexitstatus=1)
+ (x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
#print x
if rc != 0 or x == "":
- print "error"
+ print "error 2"
sys.exit(1)
@@ -68,18 +67,18 @@ def assert_vms():
pass
cmd = "%s/bin/cloud-client.sh --transfer --sourcefile %s" % (cc_home, tst_image_src)
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
id = start_vm()
assert_vms()
# Shutdown started VM
cmd = "%s/bin/nimbus-admin --shutdown --id %s" % (nimbus_home, id)
print cmd
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
print x
if rc != 0:
- print "error"
+ print "error shutdown id %s" % (cmd)
sys.exit(1)
assert_no_vms()
@@ -91,10 +90,10 @@ def assert_vms():
# Shutdown started VM
cmd = "%s/bin/nimbus-admin --shutdown --dn /O=Auto/OU=CA/CN=%s" % (nimbus_home, nimbus_user)
print cmd
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
print x
if rc != 0:
- print "error"
+ print "error shutdown dn %s" % (cmd)
sys.exit(1)
assert_no_vms()
@@ -104,10 +103,10 @@ def assert_vms():
cmd = "%s/bin/nimbus-admin --shutdown --host localhost" % (nimbus_home)
print cmd
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
print x
if rc != 0:
- print "error"
+ print "error shutdown host %s" % (cmd)
sys.exit(1)
assert_no_vms()
@@ -118,10 +117,10 @@ def assert_vms():
cmd = "%s/bin/nimbus-admin --shutdown --gid 1" % (nimbus_home)
print cmd
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
print x
if rc != 0:
- print "error"
+ print "error gid %s" % (cmd)
sys.exit(1)
assert_no_vms()
@@ -132,10 +131,10 @@ def assert_vms():
cmd = "%s/bin/nimbus-admin --shutdown --gname %s" % (nimbus_home, group_name)
print cmd
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
print x
if rc != 0:
- print "error"
+ print "error gname %s" % (cmd)
sys.exit(1)
assert_no_vms()
@@ -146,10 +145,10 @@ def assert_vms():
cmd = "%s/bin/nimbus-admin --shutdown --user %s --seconds 35" % (nimbus_home, nimbus_user)
print cmd
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
print x
if rc != 0:
- print "error"
+ print "error %dhutdown user %s" % (cmd)
sys.exit(1)
assert_no_vms()
@@ -160,18 +159,18 @@ def assert_vms():
cmd = "%s/bin/nimbus-admin --shutdown --all --seconds 30" % (nimbus_home)
print cmd
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
print x
if rc != 0:
- print "error"
+ print "error shutdown all %s" % (cmd)
sys.exit(1)
assert_no_vms()
cmd = "%s/bin/cloud-client.sh --delete --name %s" % (cc_home, tst_image_name)
-(x, rc)=pexpect.run(cmd, withexitstatus=1)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
if rc != 0:
- print "error"
+ print "error delete %s" % (cmd)
sys.exit(1)
sys.exit(0)

0 comments on commit 1e3b5f9

Please sign in to comment.