mirror of
https://github.com/sprockets/sprockets.mixins.metrics.git
synced 2024-11-25 03:00:25 +00:00
Use ephemeral port in tests for statsd
This commit is contained in:
parent
af62789a96
commit
1fb1f46bc1
2 changed files with 10 additions and 5 deletions
|
@ -33,7 +33,7 @@ class FakeStatsdServer(object):
|
|||
def __init__(self, iol):
|
||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM,
|
||||
socket.IPPROTO_UDP)
|
||||
self.socket.bind(('127.0.0.1', 8125))
|
||||
self.socket.bind(('127.0.0.1', 0))
|
||||
self.sockaddr = self.socket.getsockname()
|
||||
self.datagrams = []
|
||||
|
||||
|
|
13
tests.py
13
tests.py
|
@ -41,13 +41,15 @@ class StatsdMetricCollectionTests(testing.AsyncHTTPTestCase):
|
|||
web.url('/', examples.statsd.SimpleHandler),
|
||||
web.url('/counters/(.*)/([.0-9]*)', CounterBumper),
|
||||
])
|
||||
statsd.install(self.application, **{'namespace': 'testing'})
|
||||
return self.application
|
||||
|
||||
def setUp(self):
|
||||
self.application = None
|
||||
super(StatsdMetricCollectionTests, self).setUp()
|
||||
self.statsd = FakeStatsdServer(self.io_loop)
|
||||
statsd.install(self.application, **{'namespace': 'testing',
|
||||
'host': self.statsd.sockaddr[0],
|
||||
'port': self.statsd.sockaddr[1]})
|
||||
|
||||
def tearDown(self):
|
||||
self.statsd.close()
|
||||
|
@ -102,9 +104,6 @@ class StatsdConfigurationTests(testing.AsyncHTTPTestCase):
|
|||
web.url('/', examples.statsd.SimpleHandler),
|
||||
web.url('/counters/(.*)/([.0-9]*)', CounterBumper),
|
||||
])
|
||||
statsd.install(self.application, **{'namespace': 'testing',
|
||||
'prepend_metric_type': False,
|
||||
'prepend_hostname': False})
|
||||
return self.application
|
||||
|
||||
def setUp(self):
|
||||
|
@ -112,6 +111,12 @@ class StatsdConfigurationTests(testing.AsyncHTTPTestCase):
|
|||
super(StatsdConfigurationTests, self).setUp()
|
||||
self.statsd = FakeStatsdServer(self.io_loop)
|
||||
|
||||
statsd.install(self.application, **{'namespace': 'testing',
|
||||
'host': self.statsd.sockaddr[0],
|
||||
'port': self.statsd.sockaddr[1],
|
||||
'prepend_metric_type': False,
|
||||
'prepend_hostname': False})
|
||||
|
||||
def tearDown(self):
|
||||
self.statsd.close()
|
||||
super(StatsdConfigurationTests, self).tearDown()
|
||||
|
|
Loading…
Reference in a new issue