~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to nova/tests/test_volume_types_extra_specs.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
 
 
3
 
# Copyright (c) 2011 Zadara Storage Inc.
4
 
# Copyright (c) 2011 OpenStack LLC.
5
 
# Copyright 2011 University of Southern California
6
 
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
7
 
#    not use this file except in compliance with the License. You may obtain
8
 
#    a copy of the License at
9
 
#
10
 
#         http://www.apache.org/licenses/LICENSE-2.0
11
 
#
12
 
#    Unless required by applicable law or agreed to in writing, software
13
 
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
 
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
 
#    License for the specific language governing permissions and limitations
16
 
#    under the License.
17
 
"""
18
 
Unit Tests for volume types extra specs code
19
 
"""
20
 
 
21
 
from nova import context
22
 
from nova import db
23
 
from nova import test
24
 
 
25
 
 
26
 
class VolumeTypeExtraSpecsTestCase(test.TestCase):
27
 
 
28
 
    def setUp(self):
29
 
        super(VolumeTypeExtraSpecsTestCase, self).setUp()
30
 
        self.context = context.get_admin_context()
31
 
        self.vol_type1 = dict(name="TEST: Regular volume test")
32
 
        self.vol_type1_specs = dict(vol_extra1="value1",
33
 
                                  vol_extra2="value2",
34
 
                                  vol_extra3=3)
35
 
        self.vol_type1['extra_specs'] = self.vol_type1_specs
36
 
        ref = db.volume_type_create(self.context, self.vol_type1)
37
 
        self.volume_type1_id = ref.id
38
 
        for k, v in self.vol_type1_specs.iteritems():
39
 
            self.vol_type1_specs[k] = str(v)
40
 
 
41
 
        self.vol_type2_noextra = dict(name="TEST: Volume type without extra")
42
 
        ref = db.volume_type_create(self.context, self.vol_type2_noextra)
43
 
        self.vol_type2_id = ref.id
44
 
 
45
 
    def tearDown(self):
46
 
        # Remove the volume type from the database
47
 
        db.volume_type_destroy(context.get_admin_context(),
48
 
                               self.vol_type1['name'])
49
 
        db.volume_type_destroy(context.get_admin_context(),
50
 
                               self.vol_type2_noextra['name'])
51
 
        super(VolumeTypeExtraSpecsTestCase, self).tearDown()
52
 
 
53
 
    def test_volume_type_specs_get(self):
54
 
        expected_specs = self.vol_type1_specs.copy()
55
 
        actual_specs = db.volume_type_extra_specs_get(
56
 
                              context.get_admin_context(),
57
 
                              self.volume_type1_id)
58
 
        self.assertEquals(expected_specs, actual_specs)
59
 
 
60
 
    def test_volume_type_extra_specs_delete(self):
61
 
        expected_specs = self.vol_type1_specs.copy()
62
 
        del expected_specs['vol_extra2']
63
 
        db.volume_type_extra_specs_delete(context.get_admin_context(),
64
 
                                      self.volume_type1_id,
65
 
                                      'vol_extra2')
66
 
        actual_specs = db.volume_type_extra_specs_get(
67
 
                              context.get_admin_context(),
68
 
                              self.volume_type1_id)
69
 
        self.assertEquals(expected_specs, actual_specs)
70
 
 
71
 
    def test_volume_type_extra_specs_update(self):
72
 
        expected_specs = self.vol_type1_specs.copy()
73
 
        expected_specs['vol_extra3'] = "4"
74
 
        db.volume_type_extra_specs_update_or_create(
75
 
                              context.get_admin_context(),
76
 
                              self.volume_type1_id,
77
 
                              dict(vol_extra3=4))
78
 
        actual_specs = db.volume_type_extra_specs_get(
79
 
                              context.get_admin_context(),
80
 
                              self.volume_type1_id)
81
 
        self.assertEquals(expected_specs, actual_specs)
82
 
 
83
 
    def test_volume_type_extra_specs_create(self):
84
 
        expected_specs = self.vol_type1_specs.copy()
85
 
        expected_specs['vol_extra4'] = 'value4'
86
 
        expected_specs['vol_extra5'] = 'value5'
87
 
        db.volume_type_extra_specs_update_or_create(
88
 
                              context.get_admin_context(),
89
 
                              self.volume_type1_id,
90
 
                              dict(vol_extra4="value4",
91
 
                                   vol_extra5="value5"))
92
 
        actual_specs = db.volume_type_extra_specs_get(
93
 
                              context.get_admin_context(),
94
 
                              self.volume_type1_id)
95
 
        self.assertEquals(expected_specs, actual_specs)
96
 
 
97
 
    def test_volume_type_get_with_extra_specs(self):
98
 
        volume_type = db.volume_type_get(
99
 
                            context.get_admin_context(),
100
 
                            self.volume_type1_id)
101
 
        self.assertEquals(volume_type['extra_specs'],
102
 
                          self.vol_type1_specs)
103
 
 
104
 
        volume_type = db.volume_type_get(
105
 
                            context.get_admin_context(),
106
 
                            self.vol_type2_id)
107
 
        self.assertEquals(volume_type['extra_specs'], {})
108
 
 
109
 
    def test_volume_type_get_by_name_with_extra_specs(self):
110
 
        volume_type = db.volume_type_get_by_name(
111
 
                            context.get_admin_context(),
112
 
                            self.vol_type1['name'])
113
 
        self.assertEquals(volume_type['extra_specs'],
114
 
                          self.vol_type1_specs)
115
 
 
116
 
        volume_type = db.volume_type_get_by_name(
117
 
                            context.get_admin_context(),
118
 
                            self.vol_type2_noextra['name'])
119
 
        self.assertEquals(volume_type['extra_specs'], {})
120
 
 
121
 
    def test_volume_type_get_all(self):
122
 
        expected_specs = self.vol_type1_specs.copy()
123
 
 
124
 
        types = db.volume_type_get_all(context.get_admin_context())
125
 
 
126
 
        self.assertEquals(
127
 
            types[self.vol_type1['name']]['extra_specs'], expected_specs)
128
 
 
129
 
        self.assertEquals(
130
 
            types[self.vol_type2_noextra['name']]['extra_specs'], {})