1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
# Copyright [2010] [Anso Labs, LLC]
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
8
# http://www.apache.org/licenses/LICENSE-2.0
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
20
from xml.etree import ElementTree
22
from nova import vendor
24
from tornado import ioloop
25
from twisted.internet import defer
27
from nova import exception
28
from nova import flags
30
from nova.compute import node
31
from nova.volume import storage
37
class StorageTestCase(test.TrialTestCase):
39
logging.getLogger().setLevel(logging.DEBUG)
40
super(StorageTestCase, self).setUp()
41
self.mynode = node.Node()
43
self.flags(fake_libvirt=True,
46
if FLAGS.fake_storage:
47
self.mystorage = storage.FakeBlockStore()
49
self.mystorage = storage.BlockStore()
52
def test_run_create_volume(self):
55
volume_id = self.mystorage.create_volume(vol_size, user_id)
56
# rv = self.mystorage.describe_volumes()
58
# Volumes have to be sorted by timestamp in order to work here...
59
# TODO(termie): get_volume returns differently than create_volume
60
self.assertEqual(volume_id,
61
self.mystorage.get_volume(volume_id)['volume_id'])
63
rv = self.mystorage.delete_volume(volume_id)
64
self.assertRaises(exception.Error,
65
self.mystorage.get_volume,
69
def test_run_attach_detach_volume(self):
70
# Create one volume and one node to test with
71
instance_id = "storage-test"
72
# TODO(joshua) - Redo this test, can't make fake instances this way any more
73
# rv = self.mynode.run_instance(instance_id)
76
volume_id = self.mystorage.create_volume(vol_size, user_id)
77
rv = self.mystorage.attach_volume(volume_id,
80
volume_obj = self.mystorage.get_volume(volume_id)
81
self.assertEqual(volume_obj['status'], "attached")
82
# TODO(???): assert that it's attached to the right instance
84
rv = self.mystorage.detach_volume(volume_id)
85
volume_obj = self.mystorage.get_volume(volume_id)
86
self.assertEqual(volume_obj['status'], "available")