constants: default SERVER_IP to 127.0.0.1 87/33287/7
authorRoss Brattain <ross.b.brattain@intel.com>
Wed, 12 Apr 2017 04:56:15 +0000 (21:56 -0700)
committerRoss Brattain <ross.b.brattain@intel.com>
Wed, 12 Jul 2017 06:21:20 +0000 (06:21 +0000)
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>
yardstick/common/constants.py

index d251341..c5a37b6 100644 (file)
@@ -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')