diff options
-rw-r--r-- | nova/network/manager.py | 1 | ||||
-rw-r--r-- | nova/service.py | 2 | ||||
-rw-r--r-- | nova/test.py | 6 | ||||
-rw-r--r-- | nova/tests/access_unittest.py | 2 | ||||
-rw-r--r-- | nova/tests/auth_unittest.py | 3 | ||||
-rw-r--r-- | nova/tests/cloud_unittest.py | 3 | ||||
-rw-r--r-- | nova/tests/compute_unittest.py | 3 | ||||
-rw-r--r-- | nova/tests/fake_flags.py | 5 | ||||
-rw-r--r-- | nova/tests/network_unittest.py | 1 | ||||
-rw-r--r-- | nova/tests/real_flags.py | 1 | ||||
-rw-r--r-- | nova/tests/service_unittest.py | 72 | ||||
-rw-r--r-- | nova/tests/storage_unittest.py | 115 | ||||
-rw-r--r-- | nova/tests/volume_unittest.py | 3 | ||||
-rw-r--r-- | nova/volume/driver.py | 4 | ||||
-rw-r--r-- | nova/volume/manager.py | 12 |
15 files changed, 50 insertions, 183 deletions
diff --git a/nova/network/manager.py b/nova/network/manager.py index dbb8e66da..83de5d023 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -260,6 +260,7 @@ class VlanManager(NetworkManager): significant_bits = 32 - int(math.log(FLAGS.network_size, 2)) cidr = "%s/%s" % (private_net[start], significant_bits) project_net = IPy.IP(cidr) + net = {} net['cidr'] = cidr # NOTE(vish): we could turn these into properties diff --git a/nova/service.py b/nova/service.py index dec3812d2..60583dcdb 100644 --- a/nova/service.py +++ b/nova/service.py @@ -152,7 +152,7 @@ class Service(object, service.Service): logging.error("Recovered model server connection!") # TODO(vish): this should probably only catch connection errors - except: # pylint: disable-msg=W0702 + except Exception: # pylint: disable-msg=W0702 if not getattr(self, "model_disconnected", False): self.model_disconnected = True logging.exception("model server went away") diff --git a/nova/test.py b/nova/test.py index 4eb5c1c53..c392c8a84 100644 --- a/nova/test.py +++ b/nova/test.py @@ -39,12 +39,6 @@ FLAGS = flags.FLAGS flags.DEFINE_bool('fake_tests', True, 'should we use everything for testing') -from sqlalchemy import create_engine -from sqlalchemy.ext.declarative import declarative_base - -engine = create_engine('sqlite:///:memory:', echo=True) -Base = declarative_base() -Base.metadata.create_all(engine) def skip_if_fake(func): """Decorator that skips a test if running in fake mode""" diff --git a/nova/tests/access_unittest.py b/nova/tests/access_unittest.py index fa0a090a0..59e1683db 100644 --- a/nova/tests/access_unittest.py +++ b/nova/tests/access_unittest.py @@ -33,8 +33,6 @@ class Context(object): class AccessTestCase(test.BaseTestCase): def setUp(self): super(AccessTestCase, self).setUp() - FLAGS.connection_type = 'fake' - FLAGS.fake_storage = True um = manager.AuthManager() # Make test users try: diff --git a/nova/tests/auth_unittest.py b/nova/tests/auth_unittest.py index 59a81818c..b54e68274 100644 --- a/nova/tests/auth_unittest.py +++ b/nova/tests/auth_unittest.py @@ -34,8 +34,7 @@ FLAGS = flags.FLAGS class AuthTestCase(test.BaseTestCase): def setUp(self): super(AuthTestCase, self).setUp() - self.flags(connection_type='fake', - fake_storage=True) + self.flags(connection_type='fake') self.manager = manager.AuthManager() def test_001_can_create_users(self): diff --git a/nova/tests/cloud_unittest.py b/nova/tests/cloud_unittest.py index e6796e3da..29947e03c 100644 --- a/nova/tests/cloud_unittest.py +++ b/nova/tests/cloud_unittest.py @@ -39,8 +39,7 @@ FLAGS = flags.FLAGS class CloudTestCase(test.BaseTestCase): def setUp(self): super(CloudTestCase, self).setUp() - self.flags(connection_type='fake', - fake_storage=True) + self.flags(connection_type='fake') self.conn = rpc.Connection.instance() logging.getLogger().setLevel(logging.DEBUG) diff --git a/nova/tests/compute_unittest.py b/nova/tests/compute_unittest.py index 867b572f3..07a2fceb1 100644 --- a/nova/tests/compute_unittest.py +++ b/nova/tests/compute_unittest.py @@ -38,8 +38,7 @@ class ComputeTestCase(test.TrialTestCase): def setUp(self): # pylint: disable-msg=C0103 logging.getLogger().setLevel(logging.DEBUG) super(ComputeTestCase, self).setUp() - self.flags(connection_type='fake', - fake_storage=True) + self.flags(connection_type='fake') self.compute = utils.import_object(FLAGS.compute_manager) self.manager = manager.AuthManager() self.user = self.manager.create_user('fake', 'fake', 'fake') diff --git a/nova/tests/fake_flags.py b/nova/tests/fake_flags.py index 3114912ba..8f4754650 100644 --- a/nova/tests/fake_flags.py +++ b/nova/tests/fake_flags.py @@ -20,8 +20,8 @@ from nova import flags FLAGS = flags.FLAGS -flags.DECLARE('fake_storage', 'nova.volume.manager') -FLAGS.fake_storage = True +flags.DECLARE('volume_driver', 'nova.volume.manager') +FLAGS.volume_driver = 'nova.volume.driver.FakeAOEDriver' FLAGS.connection_type = 'fake' FLAGS.fake_rabbit = True FLAGS.auth_driver = 'nova.auth.ldapdriver.FakeLdapDriver' @@ -37,4 +37,3 @@ FLAGS.num_shelves = 2 FLAGS.blades_per_shelf = 4 FLAGS.verbose = True FLAGS.sql_connection = 'sqlite:///nova.sqlite' -#FLAGS.sql_connection = 'mysql://root@localhost/test' diff --git a/nova/tests/network_unittest.py b/nova/tests/network_unittest.py index 8e462b9d3..a89f1d622 100644 --- a/nova/tests/network_unittest.py +++ b/nova/tests/network_unittest.py @@ -39,7 +39,6 @@ class NetworkTestCase(test.TrialTestCase): # NOTE(vish): if you change these flags, make sure to change the # flags in the corresponding section in nova-dhcpbridge self.flags(connection_type='fake', - fake_storage=True, fake_network=True, auth_driver='nova.auth.ldapdriver.FakeLdapDriver', network_size=16, diff --git a/nova/tests/real_flags.py b/nova/tests/real_flags.py index 121f4eb41..71da04992 100644 --- a/nova/tests/real_flags.py +++ b/nova/tests/real_flags.py @@ -21,7 +21,6 @@ from nova import flags FLAGS = flags.FLAGS FLAGS.connection_type = 'libvirt' -FLAGS.fake_storage = False FLAGS.fake_rabbit = False FLAGS.fake_network = False FLAGS.verbose = False diff --git a/nova/tests/service_unittest.py b/nova/tests/service_unittest.py index 590d760b9..097a045e0 100644 --- a/nova/tests/service_unittest.py +++ b/nova/tests/service_unittest.py @@ -47,9 +47,9 @@ class ServiceTestCase(test.BaseTestCase): self.mox.StubOutWithMock(service, 'db') def test_create(self): - host='foo' - binary='nova-fake' - topic='fake' + host = 'foo' + binary = 'nova-fake' + topic = 'fake' self.mox.StubOutWithMock(rpc, 'AdapterConsumer', use_mock_anything=True) @@ -75,19 +75,19 @@ class ServiceTestCase(test.BaseTestCase): rpc.AdapterConsumer.attach_to_twisted() rpc.AdapterConsumer.attach_to_twisted() service_create = {'host': host, - 'binary': binary, - 'topic': topic, - 'report_count': 0} + 'binary': binary, + 'topic': topic, + 'report_count': 0} service_ref = {'host': host, - 'binary': binary, - 'report_count': 0, - 'id': 1} + 'binary': binary, + 'report_count': 0, + 'id': 1} service.db.service_get_by_args(None, - host, - binary).AndRaise(exception.NotFound()) + host, + binary).AndRaise(exception.NotFound()) service.db.service_create(None, - service_create).AndReturn(service_ref['id']) + service_create).AndReturn(service_ref['id']) self.mox.ReplayAll() app = service.Service.create(host=host, binary=binary) @@ -101,15 +101,15 @@ class ServiceTestCase(test.BaseTestCase): host = 'foo' binary = 'bar' service_ref = {'host': host, - 'binary': binary, - 'report_count': 0, - 'id': 1} + 'binary': binary, + 'report_count': 0, + 'id': 1} service.db.__getattr__('report_state') service.db.service_get_by_args(None, - host, - binary).AndReturn(service_ref) + host, + binary).AndReturn(service_ref) service.db.service_update(None, service_ref['id'], - mox.ContainsKeyValue('report_count', 1)) + mox.ContainsKeyValue('report_count', 1)) self.mox.ReplayAll() s = service.Service() @@ -119,22 +119,22 @@ class ServiceTestCase(test.BaseTestCase): host = 'foo' binary = 'bar' service_create = {'host': host, - 'binary': binary, - 'report_count': 0} + 'binary': binary, + 'report_count': 0} service_ref = {'host': host, - 'binary': binary, - 'report_count': 0, - 'id': 1} + 'binary': binary, + 'report_count': 0, + 'id': 1} service.db.__getattr__('report_state') service.db.service_get_by_args(None, host, binary).AndRaise(exception.NotFound()) service.db.service_create(None, - service_create).AndReturn(service_ref['id']) + service_create).AndReturn(service_ref['id']) service.db.service_get(None, service_ref['id']).AndReturn(service_ref) service.db.service_update(None, service_ref['id'], - mox.ContainsKeyValue('report_count', 1)) + mox.ContainsKeyValue('report_count', 1)) self.mox.ReplayAll() s = service.Service() @@ -144,14 +144,14 @@ class ServiceTestCase(test.BaseTestCase): host = 'foo' binary = 'bar' service_ref = {'host': host, - 'binary': binary, - 'report_count': 0, - 'id': 1} + 'binary': binary, + 'report_count': 0, + 'id': 1} service.db.__getattr__('report_state') service.db.service_get_by_args(None, - host, - binary).AndRaise(Exception()) + host, + binary).AndRaise(Exception()) self.mox.ReplayAll() s = service.Service() @@ -163,16 +163,16 @@ class ServiceTestCase(test.BaseTestCase): host = 'foo' binary = 'bar' service_ref = {'host': host, - 'binary': binary, - 'report_count': 0, - 'id': 1} + 'binary': binary, + 'report_count': 0, + 'id': 1} service.db.__getattr__('report_state') service.db.service_get_by_args(None, - host, - binary).AndReturn(service_ref) + host, + binary).AndReturn(service_ref) service.db.service_update(None, service_ref['id'], - mox.ContainsKeyValue('report_count', 1)) + mox.ContainsKeyValue('report_count', 1)) self.mox.ReplayAll() s = service.Service() diff --git a/nova/tests/storage_unittest.py b/nova/tests/storage_unittest.py deleted file mode 100644 index f400cd2fd..000000000 --- a/nova/tests/storage_unittest.py +++ /dev/null @@ -1,115 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2010 United States Government as represented by the -# Administrator of the National Aeronautics and Space Administration. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import logging - -from nova import exception -from nova import flags -from nova import test -from nova.compute import node -from nova.volume import storage - - -FLAGS = flags.FLAGS - - -class StorageTestCase(test.TrialTestCase): - def setUp(self): - logging.getLogger().setLevel(logging.DEBUG) - super(StorageTestCase, self).setUp() - self.mynode = node.Node() - self.mystorage = None - self.flags(connection_type='fake', - fake_storage=True) - self.mystorage = storage.BlockStore() - - def test_run_create_volume(self): - vol_size = '0' - user_id = 'fake' - project_id = 'fake' - volume_id = self.mystorage.create_volume(vol_size, user_id, project_id) - # TODO(termie): get_volume returns differently than create_volume - self.assertEqual(volume_id, - storage.get_volume(volume_id)['volume_id']) - - rv = self.mystorage.delete_volume(volume_id) - self.assertRaises(exception.Error, - storage.get_volume, - volume_id) - - def test_too_big_volume(self): - vol_size = '1001' - user_id = 'fake' - project_id = 'fake' - self.assertRaises(TypeError, - self.mystorage.create_volume, - vol_size, user_id, project_id) - - def test_too_many_volumes(self): - vol_size = '1' - user_id = 'fake' - project_id = 'fake' - num_shelves = FLAGS.last_shelf_id - FLAGS.first_shelf_id + 1 - total_slots = FLAGS.slots_per_shelf * num_shelves - vols = [] - for i in xrange(total_slots): - vid = self.mystorage.create_volume(vol_size, user_id, project_id) - vols.append(vid) - self.assertRaises(storage.NoMoreVolumes, - self.mystorage.create_volume, - vol_size, user_id, project_id) - for id in vols: - self.mystorage.delete_volume(id) - - def test_run_attach_detach_volume(self): - # Create one volume and one node to test with - instance_id = "storage-test" - vol_size = "5" - user_id = "fake" - project_id = 'fake' - mountpoint = "/dev/sdf" - volume_id = self.mystorage.create_volume(vol_size, user_id, project_id) - - volume_obj = storage.get_volume(volume_id) - volume_obj.start_attach(instance_id, mountpoint) - rv = yield self.mynode.attach_volume(volume_id, - instance_id, - mountpoint) - self.assertEqual(volume_obj['status'], "in-use") - self.assertEqual(volume_obj['attachStatus'], "attached") - self.assertEqual(volume_obj['instance_id'], instance_id) - self.assertEqual(volume_obj['mountpoint'], mountpoint) - - self.assertRaises(exception.Error, - self.mystorage.delete_volume, - volume_id) - - rv = yield self.mystorage.detach_volume(volume_id) - volume_obj = storage.get_volume(volume_id) - self.assertEqual(volume_obj['status'], "available") - - rv = self.mystorage.delete_volume(volume_id) - self.assertRaises(exception.Error, - storage.get_volume, - volume_id) - - def test_multi_node(self): - # TODO(termie): Figure out how to test with two nodes, - # each of them having a different FLAG for storage_node - # This will allow us to test cross-node interactions - pass diff --git a/nova/tests/volume_unittest.py b/nova/tests/volume_unittest.py index 0df0c20d6..99b228701 100644 --- a/nova/tests/volume_unittest.py +++ b/nova/tests/volume_unittest.py @@ -37,8 +37,7 @@ class VolumeTestCase(test.TrialTestCase): logging.getLogger().setLevel(logging.DEBUG) super(VolumeTestCase, self).setUp() self.compute = utils.import_object(FLAGS.compute_manager) - self.flags(connection_type='fake', - fake_storage=True) + self.flags(connection_type='fake') self.volume = utils.import_object(FLAGS.volume_manager) self.context = None diff --git a/nova/volume/driver.py b/nova/volume/driver.py index f875e0213..4604b85d5 100644 --- a/nova/volume/driver.py +++ b/nova/volume/driver.py @@ -92,9 +92,9 @@ class AOEDriver(object): # NOTE(ja): wait for blades to appear yield self._execute("sleep 5") yield self._execute("sudo vblade-persist auto all", - check_exit_code=False) + check_exit_code=False) yield self._execute("sudo vblade-persist start all", - check_exit_code=False) + check_exit_code=False) class FakeAOEDriver(AOEDriver): diff --git a/nova/volume/manager.py b/nova/volume/manager.py index c4fa1f982..174c036d6 100644 --- a/nova/volume/manager.py +++ b/nova/volume/manager.py @@ -35,8 +35,6 @@ FLAGS = flags.FLAGS flags.DEFINE_string('storage_availability_zone', 'nova', 'availability zone of this service') -flags.DEFINE_boolean('fake_storage', False, - 'Should we make real storage volumes to attach?') flags.DEFINE_string('volume_driver', 'nova.volume.driver.AOEDriver', 'Driver to use for volume creation') flags.DEFINE_integer('num_shelves', @@ -51,11 +49,7 @@ class AOEManager(manager.Manager): """Manages Ata-Over_Ethernet volumes""" def __init__(self, volume_driver=None, *args, **kwargs): if not volume_driver: - # NOTE(vish): support the legacy fake storage flag - if FLAGS.fake_storage: - volume_driver = 'nova.volume.driver.FakeAOEDriver' - else: - volume_driver = FLAGS.volume_driver + volume_driver = FLAGS.volume_driver self.driver = utils.import_object(volume_driver) super(AOEManager, self).__init__(*args, **kwargs) @@ -92,7 +86,9 @@ class AOEManager(manager.Manager): logging.debug("volume %s: exporting shelf %s & blade %s", volume_id, shelf_id, blade_id) - yield self.driver.create_export(volume_ref['str_id'], shelf_id, blade_id) + yield self.driver.create_export(volume_ref['str_id'], + shelf_id, + blade_id) # TODO(joshua): We need to trigger a fanout message # for aoe-discover on all the nodes |