aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-04-11 21:56:15 -0700
committerRoss Brattain <ross.b.brattain@intel.com>2017-07-12 06:21:20 +0000
commit29484c3071028df6c897797706117082a4b8c3f5 (patch)
tree430774f764f6266d5ddabe2827302008f5b9804d
parent0832b64daeeae389db660d87c139e82c1c6593f8 (diff)
constants: default SERVER_IP to 127.0.0.1
When running unittest while connected to P2P VPN, their is no default route, so we get None. Instead of using None, default to 127.0.0.1 Not sure why this was renamed to SERVER_IP either, what do we use this value for? Still getting py.test unittest failures all the time. The problem is we lookup influxdb.ip but SERVER_IP is None, so the lookup fails. INFLUXDB_IP = get_param('influxdb.ip', SERVER_IP) SERVER_IP can't ever be None Change-Id: Iedb09dc541137f7cdc6ef8d26dd312807985bfa8 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
-rw-r--r--yardstick/common/constants.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/yardstick/common/constants.py b/yardstick/common/constants.py
index d251341fc..c5a37b605 100644
--- a/yardstick/common/constants.py
+++ b/yardstick/common/constants.py
@@ -26,7 +26,15 @@ except KeyError:
SERVER_IP = '172.17.0.1'
else:
with IPDB() as ip:
- SERVER_IP = ip.routes['default'].gateway
+ try:
+ SERVER_IP = ip.routes['default'].gateway
+ except KeyError:
+ # during unittests ip.routes['default'] can be invalid
+ SERVER_IP = '127.0.0.1'
+
+if not SERVER_IP:
+ SERVER_IP = '127.0.0.1'
+
# dir
CONF_DIR = get_param('dir.conf', '/etc/yardstick')