~ubuntu-branches/ubuntu/saucy/cinder/saucy

« back to all changes in this revision

Viewing changes to cinder/tests/test_volume_rpcapi.py

  • Committer: Package Import Robot
  • Author(s): James Page, Chuck Short, Adam Gandelman, James Page
  • Date: 2013-07-19 14:14:40 UTC
  • mfrom: (1.1.17)
  • Revision ID: package-import@ubuntu.com-20130719141440-brarmy8wxm3vosaf
Tags: 1:2013.2~b2-0ubuntu1
[ Chuck Short ]
* debian/patches/avoid_paramiko_vers_depends.patch: Refreshed
* debian/control: Add missing testrepostory.
* debian/rules: Use testr directly.

[ Adam Gandelman ]
* debian/control:
  - Add minimum requirement python-anyjson (>= 0.3.3).
  - Add minimum requirement python-keystoneclient (>= 0.2.3).
  - Add minimum requirement python-kombu (>= 2.5.12).

[ James Page ]
* New upstream release.
* d/control: Update VCS fields for new branch locations.
* d/rules: Run unit tests in parallel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
"""
20
20
 
21
21
 
 
22
from oslo.config import cfg
 
23
 
22
24
from cinder import context
23
25
from cinder import db
24
 
from cinder import flags
25
26
from cinder.openstack.common import jsonutils
26
27
from cinder.openstack.common import rpc
27
28
from cinder import test
28
29
from cinder.volume import rpcapi as volume_rpcapi
29
30
 
30
31
 
31
 
FLAGS = flags.FLAGS
 
32
CONF = cfg.CONF
32
33
 
33
34
 
34
35
class VolumeRpcAPITestCase(test.TestCase):
35
36
 
36
37
    def setUp(self):
 
38
        super(VolumeRpcAPITestCase, self).setUp()
37
39
        self.context = context.get_admin_context()
38
40
        vol = {}
39
41
        vol['host'] = 'fake_host'
40
 
        vol['availability_zone'] = FLAGS.storage_availability_zone
 
42
        vol['availability_zone'] = CONF.storage_availability_zone
41
43
        vol['status'] = "available"
42
44
        vol['attach_status'] = "detached"
43
45
        volume = db.volume_create(self.context, vol)
52
54
        snapshot = db.snapshot_create(self.context, snpshot)
53
55
        self.fake_volume = jsonutils.to_primitive(volume)
54
56
        self.fake_snapshot = jsonutils.to_primitive(snapshot)
55
 
        super(VolumeRpcAPITestCase, self).setUp()
56
57
 
57
58
    def test_serialized_volume_has_id(self):
58
59
        self.assertTrue('id' in self.fake_volume)
87
88
            host = kwargs['host']
88
89
        else:
89
90
            host = kwargs['volume']['host']
90
 
        expected_topic = '%s.%s' % (FLAGS.volume_topic, host)
 
91
        expected_topic = '%s.%s' % (CONF.volume_topic, host)
91
92
 
92
93
        self.fake_args = None
93
94
        self.fake_kwargs = None
137
138
                              snapshot=self.fake_snapshot,
138
139
                              host='fake_host')
139
140
 
140
 
    def test_attach_volume(self):
 
141
    def test_attach_volume_to_instance(self):
141
142
        self._test_volume_api('attach_volume',
142
143
                              rpc_method='call',
143
144
                              volume=self.fake_volume,
144
145
                              instance_uuid='fake_uuid',
145
 
                              mountpoint='fake_mountpoint')
 
146
                              host_name=None,
 
147
                              mountpoint='fake_mountpoint',
 
148
                              version='1.7')
 
149
 
 
150
    def test_attach_volume_to_host(self):
 
151
        self._test_volume_api('attach_volume',
 
152
                              rpc_method='call',
 
153
                              volume=self.fake_volume,
 
154
                              instance_uuid=None,
 
155
                              host_name='fake_host',
 
156
                              mountpoint='fake_mountpoint',
 
157
                              version='1.7')
146
158
 
147
159
    def test_detach_volume(self):
148
160
        self._test_volume_api('detach_volume',
170
182
                              volume=self.fake_volume,
171
183
                              connector='fake_connector',
172
184
                              force=False)
 
185
 
 
186
    def test_accept_transfer(self):
 
187
        self._test_volume_api('accept_transfer',
 
188
                              rpc_method='cast',
 
189
                              volume=self.fake_volume,
 
190
                              version='1.5')
 
191
 
 
192
    def test_extend_volume(self):
 
193
        self._test_volume_api('extend_volume',
 
194
                              rpc_method='cast',
 
195
                              volume=self.fake_volume,
 
196
                              new_size=1,
 
197
                              version='1.6')