summaryrefslogtreecommitdiff
path: root/nova/tests
diff options
context:
space:
mode:
authorMichael Wilson <geekinutah@gmail.com>2013-08-05 14:45:40 -0600
committerMichael Wilson <geekinutah@gmail.com>2013-10-25 09:50:00 -0600
commit62e9829c19e099e3a10b2b54954163b5e780363b (patch)
treeed31615df80fd31114816bca0787b7f0c90dc677 /nova/tests
parent6af8c796647d1d1a4fb64bae27e8fa5fce015b0e (diff)
downloadnova-62e9829c19e099e3a10b2b54954163b5e780363b.tar.gz
Allow _sync_power_states periodic task to hit slave DB
This commit allows those who have slave_connection configured to have reads from _sync_power_states hit that connection. This change does not affect anyone who doesn't have a slave. The behavior remains the same for them. Implements: blueprint periodic-tasks-to-db-slave Change-Id: Iaeb2d47a5064a649f427b18d5cbd2b6b97ce90d0
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_disk_config.py3
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_instance_actions.py8
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_security_groups.py10
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_server_start_stop.py3
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_shelve.py6
-rw-r--r--nova/tests/api/openstack/compute/plugins/v3/test_disk_config.py3
-rw-r--r--nova/tests/api/openstack/compute/plugins/v3/test_instance_actions.py6
-rw-r--r--nova/tests/api/openstack/compute/plugins/v3/test_server_actions.py6
-rw-r--r--nova/tests/api/openstack/compute/plugins/v3/test_server_metadata.py8
-rw-r--r--nova/tests/api/openstack/compute/plugins/v3/test_servers.py3
-rw-r--r--nova/tests/api/openstack/compute/plugins/v3/test_shelve.py6
-rw-r--r--nova/tests/api/openstack/compute/test_server_actions.py6
-rw-r--r--nova/tests/api/openstack/compute/test_server_metadata.py8
-rw-r--r--nova/tests/api/openstack/fakes.py2
-rw-r--r--nova/tests/compute/test_compute.py20
-rw-r--r--nova/tests/compute/test_compute_mgr.py12
-rw-r--r--nova/tests/compute/test_compute_xen.py2
-rw-r--r--nova/tests/db/test_db_api.py4
-rw-r--r--nova/tests/objects/test_instance.py75
-rw-r--r--nova/tests/objects/test_migration.py3
-rw-r--r--nova/tests/virt/libvirt/test_libvirt.py6
-rw-r--r--nova/tests/virt/xenapi/test_xenapi.py3
22 files changed, 130 insertions, 73 deletions
diff --git a/nova/tests/api/openstack/compute/contrib/test_disk_config.py b/nova/tests/api/openstack/compute/contrib/test_disk_config.py
index a5c4e1b0e4..5145e02a27 100644
--- a/nova/tests/api/openstack/compute/contrib/test_disk_config.py
+++ b/nova/tests/api/openstack/compute/contrib/test_disk_config.py
@@ -67,7 +67,8 @@ class DiskConfigTestCase(test.TestCase):
self.stubs.Set(db, 'instance_get', fake_instance_get)
- def fake_instance_get_by_uuid(context, uuid, columns_to_join=None):
+ def fake_instance_get_by_uuid(context, uuid,
+ columns_to_join=None, use_slave=False):
for instance in FAKE_INSTANCES:
if uuid == instance['uuid']:
return instance
diff --git a/nova/tests/api/openstack/compute/contrib/test_instance_actions.py b/nova/tests/api/openstack/compute/contrib/test_instance_actions.py
index dedc4f9836..0e931a2302 100644
--- a/nova/tests/api/openstack/compute/contrib/test_instance_actions.py
+++ b/nova/tests/api/openstack/compute/contrib/test_instance_actions.py
@@ -77,7 +77,8 @@ class InstanceActionsPolicyTest(test.NoDBTestCase):
policy.set_rules(rules)
def fake_instance_get_by_uuid(context, instance_id,
- columns_to_join=None):
+ columns_to_join=None,
+ use_slave=False):
return fake_instance.fake_db_instance(
**{'name': 'fake', 'project_id': '%s_unequal' %
context.project_id})
@@ -94,7 +95,8 @@ class InstanceActionsPolicyTest(test.NoDBTestCase):
policy.set_rules(rules)
def fake_instance_get_by_uuid(context, instance_id,
- columns_to_join=None):
+ columns_to_join=None,
+ use_slave=False):
return fake_instance.fake_db_instance(
**{'name': 'fake', 'project_id': '%s_unequal' %
context.project_id})
@@ -116,7 +118,7 @@ class InstanceActionsTest(test.NoDBTestCase):
def fake_get(self, context, instance_uuid):
return {'uuid': instance_uuid}
- def fake_instance_get_by_uuid(context, instance_id):
+ def fake_instance_get_by_uuid(context, instance_id, use_slave=False):
return {'name': 'fake', 'project_id': context.project_id}
self.stubs.Set(compute_api.API, 'get', fake_get)
diff --git a/nova/tests/api/openstack/compute/contrib/test_security_groups.py b/nova/tests/api/openstack/compute/contrib/test_security_groups.py
index 4e3b86168e..530fc5ce1f 100644
--- a/nova/tests/api/openstack/compute/contrib/test_security_groups.py
+++ b/nova/tests/api/openstack/compute/contrib/test_security_groups.py
@@ -80,7 +80,8 @@ def security_group_rule_db(rule, id=None):
return AttrDict(attrs)
-def return_server(context, server_id, columns_to_join=None):
+def return_server(context, server_id,
+ columns_to_join=None, use_slave=False):
return fake_instance.fake_db_instance(
**{'id': int(server_id),
'power_state': 0x01,
@@ -89,7 +90,9 @@ def return_server(context, server_id, columns_to_join=None):
'name': 'asdf'})
-def return_server_by_uuid(context, server_uuid, columns_to_join=None):
+def return_server_by_uuid(context, server_uuid,
+ columns_to_join=None,
+ use_slave=False):
return fake_instance.fake_db_instance(
**{'id': 1,
'power_state': 0x01,
@@ -352,7 +355,8 @@ class TestSecurityGroups(test.TestCase):
groups.append(sg)
expected = {'security_groups': groups}
- def return_instance(context, server_id, columns_to_join=None):
+ def return_instance(context, server_id,
+ columns_to_join=None, use_slave=False):
self.assertEquals(server_id, FAKE_UUID1)
return return_server_by_uuid(context, server_id)
diff --git a/nova/tests/api/openstack/compute/contrib/test_server_start_stop.py b/nova/tests/api/openstack/compute/contrib/test_server_start_stop.py
index 0970e1726d..79ff12c5a1 100644
--- a/nova/tests/api/openstack/compute/contrib/test_server_start_stop.py
+++ b/nova/tests/api/openstack/compute/contrib/test_server_start_stop.py
@@ -23,7 +23,8 @@ from nova import test
from nova.tests.api.openstack import fakes
-def fake_instance_get(context, instance_id, columns_to_join=None):
+def fake_instance_get(context, instance_id,
+ columns_to_join=None, use_slave=False):
result = fakes.stub_instance(id=1, uuid=instance_id)
result['created_at'] = None
result['deleted_at'] = None
diff --git a/nova/tests/api/openstack/compute/contrib/test_shelve.py b/nova/tests/api/openstack/compute/contrib/test_shelve.py
index 8f0ee73a32..df9a24b987 100644
--- a/nova/tests/api/openstack/compute/contrib/test_shelve.py
+++ b/nova/tests/api/openstack/compute/contrib/test_shelve.py
@@ -44,7 +44,7 @@ class ShelvePolicyTest(test.NoDBTestCase):
policy.set_rules(rules)
def fake_instance_get_by_uuid(context, instance_id,
- columns_to_join=None):
+ columns_to_join=None, use_slave=False):
return fake_instance.fake_db_instance(
**{'name': 'fake', 'project_id': '%s_unequal' %
context.project_id})
@@ -70,7 +70,7 @@ class ShelvePolicyTest(test.NoDBTestCase):
policy.set_rules(rules)
def fake_instance_get_by_uuid(context, instance_id,
- columns_to_join=None):
+ columns_to_join=None, use_slave=False):
return fake_instance.fake_db_instance(
**{'name': 'fake', 'project_id': '%s_unequal' %
context.project_id})
@@ -96,7 +96,7 @@ class ShelvePolicyTest(test.NoDBTestCase):
policy.set_rules(rules)
def fake_instance_get_by_uuid(context, instance_id,
- columns_to_join=None):
+ columns_to_join=None, use_slave=False):
return fake_instance.fake_db_instance(
**{'name': 'fake', 'project_id': '%s_unequal' %
context.project_id})
diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_disk_config.py b/nova/tests/api/openstack/compute/plugins/v3/test_disk_config.py
index 3bb9e611a8..5136c52160 100644
--- a/nova/tests/api/openstack/compute/plugins/v3/test_disk_config.py
+++ b/nova/tests/api/openstack/compute/plugins/v3/test_disk_config.py
@@ -68,7 +68,8 @@ class DiskConfigTestCase(test.TestCase):
self.stubs.Set(db, 'instance_get', fake_instance_get)
- def fake_instance_get_by_uuid(context, uuid, columns_to_join=None):
+ def fake_instance_get_by_uuid(context, uuid,
+ columns_to_join=None, use_slave=False):
for instance in FAKE_INSTANCES:
if uuid == instance['uuid']:
return instance
diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_instance_actions.py b/nova/tests/api/openstack/compute/plugins/v3/test_instance_actions.py
index 67d727694b..fa8c10e02f 100644
--- a/nova/tests/api/openstack/compute/plugins/v3/test_instance_actions.py
+++ b/nova/tests/api/openstack/compute/plugins/v3/test_instance_actions.py
@@ -80,7 +80,7 @@ class InstanceActionsPolicyTest(test.NoDBTestCase):
policy.set_rules(rules)
def fake_instance_get_by_uuid(context, instance_id,
- columns_to_join=None):
+ columns_to_join=None, use_slave=False):
return fake_instance.fake_db_instance(
**{'name': 'fake', 'project_id': '%s_unequal' %
context.project_id})
@@ -97,7 +97,7 @@ class InstanceActionsPolicyTest(test.NoDBTestCase):
policy.set_rules(rules)
def fake_instance_get_by_uuid(context, instance_id,
- columns_to_join=None):
+ columns_to_join=None, use_slave=False):
return fake_instance.fake_db_instance(
**{'name': 'fake', 'project_id': '%s_unequal' %
context.project_id})
@@ -120,7 +120,7 @@ class InstanceActionsTest(test.NoDBTestCase):
return {'uuid': instance_uuid}
def fake_instance_get_by_uuid(context, instance_id,
- columns_to_join=None):
+ columns_to_join=None, use_slave=False):
return fake_instance.fake_db_instance(
**{'name': 'fake', 'project_id': '%s_unequal' %
context.project_id})
diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_server_actions.py b/nova/tests/api/openstack/compute/plugins/v3/test_server_actions.py
index 5a34847a03..eb5cfde393 100644
--- a/nova/tests/api/openstack/compute/plugins/v3/test_server_actions.py
+++ b/nova/tests/api/openstack/compute/plugins/v3/test_server_actions.py
@@ -477,7 +477,8 @@ class ServerActionsControllerTest(test.TestCase):
self.assertNotIn('adminPass', body['server'])
def test_rebuild_server_not_found(self):
- def server_not_found(self, instance_id, columns_to_join=None):
+ def server_not_found(self, instance_id,
+ columns_to_join=None, use_slave=False):
raise exception.InstanceNotFound(instance_id=instance_id)
self.stubs.Set(db, 'instance_get_by_uuid', server_not_found)
@@ -1060,7 +1061,8 @@ class ServerActionsControllerTest(test.TestCase):
req, FAKE_UUID, body)
def test_locked(self):
- def fake_locked(context, instance_uuid, columns_to_join=None):
+ def fake_locked(context, instance_uuid,
+ columns_to_join=None, use_slave=False):
return fake_instance.fake_db_instance(name="foo",
uuid=FAKE_UUID,
locked=True)
diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_server_metadata.py b/nova/tests/api/openstack/compute/plugins/v3/test_server_metadata.py
index 170c110bfd..b230341f8c 100644
--- a/nova/tests/api/openstack/compute/plugins/v3/test_server_metadata.py
+++ b/nova/tests/api/openstack/compute/plugins/v3/test_server_metadata.py
@@ -86,7 +86,8 @@ def return_server(context, server_id, columns_to_join=None):
'vm_state': vm_states.ACTIVE})
-def return_server_by_uuid(context, server_uuid, columns_to_join=None):
+def return_server_by_uuid(context, server_uuid,
+ columns_to_join=None, use_slave=False):
return fake_instance.fake_db_instance(
**{'id': 1,
'uuid': '0cc3346e-9fef-4445-abe6-5d2b2690ec64',
@@ -96,7 +97,8 @@ def return_server_by_uuid(context, server_uuid, columns_to_join=None):
'vm_state': vm_states.ACTIVE})
-def return_server_nonexistent(context, server_id, columns_to_join=None):
+def return_server_nonexistent(context, server_id,
+ columns_to_join=None, use_slave=False):
raise exception.InstanceNotFound(instance_id=server_id)
@@ -592,7 +594,7 @@ class BadStateServerMetaDataTest(BaseTest):
'vm_state': vm_states.BUILDING})
def _return_server_in_build_by_uuid(self, context, server_uuid,
- columns_to_join=None):
+ columns_to_join=None, use_slave=False):
return fake_instance.fake_db_instance(
**{'id': 1,
'uuid': '0cc3346e-9fef-4445-abe6-5d2b2690ec64',
diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_servers.py b/nova/tests/api/openstack/compute/plugins/v3/test_servers.py
index c8d6642d17..e713758cb0 100644
--- a/nova/tests/api/openstack/compute/plugins/v3/test_servers.py
+++ b/nova/tests/api/openstack/compute/plugins/v3/test_servers.py
@@ -113,7 +113,8 @@ def fake_start_stop_locked_server(self, context, instance):
raise exception.InstanceIsLocked(instance_uuid=instance['uuid'])
-def fake_instance_get_by_uuid_not_found(context, uuid, columns_to_join):
+def fake_instance_get_by_uuid_not_found(context, uuid,
+ columns_to_join, use_slave=False):
raise exception.InstanceNotFound(instance_id=uuid)
diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_shelve.py b/nova/tests/api/openstack/compute/plugins/v3/test_shelve.py
index 5fd4a2da54..9c069a8e46 100644
--- a/nova/tests/api/openstack/compute/plugins/v3/test_shelve.py
+++ b/nova/tests/api/openstack/compute/plugins/v3/test_shelve.py
@@ -44,7 +44,8 @@ class ShelvePolicyTest(test.NoDBTestCase):
policy.set_rules(rules)
def fake_instance_get_by_uuid(context, instance_id,
- columns_to_join=None):
+ columns_to_join=None,
+ use_slave=False):
return fake_instance.fake_db_instance(
**{'name': 'fake', 'project_id': '%s_unequal' %
context.project_id})
@@ -70,7 +71,8 @@ class ShelvePolicyTest(test.NoDBTestCase):
policy.set_rules(rules)
def fake_instance_get_by_uuid(context, instance_id,
- columns_to_join=None):
+ columns_to_join=None,
+ use_slave=False):
return fake_instance.fake_db_instance(
**{'name': 'fake', 'project_id': '%s_unequal' %
context.project_id})
diff --git a/nova/tests/api/openstack/compute/test_server_actions.py b/nova/tests/api/openstack/compute/test_server_actions.py
index 5a34847a03..eb5cfde393 100644
--- a/nova/tests/api/openstack/compute/test_server_actions.py
+++ b/nova/tests/api/openstack/compute/test_server_actions.py
@@ -477,7 +477,8 @@ class ServerActionsControllerTest(test.TestCase):
self.assertNotIn('adminPass', body['server'])
def test_rebuild_server_not_found(self):
- def server_not_found(self, instance_id, columns_to_join=None):
+ def server_not_found(self, instance_id,
+ columns_to_join=None, use_slave=False):
raise exception.InstanceNotFound(instance_id=instance_id)
self.stubs.Set(db, 'instance_get_by_uuid', server_not_found)
@@ -1060,7 +1061,8 @@ class ServerActionsControllerTest(test.TestCase):
req, FAKE_UUID, body)
def test_locked(self):
- def fake_locked(context, instance_uuid, columns_to_join=None):
+ def fake_locked(context, instance_uuid,
+ columns_to_join=None, use_slave=False):
return fake_instance.fake_db_instance(name="foo",
uuid=FAKE_UUID,
locked=True)
diff --git a/nova/tests/api/openstack/compute/test_server_metadata.py b/nova/tests/api/openstack/compute/test_server_metadata.py
index 7063adcef7..6154ce2cba 100644
--- a/nova/tests/api/openstack/compute/test_server_metadata.py
+++ b/nova/tests/api/openstack/compute/test_server_metadata.py
@@ -84,7 +84,8 @@ def return_server(context, server_id, columns_to_join=None):
'vm_state': vm_states.ACTIVE})
-def return_server_by_uuid(context, server_uuid, columns_to_join=None):
+def return_server_by_uuid(context, server_uuid,
+ columns_to_join=None, use_slave=False):
return fake_instance.fake_db_instance(
**{'id': 1,
'uuid': '0cc3346e-9fef-4445-abe6-5d2b2690ec64',
@@ -94,7 +95,8 @@ def return_server_by_uuid(context, server_uuid, columns_to_join=None):
'vm_state': vm_states.ACTIVE})
-def return_server_nonexistent(context, server_id, columns_to_join=None):
+def return_server_nonexistent(context, server_id,
+ columns_to_join=None, use_slave=False):
raise exception.InstanceNotFound(instance_id=server_id)
@@ -565,7 +567,7 @@ class BadStateServerMetaDataTest(BaseTest):
'vm_state': vm_states.BUILDING})
def _return_server_in_build_by_uuid(self, context, server_uuid,
- columns_to_join=None):
+ columns_to_join=None, use_slave=False):
return fake_instance.fake_db_instance(
**{'id': 1,
'uuid': '0cc3346e-9fef-4445-abe6-5d2b2690ec64',
diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py
index d3499971cd..f5b26155c9 100644
--- a/nova/tests/api/openstack/fakes.py
+++ b/nova/tests/api/openstack/fakes.py
@@ -427,7 +427,7 @@ def get_fake_uuid(token=0):
def fake_instance_get(**kwargs):
- def _return_server(context, uuid, columns_to_join=None):
+ def _return_server(context, uuid, columns_to_join=None, use_slave=False):
return stub_instance(1, **kwargs)
return _return_server
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index 00d818e797..ea9e413fc2 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -4984,12 +4984,14 @@ class ComputeTestCase(BaseTestCase):
call_info = {'get_all_by_host': 0, 'get_by_uuid': 0,
'get_nw_info': 0, 'expected_instance': None}
- def fake_instance_get_all_by_host(context, host, columns_to_join):
+ def fake_instance_get_all_by_host(context, host,
+ columns_to_join, use_slave=False):
call_info['get_all_by_host'] += 1
self.assertEqual([], columns_to_join)
return instances[:]
- def fake_instance_get_by_uuid(context, instance_uuid, columns_to_join):
+ def fake_instance_get_by_uuid(context, instance_uuid,
+ columns_to_join, use_slave=False):
if instance_uuid not in instance_map:
raise exception.InstanceNotFound(instance_id=instance_uuid)
call_info['get_by_uuid'] += 1
@@ -5120,7 +5122,7 @@ class ComputeTestCase(BaseTestCase):
migrations.append(fake_mig)
def fake_instance_get_by_uuid(context, instance_uuid,
- columns_to_join=None):
+ columns_to_join=None, use_slave=False):
self.assertIn('metadata', columns_to_join)
self.assertIn('system_metadata', columns_to_join)
# raise InstanceNotFound exception for uuid 'noexist'
@@ -5660,11 +5662,13 @@ class ComputeTestCase(BaseTestCase):
self.compute.driver.get_info(mox.IgnoreArg()).AndReturn(
{'state': power_state.RUNNING})
self.compute._sync_instance_power_state(ctxt, mox.IgnoreArg(),
- power_state.RUNNING)
+ power_state.RUNNING,
+ use_slave=True)
self.compute.driver.get_info(mox.IgnoreArg()).AndReturn(
{'state': power_state.SHUTDOWN})
self.compute._sync_instance_power_state(ctxt, mox.IgnoreArg(),
- power_state.SHUTDOWN)
+ power_state.SHUTDOWN,
+ use_slave=True)
self.mox.ReplayAll()
self.compute._sync_power_states(ctxt)
@@ -6526,7 +6530,8 @@ class ComputeAPITestCase(BaseTestCase):
self.context, instance_obj.Instance(), exp_instance,
instance_obj.INSTANCE_DEFAULT_FIELDS + ['fault']))
- def fake_db_get(_context, _instance_uuid, columns_to_join=None):
+ def fake_db_get(_context, _instance_uuid,
+ columns_to_join=None, use_slave=False):
return exp_instance
self.stubs.Set(db, 'instance_get_by_uuid', fake_db_get)
@@ -6546,7 +6551,8 @@ class ComputeAPITestCase(BaseTestCase):
c, instance_obj.Instance(), exp_instance,
instance_obj.INSTANCE_DEFAULT_FIELDS + ['fault']))
- def fake_db_get(context, instance_uuid, columns_to_join=None):
+ def fake_db_get(context, instance_uuid,
+ columns_to_join=None, use_slave=False):
return exp_instance
self.stubs.Set(db, 'instance_get_by_uuid', fake_db_get)
diff --git a/nova/tests/compute/test_compute_mgr.py b/nova/tests/compute/test_compute_mgr.py
index 1c3b911fd3..7ae19d2f22 100644
--- a/nova/tests/compute/test_compute_mgr.py
+++ b/nova/tests/compute/test_compute_mgr.py
@@ -155,7 +155,8 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
self.compute.driver.init_host(host=our_host)
context.get_admin_context().AndReturn(fake_context)
db.instance_get_all_by_host(
- fake_context, our_host, columns_to_join=['info_cache']
+ fake_context, our_host, columns_to_join=['info_cache'],
+ use_slave=False
).AndReturn(startup_instances)
if defer_iptables_apply:
self.compute.driver.filter_defer_apply_on()
@@ -224,7 +225,8 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
self.compute.driver.init_host(host=our_host)
context.get_admin_context().AndReturn(fake_context)
db.instance_get_all_by_host(fake_context, our_host,
- columns_to_join=['info_cache']
+ columns_to_join=['info_cache'],
+ use_slave=False
).AndReturn([])
self.compute.init_virt_events()
@@ -425,7 +427,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
def test_sync_instance_power_state_match(self):
instance = self._get_sync_instance(power_state.RUNNING,
vm_states.ACTIVE)
- instance.refresh()
+ instance.refresh(use_slave=False)
self.mox.ReplayAll()
self.compute._sync_instance_power_state(self.context, instance,
power_state.RUNNING)
@@ -433,7 +435,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
def test_sync_instance_power_state_running_stopped(self):
instance = self._get_sync_instance(power_state.RUNNING,
vm_states.ACTIVE)
- instance.refresh()
+ instance.refresh(use_slave=False)
instance.save()
self.mox.ReplayAll()
self.compute._sync_instance_power_state(self.context, instance,
@@ -443,7 +445,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
def _test_sync_to_stop(self, power_state, vm_state, driver_power_state,
stop=True, force=False):
instance = self._get_sync_instance(power_state, vm_state)
- instance.refresh()
+ instance.refresh(use_slave=False)
instance.save()
self.mox.StubOutWithMock(self.compute.compute_api, 'stop')
self.mox.StubOutWithMock(self.compute.compute_api, 'force_stop')
diff --git a/nova/tests/compute/test_compute_xen.py b/nova/tests/compute/test_compute_xen.py
index 326d8f6bed..06a2ac6836 100644
--- a/nova/tests/compute/test_compute_xen.py
+++ b/nova/tests/compute/test_compute_xen.py
@@ -50,7 +50,7 @@ class ComputeXenTestCase(stubs.XenAPITestBaseNoDB):
self.mox.StubOutWithMock(self.compute, '_sync_instance_power_state')
instance_obj.InstanceList.get_by_host(ctxt,
- self.compute.host).AndReturn(instance_list)
+ self.compute.host, use_slave=True).AndReturn(instance_list)
self.compute.driver.get_num_instances().AndReturn(1)
vm_utils.lookup(self.compute.driver._session, instance['name'],
False).AndReturn(None)
diff --git a/nova/tests/db/test_db_api.py b/nova/tests/db/test_db_api.py
index 1e6c2b022d..e70a84ccea 100644
--- a/nova/tests/db/test_db_api.py
+++ b/nova/tests/db/test_db_api.py
@@ -1161,8 +1161,8 @@ class SecurityGroupTestCase(test.TestCase, ModelsObjectComparatorMixin):
session = get_session()
self.mox.StubOutWithMock(sqlalchemy_api, 'get_session')
- sqlalchemy_api.get_session().AndReturn(session)
- sqlalchemy_api.get_session().AndReturn(session)
+ sqlalchemy_api.get_session(slave_session=False).AndReturn(session)
+ sqlalchemy_api.get_session(slave_session=False).AndReturn(session)
self.mox.ReplayAll()
security_group = db.security_group_get(self.ctxt, sid,
diff --git a/nova/tests/objects/test_instance.py b/nova/tests/objects/test_instance.py
index 7e7dd8f34a..dfa9f1ae4d 100644
--- a/nova/tests/objects/test_instance.py
+++ b/nova/tests/objects/test_instance.py
@@ -64,7 +64,7 @@ class _TestInstanceObject(object):
primitive = inst.obj_to_primitive()
expected = {'nova_object.name': 'Instance',
'nova_object.namespace': 'nova',
- 'nova_object.version': '1.9',
+ 'nova_object.version': '1.10',
'nova_object.data':
{'uuid': 'fake-uuid',
'launched_at': '1955-11-05T00:00:00Z'},
@@ -80,7 +80,7 @@ class _TestInstanceObject(object):
primitive = inst.obj_to_primitive()
expected = {'nova_object.name': 'Instance',
'nova_object.namespace': 'nova',
- 'nova_object.version': '1.9',
+ 'nova_object.version': '1.10',
'nova_object.data':
{'uuid': 'fake-uuid',
'access_ip_v4': '1.2.3.4',
@@ -97,7 +97,8 @@ class _TestInstanceObject(object):
def test_get_without_expected(self):
self.mox.StubOutWithMock(db, 'instance_get_by_uuid')
db.instance_get_by_uuid(self.context, 'uuid',
- columns_to_join=[]
+ columns_to_join=[],
+ use_slave=False
).AndReturn(self.fake_instance)
self.mox.ReplayAll()
inst = instance.Instance.get_by_uuid(self.context, 'uuid',
@@ -115,7 +116,8 @@ class _TestInstanceObject(object):
db.instance_get_by_uuid(
self.context, 'uuid',
- columns_to_join=exp_cols
+ columns_to_join=exp_cols,
+ use_slave=False
).AndReturn(self.fake_instance)
fake_faults = test_instance_fault.fake_faults
db.instance_fault_get_by_instance_uuids(
@@ -146,12 +148,14 @@ class _TestInstanceObject(object):
fake_uuid = self.fake_instance['uuid']
db.instance_get_by_uuid(self.context, fake_uuid,
columns_to_join=['info_cache',
- 'security_groups']
+ 'security_groups'],
+ use_slave=False
).AndReturn(self.fake_instance)
fake_inst2 = dict(self.fake_instance,
system_metadata=[{'key': 'foo', 'value': 'bar'}])
db.instance_get_by_uuid(self.context, fake_uuid,
- columns_to_join=['system_metadata']
+ columns_to_join=['system_metadata'],
+ use_slave=False
).AndReturn(fake_inst2)
self.mox.ReplayAll()
inst = instance.Instance.get_by_uuid(self.context, fake_uuid)
@@ -175,7 +179,8 @@ class _TestInstanceObject(object):
fake_instance = self.fake_instance
db.instance_get_by_uuid(self.context, 'fake-uuid',
columns_to_join=['info_cache',
- 'security_groups']
+ 'security_groups'],
+ use_slave=False
).AndReturn(fake_instance)
self.mox.ReplayAll()
inst = instance.Instance.get_by_uuid(self.context, 'fake-uuid')
@@ -192,12 +197,14 @@ class _TestInstanceObject(object):
fake_uuid = self.fake_instance['uuid']
db.instance_get_by_uuid(self.context, fake_uuid,
columns_to_join=['info_cache',
- 'security_groups']
+ 'security_groups'],
+ use_slave=False
).AndReturn(dict(self.fake_instance,
host='orig-host'))
db.instance_get_by_uuid(self.context, fake_uuid,
columns_to_join=['info_cache',
- 'security_groups']
+ 'security_groups'],
+ use_slave=False
).AndReturn(dict(self.fake_instance,
host='new-host'))
self.mox.ReplayAll()
@@ -215,7 +222,8 @@ class _TestInstanceObject(object):
inst_copy.uuid = inst.uuid
self.mox.StubOutWithMock(instance.Instance, 'get_by_uuid')
instance.Instance.get_by_uuid(self.context, uuid=inst.uuid,
- expected_attrs=['metadata']
+ expected_attrs=['metadata'],
+ use_slave=False
).AndReturn(inst_copy)
self.mox.ReplayAll()
self.assertRaises(exception.OrphanedObjectError, inst.refresh)
@@ -255,7 +263,8 @@ class _TestInstanceObject(object):
self.mox.StubOutWithMock(notifications, 'send_update')
db.instance_get_by_uuid(self.context, fake_uuid,
columns_to_join=['info_cache',
- 'security_groups']
+ 'security_groups'],
+ use_slave=False
).AndReturn(old_ref)
db.instance_update_and_get_original(
self.context, fake_uuid, expected_updates,
@@ -326,7 +335,8 @@ class _TestInstanceObject(object):
self.mox.StubOutWithMock(notifications, 'send_update')
db.instance_get_by_uuid(self.context, fake_uuid,
columns_to_join=['info_cache',
- 'security_groups']
+ 'security_groups'],
+ use_slave=False
).AndReturn(old_ref)
db.instance_update_and_get_original(
self.context, fake_uuid, expected_updates, update_cells=False,
@@ -337,7 +347,8 @@ class _TestInstanceObject(object):
self.mox.ReplayAll()
- inst = instance.Instance.get_by_uuid(self.context, old_ref['uuid'])
+ inst = instance.Instance.get_by_uuid(self.context, old_ref['uuid'],
+ use_slave=False)
self.assertEqual('hello', inst.display_name)
inst.display_name = 'goodbye'
inst.save()
@@ -350,7 +361,8 @@ class _TestInstanceObject(object):
self.mox.StubOutWithMock(db, 'instance_get_by_uuid')
db.instance_get_by_uuid(self.context, fake_uuid,
columns_to_join=['info_cache',
- 'security_groups']
+ 'security_groups'],
+ use_slave=False
).AndReturn(fake_inst)
self.mox.ReplayAll()
inst = instance.Instance.get_by_uuid(self.context, fake_uuid)
@@ -363,7 +375,8 @@ class _TestInstanceObject(object):
self.mox.StubOutWithMock(db, 'instance_get_by_uuid')
db.instance_get_by_uuid(self.context, fake_uuid,
columns_to_join=['info_cache',
- 'security_groups']
+ 'security_groups'],
+ use_slave=False
).AndReturn(fake_inst)
self.mox.ReplayAll()
inst = instance.Instance.get_by_uuid(self.context, fake_uuid)
@@ -376,7 +389,8 @@ class _TestInstanceObject(object):
self.mox.StubOutWithMock(db, 'instance_get_by_uuid')
db.instance_get_by_uuid(self.context, fake_uuid,
columns_to_join=['info_cache',
- 'security_groups']
+ 'security_groups'],
+ use_slave=False
).AndReturn(fake_inst)
self.mox.ReplayAll()
inst = instance.Instance.get_by_uuid(self.context, fake_uuid)
@@ -397,7 +411,8 @@ class _TestInstanceObject(object):
self.mox.StubOutWithMock(db, 'instance_info_cache_update')
db.instance_get_by_uuid(self.context, fake_uuid,
columns_to_join=['info_cache',
- 'security_groups']
+ 'security_groups'],
+ use_slave=False
).AndReturn(fake_inst)
db.instance_info_cache_update(self.context, fake_uuid,
{'network_info': nwinfo2_json})
@@ -413,7 +428,8 @@ class _TestInstanceObject(object):
fake_uuid = fake_inst['uuid']
self.mox.StubOutWithMock(db, 'instance_get_by_uuid')
db.instance_get_by_uuid(self.context, fake_uuid,
- columns_to_join=['info_cache']
+ columns_to_join=['info_cache'],
+ use_slave=False
).AndReturn(fake_inst)
self.mox.ReplayAll()
inst = instance.Instance.get_by_uuid(self.context, fake_uuid,
@@ -438,7 +454,8 @@ class _TestInstanceObject(object):
self.mox.StubOutWithMock(db, 'security_group_update')
db.instance_get_by_uuid(self.context, fake_uuid,
columns_to_join=['info_cache',
- 'security_groups']
+ 'security_groups'],
+ use_slave=False
).AndReturn(fake_inst)
db.security_group_update(self.context, 1, {'description': 'changed'}
).AndReturn(fake_inst['security_groups'][0])
@@ -462,7 +479,8 @@ class _TestInstanceObject(object):
self.mox.StubOutWithMock(db, 'instance_get_by_uuid')
db.instance_get_by_uuid(self.context, fake_uuid,
columns_to_join=['info_cache',
- 'security_groups']
+ 'security_groups'],
+ use_slave=False
).AndReturn(fake_inst)
self.mox.ReplayAll()
inst = instance.Instance.get_by_uuid(self.context, fake_uuid)
@@ -473,7 +491,8 @@ class _TestInstanceObject(object):
fake_uuid = fake_inst['uuid']
self.mox.StubOutWithMock(db, 'instance_get_by_uuid')
db.instance_get_by_uuid(self.context, fake_uuid,
- columns_to_join=['pci_devices']
+ columns_to_join=['pci_devices'],
+ use_slave=False
).AndReturn(fake_inst)
self.mox.ReplayAll()
inst = instance.Instance.get_by_uuid(self.context, fake_uuid,
@@ -518,7 +537,8 @@ class _TestInstanceObject(object):
]
self.mox.StubOutWithMock(db, 'instance_get_by_uuid')
db.instance_get_by_uuid(self.context, fake_uuid,
- columns_to_join=['pci_devices']
+ columns_to_join=['pci_devices'],
+ use_slave=False
).AndReturn(fake_inst)
self.mox.ReplayAll()
inst = instance.Instance.get_by_uuid(self.context, fake_uuid,
@@ -536,6 +556,7 @@ class _TestInstanceObject(object):
self.mox.StubOutWithMock(db, 'instance_fault_get_by_instance_uuids')
db.instance_get_by_uuid(self.context, fake_uuid,
columns_to_join=[],
+ use_slave=False
).AndReturn(self.fake_instance)
db.instance_fault_get_by_instance_uuids(
self.context, [fake_uuid]).AndReturn({fake_uuid: fake_faults})
@@ -740,7 +761,8 @@ class _TestInstanceListObject(object):
self.fake_instance(2)]
self.mox.StubOutWithMock(db, 'instance_get_all_by_host')
db.instance_get_all_by_host(self.context, 'foo',
- columns_to_join=None).AndReturn(fakes)
+ columns_to_join=None,
+ use_slave=False).AndReturn(fakes)
self.mox.ReplayAll()
inst_list = instance.InstanceList.get_by_host(self.context, 'foo')
for i in range(0, len(fakes)):
@@ -802,14 +824,17 @@ class _TestInstanceListObject(object):
fake_faults = test_instance_fault.fake_faults
self.mox.StubOutWithMock(db, 'instance_get_all_by_host')
self.mox.StubOutWithMock(db, 'instance_fault_get_by_instance_uuids')
- db.instance_get_all_by_host(self.context, 'host', columns_to_join=[]
+ db.instance_get_all_by_host(self.context, 'host',
+ columns_to_join=[],
+ use_slave=False
).AndReturn(fake_insts)
db.instance_fault_get_by_instance_uuids(
self.context, [x['uuid'] for x in fake_insts]
).AndReturn(fake_faults)
self.mox.ReplayAll()
instances = instance.InstanceList.get_by_host(self.context, 'host',
- expected_attrs=['fault'])
+ expected_attrs=['fault'],
+ use_slave=False)
self.assertEqual(2, len(instances))
self.assertEqual(fake_faults['fake-uuid'][0],
dict(instances[0].fault.iteritems()))
diff --git a/nova/tests/objects/test_migration.py b/nova/tests/objects/test_migration.py
index 007c6bfed6..c6f8cbda8b 100644
--- a/nova/tests/objects/test_migration.py
+++ b/nova/tests/objects/test_migration.py
@@ -101,7 +101,8 @@ class _TestMigrationObject(object):
self.mox.StubOutWithMock(db, 'instance_get_by_uuid')
db.instance_get_by_uuid(ctxt, fake_migration['instance_uuid'],
columns_to_join=['info_cache',
- 'security_groups']
+ 'security_groups'],
+ use_slave=False
).AndReturn(fake_inst)
mig = migration.Migration._from_db_object(ctxt,
migration.Migration(),
diff --git a/nova/tests/virt/libvirt/test_libvirt.py b/nova/tests/virt/libvirt/test_libvirt.py
index da5a22f81e..7c7dada782 100644
--- a/nova/tests/virt/libvirt/test_libvirt.py
+++ b/nova/tests/virt/libvirt/test_libvirt.py
@@ -3893,7 +3893,8 @@ class LibvirtConnTestCase(test.TestCase):
self.mox.StubOutWithMock(db, 'instance_get_by_uuid')
db.instance_get_by_uuid(mox.IgnoreArg(), mox.IgnoreArg(),
columns_to_join=['info_cache',
- 'security_groups']
+ 'security_groups'],
+ use_slave=False
).AndReturn(instance)
self.mox.StubOutWithMock(shutil, "rmtree")
shutil.rmtree(os.path.join(CONF.instances_path,
@@ -3981,7 +3982,8 @@ class LibvirtConnTestCase(test.TestCase):
db.instance_get_by_uuid(mox.IgnoreArg(), mox.IgnoreArg(),
columns_to_join=['info_cache',
- 'security_groups']
+ 'security_groups'],
+ use_slave=False
).AndReturn(instance)
os.path.exists(mox.IgnoreArg()).AndReturn(False)
os.path.exists(mox.IgnoreArg()).AndReturn(True)
diff --git a/nova/tests/virt/xenapi/test_xenapi.py b/nova/tests/virt/xenapi/test_xenapi.py
index a121aa20fc..ddbe74d04c 100644
--- a/nova/tests/virt/xenapi/test_xenapi.py
+++ b/nova/tests/virt/xenapi/test_xenapi.py
@@ -1456,7 +1456,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
fake_inst = fake_instance.fake_db_instance(id=123)
fake_inst2 = fake_instance.fake_db_instance(id=456)
db.instance_get_all_by_host(self.context, fake_inst['host'],
- columns_to_join=None
+ columns_to_join=None,
+ use_slave=False
).AndReturn([fake_inst, fake_inst2])
self.mox.ReplayAll()
expected_name = CONF.instance_name_template % fake_inst['id']