Run tests parallel by default

Remove `--concurrency 1` option from tox.ini which would entail
a parallel test execution.
Add @mock decorator to test methods that have mock objects to make
cleanup correct.
Add store.configure() to configure store properly.

Change-Id: I4b58746f6b6ad037fabb29be5ca1d1febcb0cf95
This commit is contained in:
Oleksii Chuprykov 2014-09-15 13:18:50 +03:00
parent 783a1c8bbd
commit 03d79fe88a
2 changed files with 14 additions and 9 deletions

View File

@ -340,10 +340,11 @@ class SwiftTests(object):
self.store.get,
loc)
@mock.patch('glance_store._drivers.swift.utils'
'.is_multiple_swift_store_accounts_enabled',
mock.Mock(return_value=False))
def test_add(self):
"""Test that we can add an image via the swift backend"""
sutils.is_multiple_swift_store_accounts_enabled = \
mock.Mock(return_value=False)
reload(swift)
self.store = Store(self.conf)
self.store.configure()
@ -400,13 +401,14 @@ class SwiftTests(object):
expected_swift_size)
self.assertEqual(expected_location, location)
@mock.patch('glance_store._drivers.swift.utils'
'.is_multiple_swift_store_accounts_enabled',
mock.Mock(return_value=True))
def test_add_auth_url_variations(self):
"""
Test that we can add an image via the swift backend with
a variety of different auth_address values
"""
sutils.is_multiple_swift_store_accounts_enabled = \
mock.Mock(return_value=True)
conf = copy.deepcopy(SWIFT_CONF)
self.config(**conf)
@ -482,13 +484,14 @@ class SwiftTests(object):
self.assertTrue(exception_caught)
self.assertEqual(SWIFT_PUT_OBJECT_CALLS, 0)
@mock.patch('glance_store._drivers.swift.utils'
'.is_multiple_swift_store_accounts_enabled',
mock.Mock(return_value=True))
def test_add_no_container_and_create(self):
"""
Tests that adding an image with a non-existing container
creates the container automatically if flag is set
"""
sutils.is_multiple_swift_store_accounts_enabled = \
mock.Mock(return_value=True)
expected_swift_size = FIVE_KB
expected_swift_contents = "*" * expected_swift_size
expected_checksum = hashlib.md5(expected_swift_contents).hexdigest()
@ -524,6 +527,9 @@ class SwiftTests(object):
self.assertEqual(expected_swift_contents, new_image_contents)
self.assertEqual(expected_swift_size, new_image_swift_size)
@mock.patch('glance_store._drivers.swift.utils'
'.is_multiple_swift_store_accounts_enabled',
mock.Mock(return_value=True))
def test_add_large_object(self):
"""
Tests that adding a very large image. We simulate the large
@ -531,8 +537,6 @@ class SwiftTests(object):
and then verify that there have been a number of calls to
put_object()...
"""
sutils.is_multiple_swift_store_accounts_enabled = \
mock.Mock(return_value=True)
expected_swift_size = FIVE_KB
expected_swift_contents = "*" * expected_swift_size
expected_checksum = hashlib.md5(expected_swift_contents).hexdigest()
@ -638,6 +642,7 @@ class SwiftTests(object):
Tests that adding an image with an existing identifier
raises an appropriate exception
"""
self.store.configure()
image_swift = six.StringIO("nevergonnamakeit")
self.assertRaises(exceptions.Duplicate,
self.store.add,

View File

@ -9,7 +9,7 @@ usedevelop = True
install_command = pip install --allow-all-external --allow-insecure netaddr -U {opts} {packages}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = python setup.py test --slowest --testr-args='--concurrency 1 {posargs}'
commands = python setup.py test --slowest --testr-args='{posargs}'
[tox:jenkins]
downloadcache = ~/cache/pip