Fixed based on reviewer's comment.
1. Change docstrings format 2. Fix comment grammer mistake, etc
This commit is contained in:
@@ -38,13 +38,11 @@ from nova import flags
|
||||
from nova import log as logging
|
||||
from nova import version
|
||||
from nova import wsgi
|
||||
from nova import utils
|
||||
|
||||
logging.basicConfig()
|
||||
LOG = logging.getLogger('nova.api')
|
||||
LOG.setLevel(logging.DEBUG)
|
||||
|
||||
utils.default_flagfile()
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
API_ENDPOINTS = ['ec2', 'osapi']
|
||||
|
||||
@@ -125,7 +125,6 @@ def main():
|
||||
LOG.debug(msg)
|
||||
globals()[action + '_lease'](mac, ip, hostname, interface)
|
||||
else:
|
||||
open('/tmp/aaa', 'w+').write('-- %s' % interface)
|
||||
print init_leases(interface)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -548,7 +548,12 @@ class InstanceCommands(object):
|
||||
"""Class for mangaging VM instances."""
|
||||
|
||||
def live_migration(self, ec2_id, dest):
|
||||
"""Migrates a running instance to a new machine."""
|
||||
"""Migrates a running instance to a new machine.
|
||||
|
||||
:param ec2_id: instance id which comes from euca-describe-instance.
|
||||
:param dest: destination host name.
|
||||
|
||||
"""
|
||||
|
||||
ctxt = context.get_admin_context()
|
||||
instance_id = ec2_id_to_id(ec2_id)
|
||||
@@ -569,9 +574,8 @@ class InstanceCommands(object):
|
||||
"dest": dest,
|
||||
"topic": FLAGS.compute_topic}})
|
||||
|
||||
msg = 'Migration of %s initiated. ' % ec2_id
|
||||
msg += 'Check its progress using euca-describe-instances.'
|
||||
print msg
|
||||
print _('Migration of %s initiated.'
|
||||
'Check its progress using euca-describe-instances.') % ec2_id
|
||||
|
||||
|
||||
class ServiceCommands(object):
|
||||
@@ -619,15 +623,17 @@ class ServiceCommands(object):
|
||||
db.service_update(ctxt, svc['id'], {'disabled': True})
|
||||
|
||||
def describe_resource(self, host):
|
||||
"""describe cpu/memory/hdd info for host."""
|
||||
"""Describes cpu/memory/hdd info for host.
|
||||
|
||||
:param host: hostname.
|
||||
|
||||
"""
|
||||
|
||||
result = rpc.call(context.get_admin_context(),
|
||||
FLAGS.scheduler_topic,
|
||||
{"method": "show_host_resource",
|
||||
{"method": "show_host_resources",
|
||||
"args": {"host": host}})
|
||||
|
||||
# Checking result msg format is necessary, that will have done
|
||||
# when this feture is included in API.
|
||||
if type(result) != dict:
|
||||
print 'Unexpected error occurs'
|
||||
print '[Result]', result
|
||||
@@ -650,7 +656,11 @@ class ServiceCommands(object):
|
||||
val['local_gb'])
|
||||
|
||||
def update_resource(self, host):
|
||||
"""update available vcpu/memory/disk info for host."""
|
||||
"""Updates available vcpu/memory/disk info for host.
|
||||
|
||||
:param host: hostname.
|
||||
|
||||
"""
|
||||
|
||||
ctxt = context.get_admin_context()
|
||||
service_refs = db.service_get_all_by_host(ctxt, host)
|
||||
|
||||
@@ -314,10 +314,7 @@ class ComputeTestCase(test.TestCase):
|
||||
self.compute_driver = utils.import_object(FLAGS.compute_driver)
|
||||
|
||||
def test_pre_live_migration_instance_has_no_fixed_ip(self):
|
||||
"""
|
||||
if instances that are intended to be migrated doesnt have fixed_ip
|
||||
(not happens usually), pre_live_migration has to raise Exception.
|
||||
"""
|
||||
"""Confirm raising exception if instance doesn't have fixed_ip."""
|
||||
instance_ref = self._get_dummy_instance()
|
||||
c = context.get_admin_context()
|
||||
i_id = instance_ref['id']
|
||||
@@ -331,14 +328,9 @@ class ComputeTestCase(test.TestCase):
|
||||
self.assertRaises(exception.NotFound,
|
||||
self.compute.pre_live_migration,
|
||||
c, instance_ref['id'])
|
||||
self.mox.ResetAll()
|
||||
|
||||
def test_pre_live_migration_instance_has_volume(self):
|
||||
"""if any volumes are attached to the instances that are
|
||||
intended to be migrated, setup_compute_volume must be
|
||||
called because aoe module should be inserted at destination
|
||||
host. This testcase checks on it.
|
||||
"""
|
||||
"""Confirm setup_compute_volume is called when volume is mounted."""
|
||||
i_ref = self._get_dummy_instance()
|
||||
c = context.get_admin_context()
|
||||
|
||||
@@ -364,14 +356,9 @@ class ComputeTestCase(test.TestCase):
|
||||
self.mox.ReplayAll()
|
||||
ret = self.compute.pre_live_migration(c, i_ref['id'])
|
||||
self.assertEqual(ret, None)
|
||||
self.mox.ResetAll()
|
||||
|
||||
def test_pre_live_migration_instance_has_no_volume(self):
|
||||
"""if any volumes are not attached to the instances that are
|
||||
intended to be migrated, log message should be appears
|
||||
because administrator can proove instance conditions before
|
||||
live_migration if any trouble occurs.
|
||||
"""
|
||||
"""Confirm log meg when instance doesn't mount any volumes."""
|
||||
i_ref = self._get_dummy_instance()
|
||||
i_ref.__setitem__('volumes', [])
|
||||
c = context.get_admin_context()
|
||||
@@ -395,14 +382,14 @@ class ComputeTestCase(test.TestCase):
|
||||
self.mox.ReplayAll()
|
||||
ret = self.compute.pre_live_migration(c, i_ref['id'])
|
||||
self.assertEqual(ret, None)
|
||||
self.mox.ResetAll()
|
||||
|
||||
def test_pre_live_migration_setup_compute_node_fail(self):
|
||||
"""setup_compute_node sometimes fail since concurrent request
|
||||
comes to iptables and iptables complains. Then this method
|
||||
tries to retry, but raise exception in case of over
|
||||
max_retry_count. this method confirms raising exception.
|
||||
"""Confirm operation setup_compute_network() fails.
|
||||
|
||||
It retries and raise exception when timeout exceeded.
|
||||
|
||||
"""
|
||||
|
||||
i_ref = self._get_dummy_instance()
|
||||
c = context.get_admin_context()
|
||||
|
||||
@@ -427,14 +414,9 @@ class ComputeTestCase(test.TestCase):
|
||||
self.assertRaises(exception.ProcessExecutionError,
|
||||
self.compute.pre_live_migration,
|
||||
c, i_ref['id'])
|
||||
self.mox.ResetAll()
|
||||
|
||||
def test_live_migration_instance_has_volume(self):
|
||||
"""Any volumes are mounted by instances to be migrated are found,
|
||||
vblade health must be checked before starting live-migration.
|
||||
And that is checked by check_for_export().
|
||||
This testcase confirms check_for_export() is called.
|
||||
"""
|
||||
def test_live_migration_works_correctly_with_volume(self):
|
||||
"""Confirm check_for_export to confirm volume health check."""
|
||||
i_ref = self._get_dummy_instance()
|
||||
c = context.get_admin_context()
|
||||
topic = db.queue_get_for(c, FLAGS.compute_topic, i_ref['host'])
|
||||
@@ -457,15 +439,9 @@ class ComputeTestCase(test.TestCase):
|
||||
self.mox.ReplayAll()
|
||||
ret = self.compute.live_migration(c, i_ref['id'], i_ref['host'])
|
||||
self.assertEqual(ret, None)
|
||||
self.mox.ResetAll()
|
||||
|
||||
def test_live_migration_instance_has_volume_and_exception(self):
|
||||
"""In addition to test_live_migration_instance_has_volume testcase,
|
||||
this testcase confirms if any exception raises from
|
||||
check_for_export(). Then, valid seaquence of this method should
|
||||
recovering instance/volumes status(ex. instance['state_description']
|
||||
is changed from 'migrating' -> 'running', was changed by scheduler)
|
||||
"""
|
||||
def test_live_migration_dest_raises_exception(self):
|
||||
"""Confirm exception when pre_live_migration fails."""
|
||||
i_ref = self._get_dummy_instance()
|
||||
c = context.get_admin_context()
|
||||
topic = db.queue_get_for(c, FLAGS.compute_topic, i_ref['host'])
|
||||
@@ -484,20 +460,16 @@ class ComputeTestCase(test.TestCase):
|
||||
'state': power_state.RUNNING,
|
||||
'host': i_ref['host']})
|
||||
for v in i_ref['volumes']:
|
||||
dbmock.volume_update(c, v['id'], {'status': 'in-use',
|
||||
'host': i_ref['host']})
|
||||
dbmock.volume_update(c, v['id'], {'status': 'in-use'})
|
||||
|
||||
self.compute.db = dbmock
|
||||
self.mox.ReplayAll()
|
||||
self.assertRaises(rpc.RemoteError,
|
||||
self.compute.live_migration,
|
||||
c, i_ref['id'], i_ref['host'])
|
||||
self.mox.ResetAll()
|
||||
|
||||
def test_live_migration_instance_has_no_volume_and_exception(self):
|
||||
"""Simpler than
|
||||
test_live_migration_instance_has_volume_and_exception
|
||||
"""
|
||||
def test_live_migration_dest_raises_exception_no_volume(self):
|
||||
"""Same as above test(input pattern is different) """
|
||||
i_ref = self._get_dummy_instance()
|
||||
i_ref.__setitem__('volumes', [])
|
||||
c = context.get_admin_context()
|
||||
@@ -520,10 +492,9 @@ class ComputeTestCase(test.TestCase):
|
||||
self.assertRaises(rpc.RemoteError,
|
||||
self.compute.live_migration,
|
||||
c, i_ref['id'], i_ref['host'])
|
||||
self.mox.ResetAll()
|
||||
|
||||
def test_live_migration_instance_has_no_volume(self):
|
||||
"""Simpler than test_live_migration_instance_has_volume."""
|
||||
def test_live_migration_works_correctly_no_volume(self):
|
||||
"""Confirm live_migration() works as expected correctly."""
|
||||
i_ref = self._get_dummy_instance()
|
||||
i_ref.__setitem__('volumes', [])
|
||||
c = context.get_admin_context()
|
||||
@@ -545,11 +516,9 @@ class ComputeTestCase(test.TestCase):
|
||||
self.mox.ReplayAll()
|
||||
ret = self.compute.live_migration(c, i_ref['id'], i_ref['host'])
|
||||
self.assertEqual(ret, None)
|
||||
self.mox.ResetAll()
|
||||
|
||||
def test_post_live_migration_working_correctly(self):
|
||||
"""post_live_migration works as expected correctly """
|
||||
|
||||
"""Confirm post_live_migration() works as expected correctly."""
|
||||
dest = 'desthost'
|
||||
flo_addr = '1.2.1.2'
|
||||
|
||||
@@ -579,19 +548,15 @@ class ComputeTestCase(test.TestCase):
|
||||
# executing
|
||||
self.mox.ReplayAll()
|
||||
ret = self.compute.post_live_migration(c, i_ref, dest)
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
# make sure every data is rewritten to dest
|
||||
i_ref = db.instance_get(c, i_ref['id'])
|
||||
c1 = (i_ref['host'] == dest)
|
||||
v_ref = db.volume_get(c, v_ref['id'])
|
||||
c2 = (v_ref['host'] == dest)
|
||||
c3 = False
|
||||
flo_refs = db.floating_ip_get_all_by_host(c, dest)
|
||||
c3 = (len(flo_refs) != 0 and flo_refs[0]['address'] == flo_addr)
|
||||
c2 = (len(flo_refs) != 0 and flo_refs[0]['address'] == flo_addr)
|
||||
|
||||
# post operaton
|
||||
self.assertTrue(c1 and c2 and c3)
|
||||
self.assertTrue(c1 and c2)
|
||||
db.instance_destroy(c, instance_id)
|
||||
db.volume_destroy(c, v_ref['id'])
|
||||
db.floating_ip_destroy(c, flo_addr)
|
||||
|
||||
@@ -108,22 +108,21 @@ class SchedulerTestCase(test.TestCase):
|
||||
self.mox.ReplayAll()
|
||||
scheduler.named_method(ctxt, 'topic', num=7)
|
||||
|
||||
def test_show_host_resource_host_not_exit(self):
|
||||
"""
|
||||
A testcase of driver.has_enough_resource
|
||||
given host does not exists.
|
||||
"""
|
||||
def test_show_host_resources_host_not_exit(self):
|
||||
"""A host given as an argument does not exists."""
|
||||
|
||||
scheduler = manager.SchedulerManager()
|
||||
dest = 'dummydest'
|
||||
ctxt = context.get_admin_context()
|
||||
|
||||
try:
|
||||
scheduler.show_host_resource(ctxt, dest)
|
||||
scheduler.show_host_resources(ctxt, dest)
|
||||
except exception.NotFound, e:
|
||||
c1 = (0 <= e.message.find('does not exist or not compute node'))
|
||||
self.assertTrue(c1)
|
||||
|
||||
def _dic_is_equal(self, dic1, dic2, keys=None):
|
||||
"""Compares 2 dictionary contents(Helper method)"""
|
||||
if not keys:
|
||||
keys = ['vcpus', 'memory_mb', 'local_gb',
|
||||
'vcpus_used', 'memory_mb_used', 'local_gb_used']
|
||||
@@ -133,16 +132,14 @@ class SchedulerTestCase(test.TestCase):
|
||||
return False
|
||||
return True
|
||||
|
||||
def test_show_host_resource_no_project(self):
|
||||
"""
|
||||
A testcase of driver.show_host_resource
|
||||
no instance stays on the given host
|
||||
"""
|
||||
def test_show_host_resources_no_project(self):
|
||||
"""No instance are running on the given host."""
|
||||
|
||||
scheduler = manager.SchedulerManager()
|
||||
ctxt = context.get_admin_context()
|
||||
s_ref = self._create_compute_service()
|
||||
|
||||
result = scheduler.show_host_resource(ctxt, s_ref['host'])
|
||||
result = scheduler.show_host_resources(ctxt, s_ref['host'])
|
||||
|
||||
# result checking
|
||||
c1 = ('resource' in result and 'usage' in result)
|
||||
@@ -152,11 +149,9 @@ class SchedulerTestCase(test.TestCase):
|
||||
self.assertTrue(c1 and c2 and c3)
|
||||
db.service_destroy(ctxt, s_ref['id'])
|
||||
|
||||
def test_show_host_resource_works_correctly(self):
|
||||
"""
|
||||
A testcase of driver.show_host_resource
|
||||
to make sure everything finished with no error.
|
||||
"""
|
||||
def test_show_host_resources_works_correctly(self):
|
||||
"""show_host_resources() works correctly as expected."""
|
||||
|
||||
scheduler = manager.SchedulerManager()
|
||||
ctxt = context.get_admin_context()
|
||||
s_ref = self._create_compute_service()
|
||||
@@ -164,7 +159,7 @@ class SchedulerTestCase(test.TestCase):
|
||||
i_ref2 = self._create_instance(project_id='p-02', vcpus=3,
|
||||
host=s_ref['host'])
|
||||
|
||||
result = scheduler.show_host_resource(ctxt, s_ref['host'])
|
||||
result = scheduler.show_host_resources(ctxt, s_ref['host'])
|
||||
|
||||
c1 = ('resource' in result and 'usage' in result)
|
||||
compute_service = s_ref['compute_service'][0]
|
||||
@@ -284,6 +279,7 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
return db.volume_create(self.context, vol)['id']
|
||||
|
||||
def _create_compute_service(self, **kwargs):
|
||||
"""Create a compute service."""
|
||||
|
||||
dic = {'binary': 'nova-compute', 'topic': 'compute',
|
||||
'report_count': 0, 'availability_zone': 'dummyzone'}
|
||||
@@ -698,13 +694,13 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
volume1.kill()
|
||||
volume2.kill()
|
||||
|
||||
def test_scheduler_live_migraiton_with_volume(self):
|
||||
"""
|
||||
driver.scheduler_live_migration finishes successfully
|
||||
(volumes are attached to instances)
|
||||
This testcase make sure schedule_live_migration
|
||||
changes instance state from 'running' -> 'migrating'
|
||||
def test_scheduler_live_migration_with_volume(self):
|
||||
"""scheduler_live_migration() works correctly as expected.
|
||||
|
||||
Also, checks instance state is changed from 'running' -> 'migrating'.
|
||||
|
||||
"""
|
||||
|
||||
instance_id = self._create_instance()
|
||||
i_ref = db.instance_get(self.context, instance_id)
|
||||
dic = {'instance_id': instance_id, 'size': 1}
|
||||
@@ -737,11 +733,9 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
db.volume_destroy(self.context, v_ref['id'])
|
||||
|
||||
def test_live_migraiton_src_check_instance_not_running(self):
|
||||
"""
|
||||
A testcase of driver._live_migration_src_check.
|
||||
The instance given by instance_id is not running.
|
||||
"""
|
||||
def test_live_migration_src_check_instance_not_running(self):
|
||||
"""The instance given by instance_id is not running."""
|
||||
|
||||
instance_id = self._create_instance(state_description='migrating')
|
||||
i_ref = db.instance_get(self.context, instance_id)
|
||||
|
||||
@@ -754,12 +748,9 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
self.assertTrue(c)
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
|
||||
def test_live_migraiton_src_check_volume_node_not_alive(self):
|
||||
"""
|
||||
A testcase of driver._live_migration_src_check.
|
||||
Volume node is not alive if any volumes are attached to
|
||||
the given instance.
|
||||
"""
|
||||
def test_live_migration_src_check_volume_node_not_alive(self):
|
||||
"""Raise exception when volume node is not alive."""
|
||||
|
||||
instance_id = self._create_instance()
|
||||
i_ref = db.instance_get(self.context, instance_id)
|
||||
dic = {'instance_id': instance_id, 'size': 1}
|
||||
@@ -782,11 +773,8 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
db.volume_destroy(self.context, v_ref['id'])
|
||||
|
||||
def test_live_migraiton_src_check_compute_node_not_alive(self):
|
||||
"""
|
||||
A testcase of driver._live_migration_src_check.
|
||||
The testcase make sure src-compute node is alive.
|
||||
"""
|
||||
def test_live_migration_src_check_compute_node_not_alive(self):
|
||||
"""Confirms src-compute node is alive."""
|
||||
instance_id = self._create_instance()
|
||||
i_ref = db.instance_get(self.context, instance_id)
|
||||
t = datetime.datetime.utcnow() - datetime.timedelta(10)
|
||||
@@ -803,11 +791,8 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
|
||||
def test_live_migraiton_src_check_works_correctly(self):
|
||||
"""
|
||||
A testcase of driver._live_migration_src_check.
|
||||
The testcase make sure everything finished with no error.
|
||||
"""
|
||||
def test_live_migration_src_check_works_correctly(self):
|
||||
"""Confirms this method finishes with no error."""
|
||||
instance_id = self._create_instance()
|
||||
i_ref = db.instance_get(self.context, instance_id)
|
||||
s_ref = self._create_compute_service(host=i_ref['host'])
|
||||
@@ -819,11 +804,8 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
|
||||
def test_live_migraiton_dest_check_not_alive(self):
|
||||
"""
|
||||
A testcase of driver._live_migration_dst_check.
|
||||
Destination host does not exist.
|
||||
"""
|
||||
def test_live_migration_dest_check_not_alive(self):
|
||||
"""Confirms exception raises in case dest host does not exist."""
|
||||
instance_id = self._create_instance()
|
||||
i_ref = db.instance_get(self.context, instance_id)
|
||||
t = datetime.datetime.utcnow() - datetime.timedelta(10)
|
||||
@@ -841,11 +823,8 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
|
||||
def test_live_migraiton_dest_check_service_same_host(self):
|
||||
"""
|
||||
A testcase of driver._live_migration_dst_check.
|
||||
Destination host is same as src host.
|
||||
"""
|
||||
def test_live_migration_dest_check_service_same_host(self):
|
||||
"""Confirms exceptioin raises in case dest and src is same host."""
|
||||
instance_id = self._create_instance()
|
||||
i_ref = db.instance_get(self.context, instance_id)
|
||||
s_ref = self._create_compute_service(host=i_ref['host'])
|
||||
@@ -861,11 +840,8 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
|
||||
def test_live_migraiton_dest_check_service_lack_memory(self):
|
||||
"""
|
||||
A testcase of driver._live_migration_dst_check.
|
||||
destination host doesnt have enough memory.
|
||||
"""
|
||||
def test_live_migration_dest_check_service_lack_memory(self):
|
||||
"""Confirms exception raises when dest doesn't have enough memory."""
|
||||
instance_id = self._create_instance()
|
||||
i_ref = db.instance_get(self.context, instance_id)
|
||||
s_ref = self._create_compute_service(host='somewhere',
|
||||
@@ -882,11 +858,8 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
|
||||
def test_live_migraiton_dest_check_service_works_correctly(self):
|
||||
"""
|
||||
A testcase of driver._live_migration_dst_check.
|
||||
The testcase make sure everything finished with no error.
|
||||
"""
|
||||
def test_live_migration_dest_check_service_works_correctly(self):
|
||||
"""Confirms method finishes with no error."""
|
||||
instance_id = self._create_instance()
|
||||
i_ref = db.instance_get(self.context, instance_id)
|
||||
s_ref = self._create_compute_service(host='somewhere',
|
||||
@@ -899,13 +872,11 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
|
||||
def test_live_migraiton_common_check_service_orig_not_exists(self):
|
||||
"""
|
||||
A testcase of driver._live_migration_common_check.
|
||||
Destination host does not exist.
|
||||
"""
|
||||
def test_live_migration_common_check_service_orig_not_exists(self):
|
||||
"""Destination host does not exist."""
|
||||
|
||||
dest = 'dummydest'
|
||||
# mocks for live_migraiton_common_check()
|
||||
# mocks for live_migration_common_check()
|
||||
instance_id = self._create_instance()
|
||||
i_ref = db.instance_get(self.context, instance_id)
|
||||
t1 = datetime.datetime.utcnow() - datetime.timedelta(10)
|
||||
@@ -929,18 +900,15 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
i_ref,
|
||||
dest)
|
||||
except exception.Invalid, e:
|
||||
c = (e.message.find('does not exists') >= 0)
|
||||
c = (e.message.find('does not exist') >= 0)
|
||||
|
||||
self.assertTrue(c)
|
||||
self.mox.UnsetStubs()
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
|
||||
def test_live_migraiton_common_check_service_different_hypervisor(self):
|
||||
"""
|
||||
A testcase of driver._live_migration_common_check.
|
||||
Original host and dest host has different hypervisor type.
|
||||
"""
|
||||
def test_live_migration_common_check_service_different_hypervisor(self):
|
||||
"""Original host and dest host has different hypervisor type."""
|
||||
dest = 'dummydest'
|
||||
instance_id = self._create_instance()
|
||||
i_ref = db.instance_get(self.context, instance_id)
|
||||
@@ -969,11 +937,8 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
db.service_destroy(self.context, s_ref2['id'])
|
||||
|
||||
def test_live_migraiton_common_check_service_different_version(self):
|
||||
"""
|
||||
A testcase of driver._live_migration_common_check.
|
||||
Original host and dest host has different hypervisor version.
|
||||
"""
|
||||
def test_live_migration_common_check_service_different_version(self):
|
||||
"""Original host and dest host has different hypervisor version."""
|
||||
dest = 'dummydest'
|
||||
instance_id = self._create_instance()
|
||||
i_ref = db.instance_get(self.context, instance_id)
|
||||
@@ -1003,11 +968,9 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
db.service_destroy(self.context, s_ref2['id'])
|
||||
|
||||
def test_live_migraiton_common_check_service_checking_cpuinfo_fail(self):
|
||||
"""
|
||||
A testcase of driver._live_migration_common_check.
|
||||
Original host and dest host has different hypervisor version.
|
||||
"""
|
||||
def test_live_migration_common_check_checking_cpuinfo_fail(self):
|
||||
"""Raise excetion when original host doen't have compatible cpu."""
|
||||
|
||||
dest = 'dummydest'
|
||||
instance_id = self._create_instance()
|
||||
i_ref = db.instance_get(self.context, instance_id)
|
||||
@@ -1025,7 +988,7 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
rpc.call(mox.IgnoreArg(), mox.IgnoreArg(),
|
||||
{"method": 'compare_cpu',
|
||||
"args": {'cpu_info': s_ref2['compute_service'][0]['cpu_info']}}).\
|
||||
AndRaise(rpc.RemoteError('doesnt have compatibility to', '', ''))
|
||||
AndRaise(rpc.RemoteError("doesn't have compatibility to", "", ""))
|
||||
|
||||
self.mox.ReplayAll()
|
||||
try:
|
||||
@@ -1033,7 +996,7 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
i_ref,
|
||||
dest)
|
||||
except rpc.RemoteError, e:
|
||||
c = (e.message.find(_('doesnt have compatibility to')) >= 0)
|
||||
c = (e.message.find(_("doesn't have compatibility to")) >= 0)
|
||||
|
||||
self.assertTrue(c)
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
@@ -23,8 +23,8 @@ from nova import context
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova import flags
|
||||
from nova import test
|
||||
from nova import logging
|
||||
from nova import test
|
||||
from nova import utils
|
||||
from nova.api.ec2 import cloud
|
||||
from nova.auth import manager
|
||||
@@ -76,12 +76,12 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
'bridge': 'br101',
|
||||
'instance_type': 'm1.small'}
|
||||
|
||||
def _driver_dependent_test_setup(self):
|
||||
"""
|
||||
Setup method.
|
||||
Call this method at the top of each testcase method,
|
||||
if the testcase is necessary libvirt and cheetah.
|
||||
"""
|
||||
def _driver_dependant_test_setup(self):
|
||||
"""Call this method at the top of each testcase method.
|
||||
|
||||
Checks if libvirt and cheetah, etc is installed.
|
||||
Otherwise, skip testing."""
|
||||
|
||||
try:
|
||||
global libvirt
|
||||
global libxml2
|
||||
@@ -92,10 +92,9 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
except ImportError, e:
|
||||
logging.warn("""This test has not been done since """
|
||||
"""using driver-dependent library Cheetah/libvirt/libxml2.""")
|
||||
raise e
|
||||
raise
|
||||
|
||||
# inebitable mocks for calling
|
||||
#nova.virt.libvirt_conn.LibvirtConnection.__init__
|
||||
obj = utils.import_object(FLAGS.firewall_driver)
|
||||
fwmock = self.mox.CreateMock(obj)
|
||||
self.mox.StubOutWithMock(libvirt_conn, 'utils',
|
||||
@@ -258,51 +257,31 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
self.assertEquals(uri, testuri)
|
||||
|
||||
def test_get_vcpu_total(self):
|
||||
"""
|
||||
Check if get_vcpu_total returns appropriate cpu value
|
||||
Connection/OS/driver differenct does not matter for this method,
|
||||
everyone can execute for checking.
|
||||
"""
|
||||
"""Check if get_vcpu_total returns appropriate cpu value."""
|
||||
try:
|
||||
self._driver_dependent_test_setup()
|
||||
self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
|
||||
self.mox.ReplayAll()
|
||||
conn = libvirt_conn.LibvirtConnection(False)
|
||||
self.assertTrue(0 < conn.get_vcpu_total())
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
def test_get_memory_mb_total(self):
|
||||
"""Check if get_memory_mb returns appropriate memory value"""
|
||||
"""Check if get_memory_mb returns appropriate memory value."""
|
||||
try:
|
||||
self._driver_dependent_test_setup()
|
||||
self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
|
||||
self.mox.ReplayAll()
|
||||
conn = libvirt_conn.LibvirtConnection(False)
|
||||
self.assertTrue(0 < conn.get_memory_mb_total())
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
def test_get_local_gb_total(self):
|
||||
"""Check if get_local_gb_total returns appropriate disk value"""
|
||||
# Note(masumotok): leave this b/c FLAGS.instances_path is inevitable..
|
||||
#try:
|
||||
# self._driver_dependent_test_setup()
|
||||
#except:
|
||||
# return
|
||||
#
|
||||
#self.mox.ReplayAll()
|
||||
#conn = libvirt_conn.LibvirtConnection(False)
|
||||
#self.assertTrue(0 < conn.get_local_gb_total())
|
||||
#self.mox.UnsetStubs()
|
||||
pass
|
||||
|
||||
def test_get_vcpu_used(self):
|
||||
"""Check if get_local_gb_total returns appropriate disk value"""
|
||||
"""Check if get_local_gb_total returns appropriate disk value."""
|
||||
try:
|
||||
self._driver_dependent_test_setup()
|
||||
self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
|
||||
@@ -321,52 +300,45 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
self.mox.ReplayAll()
|
||||
conn = libvirt_conn.LibvirtConnection(False)
|
||||
self.assertTrue(conn.get_vcpu_used() == 4)
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
def test_get_memory_mb_used(self):
|
||||
"""Check if get_memory_mb returns appropriate memory value"""
|
||||
"""Check if get_memory_mb returns appropriate memory value."""
|
||||
try:
|
||||
self._driver_dependent_test_setup()
|
||||
self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
|
||||
self.mox.ReplayAll()
|
||||
conn = libvirt_conn.LibvirtConnection(False)
|
||||
self.assertTrue(0 < conn.get_memory_mb_used())
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
def test_get_local_gb_used(self):
|
||||
"""Check if get_local_gb_total returns appropriate disk value"""
|
||||
# Note(masumotok): leave this b/c FLAGS.instances_path is inevitable
|
||||
#try:
|
||||
# self._driver_dependent_test_setup()
|
||||
#except:
|
||||
# return
|
||||
|
||||
#self.mox.ReplayAll()
|
||||
#conn = libvirt_conn.LibvirtConnection(False)
|
||||
#self.assertTrue(0 < conn.get_local_gb_used())
|
||||
#self.mox.UnsetStubs()
|
||||
pass
|
||||
|
||||
def test_get_cpu_info_works_correctly(self):
|
||||
"""
|
||||
Check if get_cpu_info works correctly.
|
||||
(in case libvirt.getCapabilities() works correctly)
|
||||
"""
|
||||
xml = ("""<cpu><arch>x86_64</arch><model>Nehalem</model>"""
|
||||
"""<vendor>Intel</vendor><topology sockets='2' """
|
||||
"""cores='4' threads='2'/><feature name='rdtscp'/>"""
|
||||
"""<feature name='dca'/><feature name='xtpr'/>"""
|
||||
"""<feature name='tm2'/><feature name='est'/>"""
|
||||
"""<feature name='vmx'/><feature name='ds_cpl'/>"""
|
||||
"""<feature name='monitor'/><feature name='pbe'/>"""
|
||||
"""<feature name='tm'/><feature name='ht'/>"""
|
||||
"""<feature name='ss'/><feature name='acpi'/>"""
|
||||
"""<feature name='ds'/><feature name='vme'/></cpu>""")
|
||||
"""Check if get_cpu_info works correctly as expected."""
|
||||
xml = """<cpu>
|
||||
<arch>x86_64</arch>
|
||||
<model>Nehalem</model>
|
||||
<vendor>Intel</vendor>
|
||||
<topology sockets='2' cores='4' threads='2'/>
|
||||
<feature name='rdtscp'/>
|
||||
<feature name='dca'/>
|
||||
<feature name='xtpr'/>
|
||||
<feature name='tm2'/>
|
||||
<feature name='est'/>
|
||||
<feature name='vmx'/>
|
||||
<feature name='ds_cpl'/>
|
||||
<feature name='monitor'/>
|
||||
<feature name='pbe'/>
|
||||
<feature name='tm'/>
|
||||
<feature name='ht'/>
|
||||
<feature name='ss'/>
|
||||
<feature name='acpi'/>
|
||||
<feature name='ds'/>
|
||||
<feature name='vme'/>
|
||||
</cpu>
|
||||
"""
|
||||
|
||||
try:
|
||||
self._driver_dependent_test_setup()
|
||||
self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
self.mox.StubOutWithMock(libvirt_conn.LibvirtConnection,
|
||||
@@ -376,27 +348,34 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
self.mox.ReplayAll()
|
||||
conn = libvirt_conn.LibvirtConnection(False)
|
||||
self.assertTrue(0 < len(conn.get_cpu_info()))
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
def test_get_cpu_info_inappropreate_xml(self):
|
||||
"""
|
||||
Check if get_cpu_info raises exception
|
||||
in case libvirt.getCapabilities() returns wrong xml
|
||||
(in case of xml doesnt have <cpu> tag)
|
||||
"""
|
||||
xml = ("""<cccccpu><arch>x86_64</arch><model>Nehalem</model>"""
|
||||
"""<vendor>Intel</vendor><topology sockets='2' """
|
||||
"""cores='4' threads='2'/><feature name='rdtscp'/>"""
|
||||
"""<feature name='dca'/><feature name='xtpr'/>"""
|
||||
"""<feature name='tm2'/><feature name='est'/>"""
|
||||
"""<feature name='vmx'/><feature name='ds_cpl'/>"""
|
||||
"""<feature name='monitor'/><feature name='pbe'/>"""
|
||||
"""<feature name='tm'/><feature name='ht'/>"""
|
||||
"""<feature name='ss'/><feature name='acpi'/>"""
|
||||
"""<feature name='ds'/><feature name='vme'/></cccccpu>""")
|
||||
"""Raise exception if given xml is inappropriate."""
|
||||
xml = """<cccccpu>
|
||||
<arch>x86_64</arch>
|
||||
<model>Nehalem</model>
|
||||
<vendor>Intel</vendor>
|
||||
<topology sockets='2' cores='4' threads='2'/>
|
||||
<feature name='rdtscp'/>
|
||||
<feature name='dca'/>
|
||||
<feature name='xtpr'/>
|
||||
<feature name='tm2'/>
|
||||
<feature name='est'/>
|
||||
<feature name='vmx'/>
|
||||
<feature name='ds_cpl'/>
|
||||
<feature name='monitor'/>
|
||||
<feature name='pbe'/>
|
||||
<feature name='tm'/>
|
||||
<feature name='ht'/>
|
||||
<feature name='ss'/>
|
||||
<feature name='acpi'/>
|
||||
<feature name='ds'/>
|
||||
<feature name='vme'/>
|
||||
</cccccpu>
|
||||
"""
|
||||
|
||||
try:
|
||||
self._driver_dependent_test_setup()
|
||||
self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
self.mox.StubOutWithMock(libvirt_conn.LibvirtConnection,
|
||||
@@ -409,29 +388,34 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
conn.get_cpu_info()
|
||||
except exception.Invalid, e:
|
||||
c1 = (0 <= e.message.find('Invalid xml'))
|
||||
self.assertTrue(c1)
|
||||
self.mox.UnsetStubs()
|
||||
self.assertTrue(c1)
|
||||
|
||||
def test_get_cpu_info_inappropreate_xml2(self):
|
||||
"""
|
||||
Check if get_cpu_info raises exception
|
||||
in case libvirt.getCapabilities() returns wrong xml
|
||||
(in case of xml doesnt have inproper <topology> tag
|
||||
meaning missing "socket" attribute)
|
||||
"""
|
||||
xml = ("""<cpu><arch>x86_64</arch><model>Nehalem</model>"""
|
||||
"""<vendor>Intel</vendor><topology """
|
||||
"""cores='4' threads='2'/><feature name='rdtscp'/>"""
|
||||
"""<feature name='dca'/><feature name='xtpr'/>"""
|
||||
"""<feature name='tm2'/><feature name='est'/>"""
|
||||
"""<feature name='vmx'/><feature name='ds_cpl'/>"""
|
||||
"""<feature name='monitor'/><feature name='pbe'/>"""
|
||||
"""<feature name='tm'/><feature name='ht'/>"""
|
||||
"""<feature name='ss'/><feature name='acpi'/>"""
|
||||
"""<feature name='ds'/><feature name='vme'/></cpu>""")
|
||||
"""Raise exception if given xml is inappropriate(topology tag)."""
|
||||
|
||||
xml = """<cpu>
|
||||
<arch>x86_64</arch>
|
||||
<model>Nehalem</model>
|
||||
<vendor>Intel</vendor><topology cores='4' threads='2'/>
|
||||
<feature name='rdtscp'/>
|
||||
<feature name='dca'/>
|
||||
<feature name='xtpr'/>
|
||||
<feature name='tm2'/>
|
||||
<feature name='est'/>
|
||||
<feature name='vmx'/>
|
||||
<feature name='ds_cpl'/>
|
||||
<feature name='monitor'/>
|
||||
<feature name='pbe'/>
|
||||
<feature name='tm'/>
|
||||
<feature name='ht'/>
|
||||
<feature name='ss'/>
|
||||
<feature name='acpi'/>
|
||||
<feature name='ds'/>
|
||||
<feature name='vme'/>
|
||||
</cpu>
|
||||
"""
|
||||
try:
|
||||
self._driver_dependent_test_setup()
|
||||
self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
self.mox.StubOutWithMock(libvirt_conn.LibvirtConnection,
|
||||
@@ -444,29 +428,12 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
conn.get_cpu_info()
|
||||
except exception.Invalid, e:
|
||||
c1 = (0 <= e.message.find('Invalid xml: topology'))
|
||||
self.assertTrue(c1)
|
||||
self.mox.UnsetStubs()
|
||||
self.assertTrue(c1)
|
||||
|
||||
def test_update_available_resource_works_correctly(self):
|
||||
"""
|
||||
In this method, vcpus/memory_mb/local_gb/vcpu_used/
|
||||
memory_mb_used/local_gb_used/hypervisor_type/
|
||||
hypervisor_version/cpu_info should be changed.
|
||||
Based on this specification, this testcase confirms
|
||||
if this method finishes successfully,
|
||||
meaning self.db.service_update must be called with dictinary
|
||||
|
||||
{'vcpu':aaa, 'memory_mb':bbb, 'local_gb':ccc,
|
||||
'vcpu_used':aaa, 'memory_mb_used':bbb, 'local_gb_sed':ccc,
|
||||
'hypervisor_type':ddd, 'hypervisor_version':eee,
|
||||
'cpu_info':fff}
|
||||
|
||||
Since each value of above dict can be obtained through
|
||||
driver(different depends on environment),
|
||||
only dictionary keys are checked.
|
||||
"""
|
||||
"""Confirm compute_service table is updated successfully."""
|
||||
try:
|
||||
self._driver_dependent_test_setup()
|
||||
self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
|
||||
@@ -478,7 +445,9 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
|
||||
host = 'foo'
|
||||
binary = 'nova-compute'
|
||||
service_ref = {'id': 1, 'host': host, 'binary': binary,
|
||||
service_ref = {'id': 1,
|
||||
'host': host,
|
||||
'binary': binary,
|
||||
'topic': 'compute'}
|
||||
|
||||
self.mox.StubOutWithMock(db, 'service_get_all_by_topic')
|
||||
@@ -491,15 +460,11 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
self.mox.ReplayAll()
|
||||
conn = libvirt_conn.LibvirtConnection(False)
|
||||
conn.update_available_resource(host)
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
def test_update_resource_info_raise_exception(self):
|
||||
"""
|
||||
This testcase confirms if no record found on Service
|
||||
table, exception can be raised.
|
||||
"""
|
||||
"""Raise exception if no recorde found on services table."""
|
||||
try:
|
||||
self._driver_dependent_test_setup()
|
||||
self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
|
||||
@@ -518,18 +483,19 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
msg = 'Cannot insert compute manager specific info'
|
||||
c1 = (0 <= e.message.find(msg))
|
||||
self.assertTrue(c1)
|
||||
self.mox.ResetAll()
|
||||
|
||||
def test_compare_cpu_works_correctly(self):
|
||||
"""Calling libvirt.compute_cpu() and works correctly """
|
||||
|
||||
t = ("""{"arch":"%s", "model":"%s", "vendor":"%s", """
|
||||
""""topology":{"cores":"%s", "threads":"%s", """
|
||||
""""sockets":"%s"}, "features":[%s]}""")
|
||||
cpu_info = t % ('x86', 'model', 'vendor', '2', '1', '4', '"tm"')
|
||||
"""Calling libvirt.compute_cpu() and works correctly."""
|
||||
t = {}
|
||||
t['arch'] = 'x86'
|
||||
t['model'] = 'model'
|
||||
t['vendor'] = 'Intel'
|
||||
t['topology'] = {'cores': "2", "threads": "1", "sockets": "4"}
|
||||
t['features'] = ["tm"]
|
||||
cpu_info = utils.dumps(t)
|
||||
|
||||
try:
|
||||
self._driver_dependent_test_setup()
|
||||
self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
|
||||
@@ -542,20 +508,19 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
self.mox.ReplayAll()
|
||||
conn = libvirt_conn.LibvirtConnection(False)
|
||||
self.assertTrue(None == conn.compare_cpu(cpu_info))
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
def test_compare_cpu_raises_exception(self):
|
||||
"""
|
||||
Libvirt-related exception occurs when calling
|
||||
libvirt.compare_cpu().
|
||||
"""
|
||||
t = ("""{"arch":"%s", "model":"%s", "vendor":"%s", """
|
||||
""""topology":{"cores":"%s", "threads":"%s", """
|
||||
""""sockets":"%s"}, "features":[%s]}""")
|
||||
cpu_info = t % ('x86', 'model', 'vendor', '2', '1', '4', '"tm"')
|
||||
"""Libvirt-related exception occurs when calling compare_cpu()."""
|
||||
t = {}
|
||||
t['arch'] = 'x86'
|
||||
t['model'] = 'model'
|
||||
t['vendor'] = 'Intel'
|
||||
t['topology'] = {'cores': "2", "threads": "1", "sockets": "4"}
|
||||
t['features'] = ["tm"]
|
||||
cpu_info = utils.dumps(t)
|
||||
|
||||
try:
|
||||
self._driver_dependent_test_setup()
|
||||
self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
|
||||
@@ -567,18 +532,19 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
self.mox.ReplayAll()
|
||||
conn = libvirt_conn.LibvirtConnection(False)
|
||||
self.assertRaises(libvirt.libvirtError, conn.compare_cpu, cpu_info)
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
def test_compare_cpu_no_compatibility(self):
|
||||
"""libvirt.compare_cpu() return less than 0.(no compatibility)"""
|
||||
|
||||
t = ("""{"arch":"%s", "model":"%s", "vendor":"%s", """
|
||||
""""topology":{"cores":"%s", "threads":"%s", """
|
||||
""""sockets":"%s"}, "features":[%s]}""")
|
||||
cpu_info = t % ('x86', 'model', 'vendor', '2', '1', '4', '"tm"')
|
||||
"""Libvirt.compare_cpu() return less than 0.(no compatibility)."""
|
||||
t = {}
|
||||
t['arch'] = 'x86'
|
||||
t['model'] = 'model'
|
||||
t['vendor'] = 'Intel'
|
||||
t['topology'] = {'cores': "2", "threads": "1", "sockets": "4"}
|
||||
t['features'] = ["tm"]
|
||||
cpu_info = utils.dumps(t)
|
||||
|
||||
try:
|
||||
self._driver_dependent_test_setup()
|
||||
self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
|
||||
@@ -590,16 +556,14 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
self.mox.ReplayAll()
|
||||
conn = libvirt_conn.LibvirtConnection(False)
|
||||
self.assertRaises(exception.Invalid, conn.compare_cpu, cpu_info)
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
def test_ensure_filtering_rules_for_instance_works_correctly(self):
|
||||
"""ensure_filtering_rules_for_instance works as expected correctly"""
|
||||
|
||||
"""ensure_filtering_rules_for_instance() works successfully."""
|
||||
instance_ref = models.Instance()
|
||||
instance_ref.__setitem__('id', 1)
|
||||
|
||||
try:
|
||||
nwmock, fwmock = self._driver_dependent_test_setup()
|
||||
nwmock, fwmock = self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
|
||||
@@ -613,16 +577,14 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
self.mox.ReplayAll()
|
||||
conn = libvirt_conn.LibvirtConnection(False)
|
||||
conn.ensure_filtering_rules_for_instance(instance_ref)
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
def test_ensure_filtering_rules_for_instance_timeout(self):
|
||||
"""ensure_filtering_fules_for_instance finishes with timeout"""
|
||||
|
||||
"""ensure_filtering_fules_for_instance() finishes with timeout."""
|
||||
instance_ref = models.Instance()
|
||||
instance_ref.__setitem__('id', 1)
|
||||
|
||||
try:
|
||||
nwmock, fwmock = self._driver_dependent_test_setup()
|
||||
nwmock, fwmock = self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
|
||||
@@ -642,11 +604,9 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
except exception.Error, e:
|
||||
c1 = (0 <= e.message.find('Timeout migrating for'))
|
||||
self.assertTrue(c1)
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
def test_live_migration_works_correctly(self):
|
||||
"""_live_migration works as expected correctly """
|
||||
|
||||
"""_live_migration() works as expected correctly."""
|
||||
class dummyCall(object):
|
||||
f = None
|
||||
|
||||
@@ -659,7 +619,7 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
ctxt = context.get_admin_context()
|
||||
|
||||
try:
|
||||
self._driver_dependent_test_setup()
|
||||
self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
|
||||
@@ -681,13 +641,9 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
# Not setting post_method/recover_method in this testcase.
|
||||
ret = conn._live_migration(ctxt, i_ref, i_ref['host'], '', '')
|
||||
self.assertTrue(ret == None)
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
def test_live_migration_raises_exception(self):
|
||||
"""
|
||||
_live_migration raises exception, then this testcase confirms
|
||||
recovered method is called.
|
||||
"""
|
||||
"""Confirms recover method is called when exceptions are raised."""
|
||||
i_ref = models.Instance()
|
||||
i_ref.__setitem__('id', 1)
|
||||
i_ref.__setitem__('host', 'dummy')
|
||||
@@ -697,7 +653,7 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
pass
|
||||
|
||||
try:
|
||||
nwmock, fwmock = self._driver_dependent_test_setup()
|
||||
nwmock, fwmock = self._driver_dependant_test_setup()
|
||||
except:
|
||||
return
|
||||
|
||||
@@ -724,7 +680,6 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
conn._mlive_migration,
|
||||
ctxt, instance_ref, dest,
|
||||
'', dummy_recover_method)
|
||||
self.mox.UnsetStubs()
|
||||
|
||||
def tearDown(self):
|
||||
super(LibvirtConnTestCase, self).tearDown()
|
||||
|
||||
Reference in New Issue
Block a user