~citrix-openstack/nova/xenapi

« back to all changes in this revision

Viewing changes to nova/tests/volume_unittest.py

  • Committer: Tarmac
  • Author(s): Todd Willey, root, Vishvananda Ishaya, Joe Heck, root, Andy Smith, Anne Gentle, Dean Troyer, Devin Carlen
  • Date: 2010-11-16 02:34:47 UTC
  • mfrom: (386.2.71 trunkdoc)
  • Revision ID: hudson@openstack.org-20101116023447-pz7n6ps5rf0fnjea
Lots of documentation and docstring updates.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
#    License for the specific language governing permissions and limitations
17
17
#    under the License.
18
18
"""
19
 
Tests for Volume Code
 
19
Tests for Volume Code.
 
20
 
20
21
"""
21
22
import logging
22
23
 
33
34
 
34
35
 
35
36
class VolumeTestCase(test.TrialTestCase):
36
 
    """Test Case for volumes"""
 
37
    """Test Case for volumes."""
 
38
 
37
39
    def setUp(self):
38
40
        logging.getLogger().setLevel(logging.DEBUG)
39
41
        super(VolumeTestCase, self).setUp()
44
46
 
45
47
    @staticmethod
46
48
    def _create_volume(size='0'):
47
 
        """Create a volume object"""
 
49
        """Create a volume object."""
48
50
        vol = {}
49
51
        vol['size'] = size
50
52
        vol['user_id'] = 'fake'
56
58
 
57
59
    @defer.inlineCallbacks
58
60
    def test_create_delete_volume(self):
59
 
        """Test volume can be created and deleted"""
 
61
        """Test volume can be created and deleted."""
60
62
        volume_id = self._create_volume()
61
63
        yield self.volume.create_volume(self.context, volume_id)
62
64
        self.assertEqual(volume_id, db.volume_get(context.get_admin_context(),
70
72
 
71
73
    @defer.inlineCallbacks
72
74
    def test_too_big_volume(self):
73
 
        """Ensure failure if a too large of a volume is requested"""
 
75
        """Ensure failure if a too large of a volume is requested."""
74
76
        # FIXME(vish): validation needs to move into the data layer in
75
77
        #              volume_create
76
78
        defer.returnValue(True)
83
85
 
84
86
    @defer.inlineCallbacks
85
87
    def test_too_many_volumes(self):
86
 
        """Ensure that NoMoreTargets is raised when we run out of volumes"""
 
88
        """Ensure that NoMoreTargets is raised when we run out of volumes."""
87
89
        vols = []
88
90
        total_slots = FLAGS.iscsi_num_targets
89
91
        for _index in xrange(total_slots):
100
102
 
101
103
    @defer.inlineCallbacks
102
104
    def test_run_attach_detach_volume(self):
103
 
        """Make sure volume can be attached and detached from instance"""
 
105
        """Make sure volume can be attached and detached from instance."""
104
106
        inst = {}
105
107
        inst['image_id'] = 'ami-test'
106
108
        inst['reservation_id'] = 'r-fakeres'
149
151
 
150
152
    @defer.inlineCallbacks
151
153
    def test_concurrent_volumes_get_different_targets(self):
152
 
        """Ensure multiple concurrent volumes get different targets"""
 
154
        """Ensure multiple concurrent volumes get different targets."""
153
155
        volume_ids = []
154
156
        targets = []
155
157
 
156
158
        def _check(volume_id):
157
 
            """Make sure targets aren't duplicated"""
 
159
            """Make sure targets aren't duplicated."""
158
160
            volume_ids.append(volume_id)
159
161
            admin_context = context.get_admin_context()
160
162
            iscsi_target = db.volume_get_iscsi_target_num(admin_context,