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
diff --git a/tests/base.py b/tests/base.py
index abbdb0a..57b30b5 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -923,7 +923,9 @@
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
diff --git a/tox.ini b/tox.ini
index d716bb7..0f8254a 100644
--- a/tox.ini
+++ b/tox.ini
@@ -5,7 +5,7 @@
[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