summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSandy Walsh <sandy.walsh@rackspace.com>2011-09-12 15:22:30 -0700
committerSandy Walsh <sandy.walsh@rackspace.com>2011-09-12 15:22:30 -0700
commitc0c046ef7d30787fe72b8de6c290a4b72cb207fb (patch)
tree5a57dc9efe7c3512899a5a7c1ea0b9e7ef198672
parent5c5948ffe158d9834d13a80a3ff4e73f79d0d7e0 (diff)
downloadnova-c0c046ef7d30787fe72b8de6c290a4b72cb207fb.tar.gz
nova-c0c046ef7d30787fe72b8de6c290a4b72cb207fb.tar.xz
nova-c0c046ef7d30787fe72b8de6c290a4b72cb207fb.zip
working on getting tests back
-rw-r--r--nova/db/sqlalchemy/api.py2
-rw-r--r--nova/rpc/impl_kombu.py1
-rw-r--r--nova/scheduler/api.py2
-rw-r--r--nova/scheduler/zone_manager.py4
-rw-r--r--nova/tests/scheduler/test_scheduler.py32
-rw-r--r--nova/tests/test_zones.py22
6 files changed, 39 insertions, 24 deletions
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 40e2ca167..e5a661c7f 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -672,7 +672,7 @@ def floating_ip_update(context, address, values):
def fixed_ip_associate(context, address, instance_id, network_id=None,
reserved=False):
"""Keyword arguments:
- reserved -- should be a boolean value(True or False), exact value will be
+ reserved -- should be a boolean value(True or False), exact value will be
used to filter on the fixed ip address
"""
session = get_session()
diff --git a/nova/rpc/impl_kombu.py b/nova/rpc/impl_kombu.py
index b994a6a10..e7fc491ea 100644
--- a/nova/rpc/impl_kombu.py
+++ b/nova/rpc/impl_kombu.py
@@ -728,7 +728,6 @@ def multicall(context, topic, msg):
wait_msg = MulticallWaiter(conn)
conn.declare_direct_consumer(msg_id, wait_msg)
conn.topic_send(topic, msg)
-
return wait_msg
diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py
index 3d92d902a..418ebe5e2 100644
--- a/nova/scheduler/api.py
+++ b/nova/scheduler/api.py
@@ -120,7 +120,7 @@ def call_zone_method(context, method_name, errors_to_ignore=None,
# Do this on behalf of the user ...
nova = novaclient.Client(zone.username, zone.password, None,
zone.api_url, region_name=zone.name,
- token = context.auth_token)
+ token=context.auth_token)
nova.authenticate()
except novaclient_exceptions.BadRequest, e:
url = zone.api_url
diff --git a/nova/scheduler/zone_manager.py b/nova/scheduler/zone_manager.py
index 16b4c7faf..c61ff7b77 100644
--- a/nova/scheduler/zone_manager.py
+++ b/nova/scheduler/zone_manager.py
@@ -102,7 +102,9 @@ def _call_novaclient(zone):
def _poll_zone(zone):
"""Eventlet worker to poll a zone."""
- logging.debug(_("Polling zone: %s @ %s") % (zone.name, zone.api_url))
+ name = zone.name
+ url = zone.api_url
+ logging.debug(_("Polling zone: %(name)s @ %(url)s") % locals())
try:
zone.update_metadata(_call_novaclient(zone))
except Exception, e:
diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py
index 890348192..c880a9005 100644
--- a/nova/tests/scheduler/test_scheduler.py
+++ b/nova/tests/scheduler/test_scheduler.py
@@ -53,6 +53,10 @@ FAKE_UUID_NOT_FOUND = 'ffffffff-ffff-ffff-ffff-ffffffffffff'
FAKE_UUID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
+class FakeContext(object):
+ auth_token = None
+
+
class TestDriver(driver.Scheduler):
"""Scheduler Driver for Tests"""
def schedule(context, topic, *args, **kwargs):
@@ -956,11 +960,12 @@ class MultiDriverTestCase(SimpleDriverTestCase):
class FakeZone(object):
- def __init__(self, id, api_url, username, password):
+ def __init__(self, id, api_url, username, password, name='child'):
self.id = id
self.api_url = api_url
self.username = username
self.password = password
+ self.name = name
ZONE_API_URL1 = "http://1.example.com"
@@ -986,7 +991,7 @@ class FakeRerouteCompute(api.reroute_compute):
super(FakeRerouteCompute, self).__init__(method_name)
self.id_to_return = id_to_return
- def _call_child_zones(self, zones, function):
+ def _call_child_zones(self, context, zones, function):
return []
def get_collection_context_and_id(self, args, kwargs):
@@ -1092,7 +1097,8 @@ class ZoneRedirectTest(test.TestCase):
return None
class FakeNovaClientWithFailure(object):
- def __init__(self, username, password, method, api_url):
+ def __init__(self, username, password, method, api_url,
+ token=None, region_name=None):
self.api_url = api_url
def authenticate(self):
@@ -1108,7 +1114,7 @@ class ZoneRedirectTest(test.TestCase):
pass
self.assertRaises(exception.ZoneRequestError,
- do_get, None, {}, FAKE_UUID)
+ do_get, None, FakeContext(), FAKE_UUID)
def test_one_zone_down_got_instance(self):
@@ -1120,7 +1126,8 @@ class ZoneRedirectTest(test.TestCase):
return FakeServer()
class FakeNovaClientWithFailure(object):
- def __init__(self, username, password, method, api_url):
+ def __init__(self, username, password, method, api_url,
+ token=None, region_name=None):
self.api_url = api_url
def authenticate(self):
@@ -1136,14 +1143,14 @@ class ZoneRedirectTest(test.TestCase):
pass
try:
- do_get(None, {}, FAKE_UUID)
+ do_get(None, FakeContext(), FAKE_UUID)
except api.RedirectResult, e:
results = e.results
self.assertIn('server', results)
self.assertEqual(results['server']['id'], FAKE_UUID)
self.assertEqual(results['server']['test'], '1234')
except Exception, e:
- self.fail(_("RedirectResult should have been raised"))
+ self.fail(_("RedirectResult should have been raised: %s" % e))
else:
self.fail(_("RedirectResult should have been raised"))
@@ -1153,7 +1160,8 @@ class ZoneRedirectTest(test.TestCase):
return None
class FakeNovaClientNoFailure(object):
- def __init__(self, username, password, method, api_url):
+ def __init__(self, username, password, method, api_url,
+ token=None, region_name=None):
pass
def authenticate(self):
@@ -1168,7 +1176,7 @@ class ZoneRedirectTest(test.TestCase):
pass
self.assertRaises(exception.InstanceNotFound,
- do_get, None, {}, FAKE_UUID)
+ do_get, None, FakeContext(), FAKE_UUID)
class FakeServerCollection(object):
@@ -1250,7 +1258,7 @@ class CallZoneMethodTest(test.TestCase):
super(CallZoneMethodTest, self).tearDown()
def test_call_zone_method(self):
- context = {}
+ context = FakeContext()
method = 'do_something'
results = api.call_zone_method(context, method)
self.assertEqual(len(results), 2)
@@ -1258,12 +1266,12 @@ class CallZoneMethodTest(test.TestCase):
self.assertIn((2, 42), results)
def test_call_zone_method_not_present(self):
- context = {}
+ context = FakeContext()
method = 'not_present'
self.assertRaises(AttributeError, api.call_zone_method,
context, method)
def test_call_zone_method_generates_exception(self):
- context = {}
+ context = FakeContext()
method = 'raises_exception'
self.assertRaises(Exception, api.call_zone_method, context, method)
diff --git a/nova/tests/test_zones.py b/nova/tests/test_zones.py
index 9efa23015..3ffc9371d 100644
--- a/nova/tests/test_zones.py
+++ b/nova/tests/test_zones.py
@@ -63,7 +63,7 @@ class ZoneManagerTestCase(test.TestCase):
self.mox.StubOutWithMock(db, 'zone_get_all')
db.zone_get_all(mox.IgnoreArg()).AndReturn([
FakeZone(id=1, api_url='http://foo.com', username='user1',
- password='pass1'),
+ password='pass1', name='child'),
])
self.assertEquals(len(zm.zone_states), 0)
@@ -107,13 +107,15 @@ class ZoneManagerTestCase(test.TestCase):
zm = zone_manager.ZoneManager()
zone_state = zone_manager.ZoneState()
zone_state.update_credentials(FakeZone(id=1, api_url='http://foo.com',
- username='user1', password='pass1'))
+ username='user1', password='pass1', name='child',
+ weight_offset=0.0, weight_scale=1.0))
zm.zone_states[1] = zone_state
self.mox.StubOutWithMock(db, 'zone_get_all')
db.zone_get_all(mox.IgnoreArg()).AndReturn([
FakeZone(id=1, api_url='http://foo.com', username='user2',
- password='pass2'),
+ password='pass2', name='child',
+ weight_offset=0.0, weight_scale=1.0),
])
self.assertEquals(len(zm.zone_states), 1)
@@ -129,7 +131,8 @@ class ZoneManagerTestCase(test.TestCase):
zm = zone_manager.ZoneManager()
zone_state = zone_manager.ZoneState()
zone_state.update_credentials(FakeZone(id=1, api_url='http://foo.com',
- username='user1', password='pass1'))
+ username='user1', password='pass1', name='child',
+ weight_offset=0.0, weight_scale=1.0))
zm.zone_states[1] = zone_state
self.mox.StubOutWithMock(db, 'zone_get_all')
@@ -147,14 +150,15 @@ class ZoneManagerTestCase(test.TestCase):
zm = zone_manager.ZoneManager()
zone_state = zone_manager.ZoneState()
zone_state.update_credentials(FakeZone(id=1, api_url='http://foo.com',
- username='user1', password='pass1'))
+ username='user1', password='pass1', name='child',
+ weight_offset=0.0, weight_scale=1.0))
zm.zone_states[1] = zone_state
self.mox.StubOutWithMock(db, 'zone_get_all')
db.zone_get_all(mox.IgnoreArg()).AndReturn([
FakeZone(id=2, api_url='http://foo.com', username='user2',
- password='pass2'),
+ password='pass2', name='child'),
])
self.assertEquals(len(zm.zone_states), 1)
@@ -173,7 +177,8 @@ class ZoneManagerTestCase(test.TestCase):
zone_state = zone_manager.ZoneState()
zone_state.update_credentials(FakeZone(id=2,
api_url='http://foo.com', username='user2',
- password='pass2'))
+ password='pass2', name='child',
+ weight_offset=0.0, weight_scale=1.0))
zone_state.attempt = 1
self.mox.ReplayAll()
@@ -188,7 +193,8 @@ class ZoneManagerTestCase(test.TestCase):
zone_state = zone_manager.ZoneState()
zone_state.update_credentials(FakeZone(id=2,
api_url='http://foo.com', username='user2',
- password='pass2'))
+ password='pass2', name='child',
+ weight_offset=0.0, weight_scale=1.0))
zone_state.attempt = FLAGS.zone_failures_to_offline - 1
self.mox.ReplayAll()