Use 127.0.0.1 rather than localhost for statsd host

When we use "localhost" as the statsd server, statsd can possibly
choose ::1 (i.e. ipv6) and all stats tests fail because the fake stats
server is ipv4.

This seems more prevalent with python2.6 (failures in our centos6 CI,
replicated with Debian stable), probably because ordering of results
changes in later glibcs.

Anyway, specify 127.0.0.1 so we're getting the right thing

Change-Id: I2f821834ab4d7e06cdb5933b79b9f650d9668c0e
This commit is contained in:
Ian Wienand 2015-09-30 15:38:47 +10:00
parent 2c83a2a542
commit ff977bf7a7
2 changed files with 4 additions and 2 deletions

View File

@ -923,7 +923,9 @@ class ZuulTestCase(BaseTestCase):
self.init_repo("org/no-jobs-project")
self.statsd = FakeStatsd()
os.environ['STATSD_HOST'] = 'localhost'
# note, use 127.0.0.1 rather than localhost to avoid getting ipv6
# see: https://github.com/jsocol/pystatsd/issues/61
os.environ['STATSD_HOST'] = '127.0.0.1'
os.environ['STATSD_PORT'] = str(self.statsd.port)
self.statsd.start()
# the statsd client object is configured in the statsd module import

View File

@ -5,7 +5,7 @@ envlist = pep8, py27
[testenv]
# Set STATSD env variables so that statsd code paths are tested.
setenv = STATSD_HOST=localhost
setenv = STATSD_HOST=127.0.0.1
STATSD_PORT=8125
VIRTUAL_ENV={envdir}
OS_TEST_TIMEOUT=30