Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
adding in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
buzztroll committed Jul 12, 2012
1 parent cff3579 commit d3a0637
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/cc-submit-bad-kernel-test.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)
35 changes: 35 additions & 0 deletions tests/cc-submit-kernel-test.py
@@ -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)
4 changes: 4 additions & 0 deletions tests/ec2_submit_tests.py
Expand Up @@ -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()
Expand Down

0 comments on commit d3a0637

Please sign in to comment.