Skip to content

Commit

Permalink
Merge "Avoid thread creation prior to service launch."
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jun 18, 2012
2 parents ed16167 + b3b4d64 commit 7aa688a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 10 deletions.
3 changes: 2 additions & 1 deletion glance/tests/functional/store_utils.py
Expand Up @@ -87,7 +87,8 @@ def serve_requests(httpd):


def teardown_http(test):
test.http_server.shutdown()
if test.http_server:
test.http_server.shutdown()


def get_http_uri(test, image_id):
Expand Down
10 changes: 7 additions & 3 deletions glance/tests/functional/test_bin_glance.py
Expand Up @@ -204,11 +204,13 @@ def test_add_no_name(self):
[c.strip() for c in line.split()]
self.assertEqual('None', name)

@requires(setup_http, teardown_http)
@requires(teardown=teardown_http)
def test_add_copying_from(self):
self.cleanup()
self.start_servers(**self.__dict__.copy())

setup_http(self)

api_port = self.api_port
registry_port = self.registry_port

Expand Down Expand Up @@ -250,6 +252,8 @@ def _do_test_update_external_source(self, source):
self.cleanup()
self.start_servers(**self.__dict__.copy())

setup_http(self)

api_port = self.api_port
registry_port = self.registry_port

Expand Down Expand Up @@ -296,15 +300,15 @@ def _do_test_update_external_source(self, source):
lines = out.split("\n")
self.assertTrue(set(lines) >= set(expected_lines))

@requires(setup_http, teardown_http)
@requires(teardown=teardown_http)
def test_update_copying_from(self):
"""
Tests creating an queued image then subsequently updating
with a copy-from source
"""
self._do_test_update_external_source('copy_from')

@requires(setup_http, teardown_http)
@requires(teardown=teardown_http)
def test_update_location(self):
"""
Tests creating an queued image then subsequently updating
Expand Down
4 changes: 3 additions & 1 deletion glance/tests/functional/v1/test_cache_middleware.py
Expand Up @@ -121,7 +121,7 @@ def test_cache_middleware_transparent(self):

self.stop_servers()

@requires(setup_http, teardown_http)
@requires(teardown=teardown_http)
@skip_if_disabled
def test_cache_remote_image(self):
"""
Expand All @@ -130,6 +130,8 @@ def test_cache_remote_image(self):
self.cleanup()
self.start_servers(**self.__dict__.copy())

setup_http(self)

api_port = self.api_port
registry_port = self.registry_port

Expand Down
4 changes: 3 additions & 1 deletion glance/tests/functional/v1/test_copy_to_file.py
Expand Up @@ -174,7 +174,7 @@ def test_copy_from_s3(self):
"""
self._do_test_copy_from('s3', get_s3_uri)

@requires(setup_http, teardown_http)
@requires(teardown=teardown_http)
@skip_if_disabled
def test_copy_from_http(self):
"""
Expand All @@ -184,6 +184,8 @@ def test_copy_from_http(self):

self.start_servers(**self.__dict__.copy())

setup_http(self)

api_port = self.api_port
registry_port = self.registry_port

Expand Down
4 changes: 3 additions & 1 deletion glance/tests/functional/v1/test_s3.py
Expand Up @@ -268,7 +268,7 @@ def test_copy_from_swift(self):
"""
self._do_test_copy_from('swift', get_swift_uri)

@requires(setup_http, teardown_http)
@requires(teardown=teardown_http)
@skip_if_disabled
def test_copy_from_http(self):
"""
Expand All @@ -278,6 +278,8 @@ def test_copy_from_http(self):

self.start_servers(**self.__dict__.copy())

setup_http(self)

api_port = self.api_port
registry_port = self.registry_port

Expand Down
4 changes: 3 additions & 1 deletion glance/tests/functional/v1/test_swift.py
Expand Up @@ -541,7 +541,7 @@ def test_copy_from_s3(self):
"""
self._do_test_copy_from('s3', get_s3_uri)

@requires(setup_http, teardown_http)
@requires(teardown=teardown_http)
@skip_if_disabled
def test_copy_from_http(self):
"""
Expand All @@ -551,6 +551,8 @@ def test_copy_from_http(self):

self.start_servers(**self.__dict__.copy())

setup_http(self)

api_port = self.api_port
registry_port = self.registry_port

Expand Down
5 changes: 3 additions & 2 deletions glance/tests/utils.py
Expand Up @@ -125,13 +125,14 @@ def _skipper(*args, **kw):

class requires(object):
"""Decorator that initiates additional test setup/teardown."""
def __init__(self, setup, teardown=None):
def __init__(self, setup=None, teardown=None):
self.setup = setup
self.teardown = teardown

def __call__(self, func):
def _runner(*args, **kw):
self.setup(args[0])
if self.setup:
self.setup(args[0])
func(*args, **kw)
if self.teardown:
self.teardown(args[0])
Expand Down

0 comments on commit 7aa688a

Please sign in to comment.