add in unit tests
This commit is contained in:
parent
e4c1fa91e0
commit
35638077a1
|
@ -150,6 +150,19 @@ class CloudTestCase(test.TestCase):
|
|||
greenthread.sleep(0.3)
|
||||
rv = yield self.cloud.terminate_instances(self.context, [instance_id])
|
||||
|
||||
def test_ajax_console(self):
|
||||
kwargs = {'image_id': image_id }
|
||||
rv = yield self.cloud.run_instances(self.context, **kwargs)
|
||||
instance_id = rv['instancesSet'][0]['instanceId']
|
||||
output = yield self.cloud.get_console_output(context=self.context,
|
||||
instance_id=[instance_id])
|
||||
self.assertEquals(b64decode(output['output']),
|
||||
'http://fakeajaxconsole.com/?token=FAKETOKEN')
|
||||
# TODO(soren): We need this until we can stop polling in the rpc code
|
||||
# for unit tests.
|
||||
greenthread.sleep(0.3)
|
||||
rv = yield self.cloud.terminate_instances(self.context, [instance_id])
|
||||
|
||||
def test_key_generation(self):
|
||||
result = self._create_key('test')
|
||||
private_key = result['private_key']
|
||||
|
|
|
@ -153,6 +153,16 @@ class ComputeTestCase(test.TestCase):
|
|||
self.assert_(console)
|
||||
self.compute.terminate_instance(self.context, instance_id)
|
||||
|
||||
def test_ajax_console(self):
|
||||
"""Make sure we can get console output from instance"""
|
||||
instance_id = self._create_instance()
|
||||
self.compute.run_instance(self.context, instance_id)
|
||||
|
||||
console = self.compute.get_ajax_console(self.context,
|
||||
instance_id)
|
||||
self.assert_(console)
|
||||
self.compute.terminate_instance(self.context, instance_id)
|
||||
|
||||
def test_run_instance_existing(self):
|
||||
"""Ensure failure when running an instance that already exists"""
|
||||
instance_id = self._create_instance()
|
||||
|
|
|
@ -260,6 +260,8 @@ class FakeConnection(object):
|
|||
def get_console_output(self, instance):
|
||||
return 'FAKE CONSOLE OUTPUT'
|
||||
|
||||
def get_ajax_console(self, instance):
|
||||
return 'http://fakeajaxconsole.com/?token=FAKETOKEN'
|
||||
|
||||
class FakeInstance(object):
|
||||
|
||||
|
|
Loading…
Reference in New Issue