Volume documentation.

This commit is contained in:
Todd Willey
2010-10-29 16:18:00 -04:00
parent d72b2a292a
commit 0cad1be95e

View File

@@ -16,7 +16,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
""" """
Tests for Volume Code Tests for Volume Code.
""" """
import logging import logging
@@ -33,7 +34,8 @@ FLAGS = flags.FLAGS
class VolumeTestCase(test.TrialTestCase): class VolumeTestCase(test.TrialTestCase):
"""Test Case for volumes""" """Test Case for volumes."""
def setUp(self): def setUp(self):
logging.getLogger().setLevel(logging.DEBUG) logging.getLogger().setLevel(logging.DEBUG)
super(VolumeTestCase, self).setUp() super(VolumeTestCase, self).setUp()
@@ -44,7 +46,7 @@ class VolumeTestCase(test.TrialTestCase):
@staticmethod @staticmethod
def _create_volume(size='0'): def _create_volume(size='0'):
"""Create a volume object""" """Create a volume object."""
vol = {} vol = {}
vol['size'] = size vol['size'] = size
vol['user_id'] = 'fake' vol['user_id'] = 'fake'
@@ -56,7 +58,7 @@ class VolumeTestCase(test.TrialTestCase):
@defer.inlineCallbacks @defer.inlineCallbacks
def test_create_delete_volume(self): def test_create_delete_volume(self):
"""Test volume can be created and deleted""" """Test volume can be created and deleted."""
volume_id = self._create_volume() volume_id = self._create_volume()
yield self.volume.create_volume(self.context, volume_id) yield self.volume.create_volume(self.context, volume_id)
self.assertEqual(volume_id, db.volume_get(context.get_admin_context(), self.assertEqual(volume_id, db.volume_get(context.get_admin_context(),
@@ -70,7 +72,7 @@ class VolumeTestCase(test.TrialTestCase):
@defer.inlineCallbacks @defer.inlineCallbacks
def test_too_big_volume(self): def test_too_big_volume(self):
"""Ensure failure if a too large of a volume is requested""" """Ensure failure if a too large of a volume is requested."""
# FIXME(vish): validation needs to move into the data layer in # FIXME(vish): validation needs to move into the data layer in
# volume_create # volume_create
defer.returnValue(True) defer.returnValue(True)
@@ -83,7 +85,7 @@ class VolumeTestCase(test.TrialTestCase):
@defer.inlineCallbacks @defer.inlineCallbacks
def test_too_many_volumes(self): def test_too_many_volumes(self):
"""Ensure that NoMoreBlades is raised when we run out of volumes""" """Ensure that NoMoreBlades is raised when we run out of volumes."""
vols = [] vols = []
total_slots = FLAGS.num_shelves * FLAGS.blades_per_shelf total_slots = FLAGS.num_shelves * FLAGS.blades_per_shelf
for _index in xrange(total_slots): for _index in xrange(total_slots):
@@ -100,7 +102,7 @@ class VolumeTestCase(test.TrialTestCase):
@defer.inlineCallbacks @defer.inlineCallbacks
def test_run_attach_detach_volume(self): def test_run_attach_detach_volume(self):
"""Make sure volume can be attached and detached from instance""" """Make sure volume can be attached and detached from instance."""
inst = {} inst = {}
inst['image_id'] = 'ami-test' inst['image_id'] = 'ami-test'
inst['reservation_id'] = 'r-fakeres' inst['reservation_id'] = 'r-fakeres'
@@ -149,12 +151,13 @@ class VolumeTestCase(test.TrialTestCase):
@defer.inlineCallbacks @defer.inlineCallbacks
def test_concurrent_volumes_get_different_blades(self): def test_concurrent_volumes_get_different_blades(self):
"""Ensure multiple concurrent volumes get different blades""" """Ensure multiple concurrent volumes get different blades."""
volume_ids = [] volume_ids = []
shelf_blades = [] shelf_blades = []
def _check(volume_id): def _check(volume_id):
"""Make sure blades aren't duplicated""" """Make sure blades aren't duplicated."""
volume_ids.append(volume_id) volume_ids.append(volume_id)
admin_context = context.get_admin_context() admin_context = context.get_admin_context()
(shelf_id, blade_id) = db.volume_get_shelf_and_blade(admin_context, (shelf_id, blade_id) = db.volume_get_shelf_and_blade(admin_context,