Added tests

This commit is contained in:
Josh Kearney
2010-12-29 14:02:57 -06:00
parent 4b2ba4b674
commit 50e54140b0
2 changed files with 34 additions and 12 deletions

View File

@@ -102,13 +102,15 @@ class ComputeTestCase(test.TestCase):
instances = db.instance_get_all(context.get_admin_context())
logging.info(_("Running instances: %s"), instances)
self.assertEqual(len(instances), 1)
instance_count = len(instances)
self.assertNotEqual(instance_count, 0)
self.compute.terminate_instance(self.context, instance_id)
instances = db.instance_get_all(context.get_admin_context())
logging.info(_("After terminating instances: %s"), instances)
self.assertEqual(len(instances), 0)
self.assertEqual(instance_count, len(instances) + 1)
def test_run_terminate_timestamps(self):
"""Make sure timestamps are set for launched and destroyed"""
@@ -151,6 +153,16 @@ class ComputeTestCase(test.TestCase):
self.compute.reboot_instance(self.context, instance_id)
self.compute.terminate_instance(self.context, instance_id)
def test_diagnostics(self):
"""Ensure instance diagnostics are available"""
instance_id = self._create_instance()
self.compute.get_diagnostics(self.context, instance_id)
def test_actions(self):
"""Ensure instance actions are available"""
instance_id = self._create_instance()
self.compute.get_actions(self.context, instance_id)
def test_console_output(self):
"""Make sure we can get console output from instance"""
instance_id = self._create_instance()

View File

@@ -159,6 +159,16 @@ class XenAPIVMTestCase(test.TestCase):
fake.reset()
fakes.stub_out_db_instance_api(self.stubs)
fake.create_network('fake', FLAGS.flat_network_bridge)
self.values = {
"name": 1,
"id": 1,
"project_id": self.project.id,
"user_id": self.user.id,
"image_id": 1,
"kernel_id": 2,
"ramdisk_id": 3,
"instance_type": "m1.large",
"mac_address": "aa:bb:cc:dd:ee:ff"}
def test_list_instances_0(self):
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
@@ -166,19 +176,19 @@ class XenAPIVMTestCase(test.TestCase):
instances = conn.list_instances()
self.assertEquals(instances, [])
def test_get_diagnostics(self):
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
conn = xenapi_conn.get_connection(False)
instance = db.instance_create(self.values)
conn.spawn(instance)
conn.get_diagnostics(instance)
def test_spawn(self):
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
values = {'name': 1, 'id': 1,
'project_id': self.project.id,
'user_id': self.user.id,
'image_id': 1,
'kernel_id': 2,
'ramdisk_id': 3,
'instance_type': 'm1.large',
'mac_address': 'aa:bb:cc:dd:ee:ff',
}
conn = xenapi_conn.get_connection(False)
instance = db.instance_create(values)
instance = db.instance_create(self.values)
conn.spawn(instance)
def check():