~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/tests/test_misc.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-08-16 14:04:11 UTC
  • mto: This revision was merged to the branch mainline in revision 84.
  • Revision ID: package-import@ubuntu.com-20120816140411-0mr4n241wmk30t9l
Tags: upstream-2012.2~f3
ImportĀ upstreamĀ versionĀ 2012.2~f3

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#    License for the specific language governing permissions and limitations
15
15
#    under the License.
16
16
 
17
 
import commands
18
17
import errno
19
18
import glob
20
19
import os
22
21
 
23
22
from eventlet import greenpool
24
23
from eventlet import greenthread
25
 
import lockfile
26
24
 
27
25
from nova import exception
28
26
from nova import test
42
40
 
43
41
 
44
42
class ProjectTestCase(test.TestCase):
45
 
    def test_authors_up_to_date(self):
46
 
        topdir = os.path.normpath(os.path.dirname(__file__) + '/../../')
47
 
        missing = set()
48
 
        contributors = set()
49
 
        mailmap = utils.parse_mailmap(os.path.join(topdir, '.mailmap'))
50
 
        authors_file = open(os.path.join(topdir,
51
 
                                         'Authors'), 'r').read().lower()
52
 
 
53
 
        if os.path.exists(os.path.join(topdir, '.git')):
54
 
            for email in commands.getoutput('git log --format=%ae').split():
55
 
                if not email:
56
 
                    continue
57
 
                if "jenkins" in email and "openstack.org" in email:
58
 
                    continue
59
 
                email = '<' + email.lower() + '>'
60
 
                contributors.add(utils.str_dict_replace(email, mailmap))
61
 
        else:
62
 
            return
63
 
 
64
 
        for contributor in contributors:
65
 
            if contributor == 'nova-core':
66
 
                continue
67
 
            if not contributor in authors_file:
68
 
                missing.add(contributor)
69
 
 
70
 
        self.assertTrue(len(missing) == 0,
71
 
                        '%r not listed in Authors' % missing)
72
43
 
73
44
    def test_all_migrations_have_downgrade(self):
74
45
        topdir = os.path.normpath(os.path.dirname(__file__) + '/../../')
135
106
        self.assertEqual(saved_sem_num, len(utils._semaphores),
136
107
                         "Semaphore leak detected")
137
108
 
138
 
    def test_nested_external_fails(self):
139
 
        """We can not nest external syncs"""
 
109
    def test_nested_external_works(self):
 
110
        """We can nest external syncs"""
 
111
        sentinel = object()
140
112
 
141
113
        @utils.synchronized('testlock1', external=True)
142
114
        def outer_lock():
143
115
 
144
116
            @utils.synchronized('testlock2', external=True)
145
117
            def inner_lock():
146
 
                pass
147
 
            inner_lock()
148
 
        try:
149
 
            self.assertRaises(lockfile.NotMyLock, outer_lock)
150
 
        finally:
151
 
            utils.cleanup_file_locks()
 
118
                return sentinel
 
119
            return inner_lock()
 
120
 
 
121
        self.assertEqual(sentinel, outer_lock())
152
122
 
153
123
    def test_synchronized_externally(self):
154
124
        """We can lock across multiple processes"""