Configure the ovs switch/bridge based on the olt host port configuration in olt_config.json
Also account for this fact in the tests relying on ovsbr0 if ovs was running locally.
Change eval script hacks for ovsbr0 as it isn't required with the new changes to pick up switch from the config file.
Change-Id: I1b85eeea6bce822352711eeaaab5e5a01bc3938b
diff --git a/src/test/proxyarp/proxyarpTest.py b/src/test/proxyarp/proxyarpTest.py
index 5fbf28a..594fabc 100644
--- a/src/test/proxyarp/proxyarpTest.py
+++ b/src/test/proxyarp/proxyarpTest.py
@@ -34,7 +34,7 @@
class proxyarp_exchange(unittest.TestCase):
apps = ('org.onosproject.vrouter','org.onosproject.proxyarp')
- device_id = 'of:' + get_mac('ovsbr0')
+ device_id = 'of:' + get_mac()
device_dict = { "devices" : {
"{}".format(device_id) : {
"basic" : {
diff --git a/src/test/setup/cord-test.py b/src/test/setup/cord-test.py
index 732ea53..54ca9c9 100755
--- a/src/test/setup/cord-test.py
+++ b/src/test/setup/cord-test.py
@@ -55,15 +55,19 @@
self.build_image(image)
##Remove test container if any
self.remove_container(self.name, force=True)
+ self.olt = False
if env is not None and env.has_key('OLT_CONFIG'):
self.olt = True
- olt_conf_file = os.path.join(self.tester_base, 'olt_config.json')
- olt_config = OltConfig(olt_conf_file)
- self.port_map, _ = olt_config.olt_port_map()
+ olt_conf_file = os.path.join(self.tester_base, 'olt_config.json')
+ olt_config = OltConfig(olt_conf_file)
+ self.port_map, _ = olt_config.olt_port_map()
+ #Try using the host interface in olt conf to setup the switch
+ if self.port_map.has_key('host'):
+ self.switch = self.port_map['host']
else:
- self.olt = False
- self.port_map = None
+ self.switch = 'ovsbr0'
if env is not None:
+ env['TEST_SWITCH'] = self.switch
env['TEST_HOST'] = self.name
env['TEST_INSTANCE'] = instance
env['TEST_INSTANCES'] = num_instances
@@ -76,11 +80,11 @@
return os.system(cmd)
return self.execute(cmd, shell = shell)
- def start_switch(self, bridge = 'ovsbr0', boot_delay = 2):
+ def start_switch(self, boot_delay = 2):
"""Start OVS"""
##Determine if OVS has to be started locally or not
s_file,s_sandbox = ('of-bridge-local.sh',self.tester_base) if self.olt else ('of-bridge.sh',self.sandbox_setup)
- ovs_cmd = os.path.join(s_sandbox, '{0}'.format(s_file)) + ' {0}'.format(bridge)
+ ovs_cmd = os.path.join(s_sandbox, s_file) + ' {0}'.format(self.switch)
if self.olt:
ovs_cmd += ' {0}'.format(self.ctlr_ip)
print('Starting OVS on the host')
@@ -91,7 +95,7 @@
## Wait for the LLDP flows to be added to the switch
tries = 0
while status != 0 and tries < 200:
- cmd = 'sudo ovs-ofctl dump-flows {0} | grep \"type=0x8942\"'.format(bridge)
+ cmd = 'sudo ovs-ofctl dump-flows {0} | grep \"type=0x8942\"'.format(self.switch)
status = self.execute_switch(cmd, shell = True)
tries += 1
if tries % 10 == 0:
diff --git a/src/test/setup/eval.sh b/src/test/setup/eval.sh
index 3b0009d..7e96de4 100755
--- a/src/test/setup/eval.sh
+++ b/src/test/setup/eval.sh
@@ -8,20 +8,9 @@
docker kill cord-onos || true
docker kill cord-quagga || true
docker kill cord-radius || true
-olt_config="$(dirname $0)/olt_config.json"
-sub=0
-if grep -q br-int $olt_config; then
- sub=1
-fi
-if [ $sub -eq 1 ]; then
- sed -i 's,br-int,ovsbr0,g' $olt_config
-fi
function finish {
$cord_tester cleanup --olt
pkill -f cord-test
- if [ $sub -eq 1 ]; then
- sed -i 's,ovsbr0,br-int,g' $olt_config
- fi
}
trap finish EXIT
$cord_tester setup --olt --start-switch
diff --git a/src/test/utils/OnosCtrl.py b/src/test/utils/OnosCtrl.py
index 09cbeee..22afa56 100644
--- a/src/test/utils/OnosCtrl.py
+++ b/src/test/utils/OnosCtrl.py
@@ -19,7 +19,9 @@
from OltConfig import OltConfig
import fcntl, socket, struct
-def get_mac(iface = 'ovsbr0', pad = 4):
+def get_mac(iface = None, pad = 4):
+ if iface is None:
+ iface = os.getenv('TEST_SWITCH', 'ovsbr0')
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', bytes(iface[:15])))
@@ -78,7 +80,7 @@
def get_device_id(cls):
'''If running under olt, we get the first switch connected to onos'''
olt = OltConfig()
- did = 'of:' + get_mac('ovsbr0')
+ did = 'of:' + get_mac()
if olt.on_olt():
devices = cls.get_devices()
if devices:
diff --git a/src/test/vrouter/vrouterTest.py b/src/test/vrouter/vrouterTest.py
index 8e602ee..89f11fc 100644
--- a/src/test/vrouter/vrouterTest.py
+++ b/src/test/vrouter/vrouterTest.py
@@ -41,7 +41,7 @@
class vrouter_exchange(unittest.TestCase):
apps = ('org.onosproject.vrouter', 'org.onosproject.fwd')
- device_id = 'of:' + get_mac('ovsbr0')
+ device_id = 'of:' + get_mac()
vrouter_device_dict = { "devices" : {
"{}".format(device_id) : {
"basic" : {