Permalink
Browse files

adding in tests

  • Loading branch information...
1 parent cff3579 commit d3a0637c2e2edc2dc35f8336172c9831ce90e6ac @buzztroll buzztroll committed Jul 12, 2012
Showing with 61 additions and 0 deletions.
  1. +22 −0 tests/cc-submit-bad-kernel-test.py
  2. +35 −0 tests/cc-submit-kernel-test.py
  3. +4 −0 tests/ec2_submit_tests.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+
+import pexpect
+import sys
+import os
+
+tst_image_name = os.environ['NIMBUS_TEST_IMAGE']
+tst_image_src = os.environ['NIMBUS_SOURCE_TEST_IMAGE']
+to=int(os.environ["NIMBUS_TEST_TIMEOUT"])
+cc_home=os.environ['CLOUD_CLIENT_HOME']
+logfile = sys.stdout
+
+cmd = "%s/bin/cloud-client.sh --transfer --sourcefile %s" % (cc_home, tst_image_src)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to)
+
+cmd = "%s/bin/cloud-client.sh --kernel notthere --run --name %s --hours .5" % (cc_home, tst_image_name)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to)
+if rc == 0:
+ print "a bad kernel was submitted, should have failed"
+ sys.exit(1)
+
+sys.exit(0)
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+
+import pexpect
+import sys
+import os
+
+tst_image_name = os.environ['NIMBUS_TEST_IMAGE']
+tst_image_src = os.environ['NIMBUS_SOURCE_TEST_IMAGE']
+to=int(os.environ["NIMBUS_TEST_TIMEOUT"])
+cc_home=os.environ['CLOUD_CLIENT_HOME']
+logfile = sys.stdout
+
+cmd = "%s/bin/cloud-client.sh --transfer --sourcefile %s" % (cc_home, tst_image_src)
+(x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to)
+
+cmd = "%s/bin/cloud-client.sh --kernel default --run --name %s --hours .5" % (cc_home, tst_image_name)
+child = pexpect.spawn (cmd, timeout=to, maxread=20000, logfile=logfile)
+rc = child.expect ('Running:')
+if rc != 0:
+ print "%s not found in the list" % (tst_image_name)
+ sys.exit(1)
+handle = child.readline().strip().replace("'", "")
+rc = child.expect(pexpect.EOF)
+if rc != 0:
+ print "run"
+ sys.exit(1)
+
+cmd = "%s/bin/cloud-client.sh --terminate --handle %s" % (cc_home, handle)
+print cmd
+(x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to)
+print x
+if rc != 0:
+ print "failed to terminate"
+ sys.exit(1)
+sys.exit(0)
@@ -104,6 +104,10 @@ def tearDown(self):
self.db.close()
self.killall_running()
+ def test_ec2_submit_kernel(self):
+ image_name = self.store_new_image()
+ image = self.ec2conn.get_image(image_name)
+ res = image.run(kernel_id="default")
def test_ec2_submit_name_format(self):
image_name = self.store_new_image()

0 comments on commit d3a0637

Please sign in to comment.