A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 1 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 2 | # Copyright 2016-present Ciena Corporation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 7 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 9 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 16 | import unittest |
| 17 | from nose.tools import * |
| 18 | from scapy.all import * |
A R Karthick | b03cecd | 2016-07-27 10:27:55 -0700 | [diff] [blame] | 19 | from OnosCtrl import OnosCtrl, get_mac |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 20 | from OltConfig import OltConfig |
A R Karthick | b03cecd | 2016-07-27 10:27:55 -0700 | [diff] [blame] | 21 | from OnosFlowCtrl import OnosFlowCtrl |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 22 | from onosclidriver import OnosCliDriver |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 23 | #from quaggaclidriver import QuaggaCliDriver |
Chetan Gaonker | 6cf6e47 | 2016-04-26 14:41:51 -0700 | [diff] [blame] | 24 | from CordContainer import Container, Onos, Quagga |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 25 | from CordTestServer import cord_test_onos_restart, cord_test_quagga_restart, cord_test_quagga_stop, cord_test_quagga_shell |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 26 | from portmaps import g_subscriber_port_map |
A R Karthick | 9313b76 | 2016-11-07 13:14:35 -0800 | [diff] [blame] | 27 | from CordLogger import CordLogger |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 28 | import threading |
| 29 | import time |
| 30 | import os |
| 31 | import json |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 32 | import pexpect |
| 33 | |
| 34 | #from cli import quagga |
| 35 | #from quagga import * |
| 36 | #from cli import requires |
| 37 | #from cli import system |
| 38 | #from generic import * |
| 39 | |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 40 | log.setLevel('INFO') |
| 41 | |
A R Karthick | 9313b76 | 2016-11-07 13:14:35 -0800 | [diff] [blame] | 42 | class vrouter_exchange(CordLogger): |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 43 | |
A R Karthick | 5241473 | 2017-01-31 09:59:47 -0800 | [diff] [blame] | 44 | apps = ('org.onosproject.proxyarp', 'org.onosproject.hostprovider', 'org.onosproject.vrouter', 'org.onosproject.fwd') |
A R Karthick | 078e63a | 2016-07-28 13:59:31 -0700 | [diff] [blame] | 45 | device_id = 'of:' + get_mac() |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 46 | vrouter_device_dict = { "devices" : { |
| 47 | "{}".format(device_id) : { |
| 48 | "basic" : { |
| 49 | "driver" : "softrouter" |
| 50 | } |
| 51 | } |
| 52 | }, |
| 53 | } |
| 54 | zebra_conf = ''' |
| 55 | password zebra |
| 56 | log stdout |
| 57 | service advanced-vty |
| 58 | ! |
Chetan Gaonker | fd3d650 | 2016-05-03 13:23:07 -0700 | [diff] [blame] | 59 | !debug zebra rib |
| 60 | !debug zebra kernel |
| 61 | !debug zebra fpm |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 62 | ! |
| 63 | !interface eth1 |
| 64 | ! ip address 10.10.0.3/16 |
| 65 | line vty |
| 66 | exec-timeout 0 0 |
| 67 | ''' |
| 68 | test_path = os.path.dirname(os.path.realpath(__file__)) |
| 69 | quagga_config_path = os.path.join(test_path, '..', 'setup/quagga-config') |
| 70 | onos_config_path = os.path.join(test_path, '..', 'setup/onos-config') |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 71 | GATEWAY = '192.168.10.50' |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 72 | INGRESS_PORT = 1 |
| 73 | EGRESS_PORT = 2 |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 74 | MAX_PORTS = 100 |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 75 | peer_list = [ ('192.168.10.1', '00:00:00:00:00:01'), ('192.168.11.1', '00:00:00:00:02:01'), ] |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 76 | network_list = [] |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 77 | network_mask = 24 |
| 78 | default_routes_address = ('11.10.10.0/24',) |
| 79 | default_peer_address = peer_list |
| 80 | quagga_ip = os.getenv('QUAGGA_IP') |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 81 | |
| 82 | @classmethod |
| 83 | def setUpClass(cls): |
| 84 | ''' Activate the vrouter apps''' |
| 85 | cls.olt = OltConfig() |
A R Karthick | b03cecd | 2016-07-27 10:27:55 -0700 | [diff] [blame] | 86 | cls.port_map, _ = cls.olt.olt_port_map() |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 87 | if not cls.port_map: |
| 88 | cls.port_map = g_subscriber_port_map |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 89 | time.sleep(3) |
A R Karthick | b03cecd | 2016-07-27 10:27:55 -0700 | [diff] [blame] | 90 | cls.load_device_id() |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 91 | |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 92 | @classmethod |
| 93 | def tearDownClass(cls): |
| 94 | '''Deactivate the vrouter apps''' |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 95 | #cls.vrouter_host_unload() |
A R Karthick | 4e0c091 | 2016-08-17 16:57:42 -0700 | [diff] [blame] | 96 | cls.start_onos(network_cfg = {}) |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 97 | |
A R Karthick | b03cecd | 2016-07-27 10:27:55 -0700 | [diff] [blame] | 98 | @classmethod |
| 99 | def load_device_id(cls): |
| 100 | did = OnosCtrl.get_device_id() |
| 101 | cls.device_id = did |
| 102 | cls.vrouter_device_dict = { "devices" : { |
| 103 | "{}".format(did) : { |
| 104 | "basic" : { |
| 105 | "driver" : "softrouter" |
| 106 | } |
| 107 | } |
| 108 | }, |
| 109 | } |
| 110 | |
A R Karthick | 5241473 | 2017-01-31 09:59:47 -0800 | [diff] [blame] | 111 | @classmethod |
| 112 | def activate_apps(cls, deactivate = False): |
| 113 | for app in cls.apps: |
| 114 | onos_ctrl = OnosCtrl(app) |
| 115 | if deactivate is False: |
| 116 | onos_ctrl.activate() |
| 117 | else: |
| 118 | onos_ctrl.deactivate() |
| 119 | time.sleep(2) |
| 120 | |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 121 | def cliEnter(self): |
| 122 | retries = 0 |
| 123 | while retries < 3: |
| 124 | self.cli = OnosCliDriver(connect = True) |
| 125 | if self.cli.handle: |
| 126 | break |
| 127 | else: |
| 128 | retries += 1 |
| 129 | time.sleep(2) |
| 130 | |
| 131 | def cliExit(self): |
| 132 | self.cli.disconnect() |
| 133 | |
| 134 | @classmethod |
| 135 | def onos_load_config(cls, config): |
| 136 | status, code = OnosCtrl.config(config) |
| 137 | if status is False: |
| 138 | log.info('JSON request returned status %d' %code) |
| 139 | assert_equal(status, True) |
| 140 | |
| 141 | @classmethod |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 142 | def vrouter_config_get(cls, networks = 4, peers = 1, peer_address = None, |
| 143 | route_update = None, router_address = None): |
| 144 | vrouter_configs = cls.generate_vrouter_conf(networks = networks, peers = peers, |
| 145 | peer_address = peer_address, router_address = router_address) |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 146 | return vrouter_configs |
| 147 | ##ONOS router does not support dynamic reconfigurations |
| 148 | #for config in vrouter_configs: |
| 149 | # cls.onos_load_config(config) |
| 150 | # time.sleep(5) |
| 151 | |
| 152 | @classmethod |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 153 | def vrouter_host_load(cls, peer_address = None): |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 154 | index = 1 |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 155 | peer_info = peer_address if peer_address is not None else cls.peer_list |
| 156 | |
| 157 | for host,_ in peer_info: |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 158 | iface = cls.port_map[index] |
| 159 | index += 1 |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 160 | log.info('Assigning ip %s to interface %s' %(host, iface)) |
| 161 | config_cmds = ( 'ifconfig {} 0'.format(iface), |
| 162 | 'ifconfig {0} {1}'.format(iface, host), |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 163 | 'arping -I {0} {1} -c 2'.format(iface, host), |
| 164 | ) |
| 165 | for cmd in config_cmds: |
| 166 | os.system(cmd) |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 167 | |
| 168 | @classmethod |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 169 | def vrouter_host_unload(cls, peer_address = None): |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 170 | index = 1 |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 171 | peer_info = peer_address if peer_address is not None else cls.peer_list |
| 172 | |
| 173 | for host,_ in peer_info: |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 174 | iface = cls.port_map[index] |
| 175 | index += 1 |
| 176 | config_cmds = ('ifconfig {} 0'.format(iface), ) |
| 177 | for cmd in config_cmds: |
| 178 | os.system(cmd) |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 179 | |
| 180 | @classmethod |
| 181 | def start_onos(cls, network_cfg = None): |
| 182 | if type(network_cfg) is tuple: |
| 183 | res = [] |
| 184 | for v in network_cfg: |
| 185 | res += v.items() |
| 186 | config = dict(res) |
| 187 | else: |
| 188 | config = network_cfg |
| 189 | log.info('Restarting ONOS with new network configuration') |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 190 | return cord_test_onos_restart(config = config) |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 191 | |
| 192 | @classmethod |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 193 | def start_quagga(cls, networks = 4, peer_address = None, router_address = None): |
Chetan Gaonker | 6cf6e47 | 2016-04-26 14:41:51 -0700 | [diff] [blame] | 194 | log.info('Restarting Quagga container with configuration for %d networks' %(networks)) |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 195 | config = cls.generate_conf(networks = networks, peer_address = peer_address, router_address = router_address) |
Chetan Gaonker | fd3d650 | 2016-05-03 13:23:07 -0700 | [diff] [blame] | 196 | if networks <= 10000: |
| 197 | boot_delay = 25 |
| 198 | else: |
Chetan Gaonker | 37ad23f | 2016-05-03 17:37:59 -0700 | [diff] [blame] | 199 | delay_map = [60, 100, 150, 200, 300, 450, 600, 800, 1000, 1200] |
| 200 | n = min(networks/100000, len(delay_map)-1) |
| 201 | boot_delay = delay_map[n] |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 202 | cord_test_quagga_restart(config = config, boot_delay = boot_delay) |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 203 | |
| 204 | @classmethod |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 205 | def generate_vrouter_conf(cls, networks = 4, peers = 1, peer_address = None, router_address = None): |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 206 | num = 0 |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 207 | if peer_address is None: |
| 208 | start_peer = ( 192 << 24) | ( 168 << 16) | (10 << 8) | 0 |
| 209 | end_peer = ( 200 << 24 ) | (168 << 16) | (10 << 8) | 0 |
| 210 | else: |
| 211 | ip = peer_address[0][0] |
| 212 | start_ip = ip.split('.') |
| 213 | start_peer = ( int(start_ip[0]) << 24) | ( int(start_ip[1]) << 16) | ( int(start_ip[2]) << 8) | 0 |
| 214 | end_peer = ((int(start_ip[0]) + 8) << 24 ) | (int(start_ip[1]) << 16) | (int(start_ip[2]) << 8) | 0 |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 215 | local_network = end_peer + 1 |
| 216 | ports_dict = { 'ports' : {} } |
| 217 | interface_list = [] |
| 218 | peer_list = [] |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 219 | for n in xrange(start_peer, end_peer, 256): |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 220 | port_map = ports_dict['ports'] |
| 221 | port = num + 1 if num < cls.MAX_PORTS - 1 else cls.MAX_PORTS - 1 |
| 222 | device_port_key = '{0}/{1}'.format(cls.device_id, port) |
| 223 | try: |
| 224 | interfaces = port_map[device_port_key]['interfaces'] |
| 225 | except: |
| 226 | port_map[device_port_key] = { 'interfaces' : [] } |
| 227 | interfaces = port_map[device_port_key]['interfaces'] |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 228 | ip = n + 2 |
| 229 | peer_ip = n + 1 |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 230 | ips = '%d.%d.%d.%d/24'%( (ip >> 24) & 0xff, ( (ip >> 16) & 0xff ), ( (ip >> 8 ) & 0xff ), ip & 0xff) |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 231 | peer = '%d.%d.%d.%d' % ( (peer_ip >> 24) & 0xff, ( ( peer_ip >> 16) & 0xff ), ( (peer_ip >> 8 ) & 0xff ), peer_ip & 0xff ) |
| 232 | mac = RandMAC()._fix() |
| 233 | peer_list.append((peer, mac)) |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 234 | if num < cls.MAX_PORTS - 1: |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 235 | interface_dict = { 'name' : 'b1-{}'.format(port), 'ips': [ips], 'mac' : mac } |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 236 | interfaces.append(interface_dict) |
| 237 | interface_list.append(interface_dict['name']) |
| 238 | else: |
| 239 | interfaces[0]['ips'].append(ips) |
| 240 | num += 1 |
| 241 | if num == peers: |
| 242 | break |
| 243 | quagga_dict = { 'apps': { 'org.onosproject.router' : { 'router' : {}, 'bgp' : { 'bgpSpeakers' : [] } } } } |
| 244 | quagga_router_dict = quagga_dict['apps']['org.onosproject.router']['router'] |
| 245 | quagga_router_dict['ospfEnabled'] = True |
| 246 | quagga_router_dict['interfaces'] = interface_list |
| 247 | quagga_router_dict['controlPlaneConnectPoint'] = '{0}/{1}'.format(cls.device_id, peers + 1) |
| 248 | |
| 249 | #bgp_speaker_dict = { 'apps': { 'org.onosproject.router' : { 'bgp' : { 'bgpSpeakers' : [] } } } } |
| 250 | bgp_speakers_list = quagga_dict['apps']['org.onosproject.router']['bgp']['bgpSpeakers'] |
| 251 | speaker_dict = {} |
| 252 | speaker_dict['name'] = 'bgp{}'.format(peers+1) |
| 253 | speaker_dict['connectPoint'] = '{0}/{1}'.format(cls.device_id, peers + 1) |
| 254 | speaker_dict['peers'] = peer_list |
| 255 | bgp_speakers_list.append(speaker_dict) |
| 256 | cls.peer_list = peer_list |
| 257 | return (cls.vrouter_device_dict, ports_dict, quagga_dict) |
| 258 | |
| 259 | @classmethod |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 260 | def generate_conf(cls, networks = 4, peer_address = None, router_address = None): |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 261 | num = 0 |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 262 | if router_address is None: |
| 263 | start_network = ( 11 << 24) | ( 10 << 16) | ( 10 << 8) | 0 |
| 264 | end_network = ( 172 << 24 ) | ( 0 << 16) | (0 << 8) | 0 |
| 265 | network_mask = 24 |
| 266 | else: |
| 267 | ip = router_address |
| 268 | start_ip = ip.split('.') |
| 269 | network_mask = int(start_ip[3].split('/')[1]) |
| 270 | start_ip[3] = (start_ip[3].split('/'))[0] |
| 271 | start_network = (int(start_ip[0]) << 24) | ( int(start_ip[1]) << 16) | ( int(start_ip[2]) << 8) | 0 |
| 272 | end_network = (172 << 24 ) | (int(start_ip[1]) << 16) | (int(start_ip[2]) << 8) | 0 |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 273 | net_list = [] |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 274 | peer_list = peer_address if peer_address is not None else cls.peer_list |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 275 | network_list = [] |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 276 | for n in xrange(start_network, end_network, 256): |
| 277 | net = '%d.%d.%d.0'%( (n >> 24) & 0xff, ( ( n >> 16) & 0xff ), ( (n >> 8 ) & 0xff ) ) |
| 278 | network_list.append(net) |
| 279 | gateway = peer_list[num % len(peer_list)][0] |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 280 | net_route = 'ip route {0}/{1} {2}'.format(net, network_mask, gateway) |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 281 | net_list.append(net_route) |
| 282 | num += 1 |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 283 | if num == networks: |
| 284 | break |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 285 | cls.network_list = network_list |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 286 | cls.network_mask = network_mask |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 287 | zebra_routes = '\n'.join(net_list) |
Chetan Gaonker | 68d9517 | 2016-05-03 11:16:59 -0700 | [diff] [blame] | 288 | #log.info('Zebra routes: \n:%s\n' %cls.zebra_conf + zebra_routes) |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 289 | return cls.zebra_conf + zebra_routes |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 290 | |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 291 | @classmethod |
| 292 | def vrouter_activate(cls, deactivate = False): |
| 293 | app = 'org.onosproject.vrouter' |
| 294 | onos_ctrl = OnosCtrl(app) |
| 295 | if deactivate is True: |
| 296 | onos_ctrl.deactivate() |
| 297 | else: |
| 298 | onos_ctrl.activate() |
| 299 | time.sleep(3) |
| 300 | |
| 301 | @classmethod |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 302 | def vrouter_configure(cls, networks = 4, peers = 1, peer_address = None, |
| 303 | route_update = None, router_address = None, time_expire = None, adding_new_routes = None): |
| 304 | vrouter_configs = cls.vrouter_config_get(networks = networks, peers = peers, |
| 305 | peer_address = peer_address, route_update = route_update) |
Chetan Gaonker | 46b62d5 | 2016-04-26 10:08:42 -0700 | [diff] [blame] | 306 | cls.start_onos(network_cfg = vrouter_configs) |
A R Karthick | 5241473 | 2017-01-31 09:59:47 -0800 | [diff] [blame] | 307 | cls.activate_apps() |
| 308 | time.sleep(5) |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 309 | cls.vrouter_host_load() |
Chetan Gaonker | 02236ba | 2016-04-26 11:24:34 -0700 | [diff] [blame] | 310 | ##Start quagga |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 311 | cls.start_quagga(networks = networks, peer_address = peer_address, router_address = router_address) |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 312 | return vrouter_configs |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 313 | |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 314 | def vrouter_port_send_recv(self, ingress, egress, dst_mac, dst_ip, positive_test = True): |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 315 | src_mac = '00:00:00:00:00:02' |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 316 | src_ip = '1.1.1.1' |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 317 | self.success = False if positive_test else True |
Chetan Gaonker | 68d9517 | 2016-05-03 11:16:59 -0700 | [diff] [blame] | 318 | timeout = 10 if positive_test else 1 |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 319 | count = 2 if positive_test else 1 |
Chetan Gaonker | 68d9517 | 2016-05-03 11:16:59 -0700 | [diff] [blame] | 320 | self.start_sending = True |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 321 | def recv_task(): |
| 322 | def recv_cb(pkt): |
| 323 | log.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst)) |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 324 | self.success = True if positive_test else False |
| 325 | sniff(count=count, timeout=timeout, |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 326 | lfilter = lambda p: IP in p and p[IP].dst == dst_ip and p[IP].src == src_ip, |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 327 | prn = recv_cb, iface = self.port_map[ingress]) |
Chetan Gaonker | 68d9517 | 2016-05-03 11:16:59 -0700 | [diff] [blame] | 328 | self.start_sending = False |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 329 | |
| 330 | t = threading.Thread(target = recv_task) |
| 331 | t.start() |
| 332 | L2 = Ether(src = src_mac, dst = dst_mac) |
| 333 | L3 = IP(src = src_ip, dst = dst_ip) |
| 334 | pkt = L2/L3 |
| 335 | log.info('Sending a packet with dst ip %s, dst mac %s on port %s to verify if flows are correct' % |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 336 | (dst_ip, dst_mac, self.port_map[egress])) |
Chetan Gaonker | 68d9517 | 2016-05-03 11:16:59 -0700 | [diff] [blame] | 337 | while self.start_sending is True: |
| 338 | sendp(pkt, count=50, iface = self.port_map[egress]) |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 339 | t.join() |
| 340 | assert_equal(self.success, True) |
| 341 | |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 342 | def vrouter_traffic_verify(self, positive_test = True, peer_address = None): |
| 343 | if peer_address is None: |
| 344 | peers = len(self.peer_list) |
| 345 | peer_list = self.peer_list |
| 346 | else: |
| 347 | peers = len(peer_address) |
| 348 | peer_list = peer_address |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 349 | egress = peers + 1 |
| 350 | num = 0 |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 351 | num_hosts = 5 if positive_test else 1 |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 352 | src_mac = '00:00:00:00:00:02' |
| 353 | src_ip = '1.1.1.1' |
| 354 | if self.network_mask != 24: |
| 355 | peers = 1 |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 356 | for network in self.network_list: |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 357 | num_ips = num_hosts |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 358 | octets = network.split('.') |
| 359 | for i in xrange(num_ips): |
| 360 | octets[-1] = str(int(octets[-1]) + 1) |
| 361 | dst_ip = '.'.join(octets) |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 362 | dst_mac = peer_list[ num % peers ] [1] |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 363 | port = (num % peers) |
| 364 | ingress = port + 1 |
| 365 | #Since peers are on the same network |
| 366 | ##Verify if flows are setup by sending traffic across |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 367 | self.vrouter_port_send_recv(ingress, egress, dst_mac, dst_ip, positive_test = positive_test) |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 368 | num += 1 |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 369 | |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 370 | def __vrouter_network_verify(self, networks, peers = 1, positive_test = True, |
| 371 | start_network = None, start_peer_address = None, route_update = None, |
| 372 | invalid_peers = None, time_expire = None, unreachable_route_traffic = None, |
| 373 | deactivate_activate_vrouter = None, adding_new_routes = None): |
| 374 | |
| 375 | _, ports_map, egress_map = self.vrouter_configure(networks = networks, peers = peers, |
| 376 | peer_address = start_peer_address, |
| 377 | route_update = route_update, |
| 378 | router_address = start_network, |
| 379 | time_expire = time_expire, |
| 380 | adding_new_routes = adding_new_routes) |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 381 | self.cliEnter() |
| 382 | ##Now verify |
| 383 | hosts = json.loads(self.cli.hosts(jsonFormat = True)) |
| 384 | log.info('Discovered hosts: %s' %hosts) |
Chetan Gaonker | 68d9517 | 2016-05-03 11:16:59 -0700 | [diff] [blame] | 385 | ##We read from cli if we expect less number of routes to avoid cli timeouts |
| 386 | if networks <= 10000: |
| 387 | routes = json.loads(self.cli.routes(jsonFormat = True)) |
| 388 | #log.info('Routes: %s' %routes) |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 389 | if start_network is not None: |
| 390 | if start_network.split('/')[1] is 24: |
| 391 | assert_equal(len(routes['routes4']), networks) |
| 392 | if start_network.split('/')[1] is not 24: |
| 393 | assert_equal(len(routes['routes4']), 1) |
| 394 | if start_network is None and invalid_peers is None: |
| 395 | assert_equal(len(routes['routes4']), networks) |
| 396 | if invalid_peers is not None: |
| 397 | assert_equal(len(routes['routes4']), 0) |
Chetan Gaonker | 68d9517 | 2016-05-03 11:16:59 -0700 | [diff] [blame] | 398 | flows = json.loads(self.cli.flows(jsonFormat = True)) |
| 399 | flows = filter(lambda f: f['flows'], flows) |
| 400 | #log.info('Flows: %s' %flows) |
| 401 | assert_not_equal(len(flows), 0) |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 402 | if invalid_peers is None: |
| 403 | self.vrouter_traffic_verify() |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 404 | if positive_test is False: |
| 405 | self.__vrouter_network_verify_negative(networks, peers = peers) |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 406 | if time_expire is True: |
| 407 | self.start_quagga(networks = networks, peer_address = start_peer_address, router_address = '12.10.10.1/24') |
| 408 | self.vrouter_traffic_verify() |
| 409 | if unreachable_route_traffic is True: |
| 410 | network_list_backup = self.network_list |
| 411 | self.network_list = ['2.2.2.2','3.3.3.3','4.4.4.4','5.5.5.5'] |
| 412 | self.vrouter_traffic_verify(positive_test = False) |
| 413 | self.network_list = network_list_backup |
| 414 | if deactivate_activate_vrouter is True: |
| 415 | log.info('Deactivating vrouter app in ONOS controller for negative scenario') |
| 416 | self.vrouter_activate(deactivate = True) |
| 417 | #routes = json.loads(self.cli.routes(jsonFormat = False, cmd_exist = False)) |
| 418 | #assert_equal(len(routes['routes4']), 'Command not found') |
| 419 | log.info('Activating vrouter app again in ONOS controller for negative scenario') |
| 420 | self.vrouter_activate(deactivate = False) |
| 421 | routes = json.loads(self.cli.routes(jsonFormat = True)) |
| 422 | assert_equal(len(routes['routes4']), networks) |
| 423 | self.vrouter_traffic_verify() |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 424 | self.cliExit() |
Chetan Gaonker | fe551a2 | 2016-04-29 17:34:57 -0700 | [diff] [blame] | 425 | self.vrouter_host_unload() |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 426 | return True |
| 427 | |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 428 | def __vrouter_network_verify_negative(self, networks, peers = 1): |
| 429 | ##Stop quagga. Test traffic again to see if flows were removed |
| 430 | log.info('Stopping Quagga container') |
A R Karthick | 4a2362c | 2016-06-22 17:32:44 -0700 | [diff] [blame] | 431 | cord_test_quagga_stop() |
Chetan Gaonker | 68d9517 | 2016-05-03 11:16:59 -0700 | [diff] [blame] | 432 | if networks <= 10000: |
| 433 | routes = json.loads(self.cli.routes(jsonFormat = True)) |
| 434 | #Verify routes have been removed |
| 435 | if routes and routes.has_key('routes4'): |
| 436 | assert_equal(len(routes['routes4']), 0) |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 437 | self.vrouter_traffic_verify(positive_test = False) |
| 438 | log.info('OVS flows have been removed successfully after Quagga was stopped') |
| 439 | self.start_quagga(networks = networks) |
| 440 | ##Verify the flows again after restarting quagga back |
Chetan Gaonker | 68d9517 | 2016-05-03 11:16:59 -0700 | [diff] [blame] | 441 | if networks <= 10000: |
| 442 | routes = json.loads(self.cli.routes(jsonFormat = True)) |
| 443 | assert_equal(len(routes['routes4']), networks) |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 444 | self.vrouter_traffic_verify() |
| 445 | log.info('OVS flows have been successfully reinstalled after Quagga was restarted') |
| 446 | |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 447 | def quagga_shell(self, cmd): |
| 448 | shell_cmds = ('vtysh', '"conf t"', '"{}"'.format(cmd)) |
| 449 | quagga_cmd = ' -c '.join(shell_cmds) |
| 450 | return cord_test_quagga_shell(quagga_cmd) |
| 451 | |
| 452 | def test_vrouter_with_5_routes(self): |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 453 | res = self.__vrouter_network_verify(5, peers = 1) |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 454 | assert_equal(res, True) |
| 455 | |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 456 | def test_vrouter_with_5_routes_2_peers(self): |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 457 | res = self.__vrouter_network_verify(5, peers = 2) |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 458 | assert_equal(res, True) |
| 459 | |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 460 | def test_vrouter_with_6_routes_3_peers(self): |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 461 | res = self.__vrouter_network_verify(6, peers = 3) |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 462 | assert_equal(res, True) |
| 463 | |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 464 | def test_vrouter_with_50_routes(self): |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 465 | res = self.__vrouter_network_verify(50, peers = 1) |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 466 | assert_equal(res, True) |
Chetan Gaonker | 6cf6e47 | 2016-04-26 14:41:51 -0700 | [diff] [blame] | 467 | |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 468 | def test_vrouter_with_50_routes_5_peers(self): |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 469 | res = self.__vrouter_network_verify(50, peers = 5) |
| 470 | assert_equal(res, True) |
| 471 | |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 472 | def test_vrouter_with_100_routes(self): |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 473 | res = self.__vrouter_network_verify(100, peers = 1) |
| 474 | assert_equal(res, True) |
| 475 | |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 476 | def test_vrouter_with_100_routes_10_peers(self): |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 477 | res = self.__vrouter_network_verify(100, peers = 10) |
| 478 | assert_equal(res, True) |
| 479 | |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 480 | def test_vrouter_with_300_routes(self): |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 481 | res = self.__vrouter_network_verify(300, peers = 1) |
| 482 | assert_equal(res, True) |
| 483 | |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 484 | def test_vrouter_with_1000_routes(self): |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 485 | res = self.__vrouter_network_verify(1000, peers = 1) |
Chetan Gaonker | 6cf6e47 | 2016-04-26 14:41:51 -0700 | [diff] [blame] | 486 | assert_equal(res, True) |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 487 | |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 488 | def test_vrouter_with_10000_routes(self): |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 489 | res = self.__vrouter_network_verify(10000, peers = 1) |
Chetan Gaonker | 6cf6e47 | 2016-04-26 14:41:51 -0700 | [diff] [blame] | 490 | assert_equal(res, True) |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 491 | |
Chetan Gaonker | 6cf6e47 | 2016-04-26 14:41:51 -0700 | [diff] [blame] | 492 | @nottest |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 493 | def test_vrouter_with_100000_routes(self): |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 494 | res = self.__vrouter_network_verify(100000, peers = 1) |
Chetan Gaonker | 6cf6e47 | 2016-04-26 14:41:51 -0700 | [diff] [blame] | 495 | assert_equal(res, True) |
| 496 | |
| 497 | @nottest |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 498 | def test_vrouter_with_1000000_routes(self): |
Chetan Gaonker | 8e25e1b | 2016-05-02 13:42:21 -0700 | [diff] [blame] | 499 | res = self.__vrouter_network_verify(1000000, peers = 1) |
Chetan Gaonker | 6cf6e47 | 2016-04-26 14:41:51 -0700 | [diff] [blame] | 500 | assert_equal(res, True) |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 501 | |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 502 | def test_vrouter_with_5_routes_stopping_quagga(self): |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 503 | res = self.__vrouter_network_verify(5, peers = 1, positive_test = False) |
| 504 | |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 505 | def test_vrouter_with_50_routes_stopping_quagga(self): |
Chetan Gaonker | b6064fa | 2016-05-02 16:29:57 -0700 | [diff] [blame] | 506 | res = self.__vrouter_network_verify(50, peers = 1, positive_test = False) |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 507 | |
| 508 | def test_vrouter_with_route_update(self): |
| 509 | res = self.__vrouter_network_verify(5, peers = 2, positive_test = True) |
| 510 | assert_equal(res, True) |
| 511 | peer_info = [('192.168.20.1', '00:00:00:00:01:01'), ('192.168.21.1', '00:00:00:00:02:01')] |
| 512 | res = self.__vrouter_network_verify(5, peers = 2, positive_test = True, |
| 513 | start_peer_address = peer_info, route_update = True) |
| 514 | assert_equal(res, True) |
| 515 | |
| 516 | def test_vrouter_with_classA_route_update(self): |
| 517 | router_address = '11.10.10.0/8' |
| 518 | res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_network = router_address) |
| 519 | assert_equal(res, True) |
| 520 | |
| 521 | def test_vrouter_with_classB_route_update(self): |
| 522 | router_address = '11.10.10.0/16' |
| 523 | res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_network = router_address) |
| 524 | assert_equal(res, True) |
| 525 | |
| 526 | def test_vrouter_with_classless_route_update(self): |
| 527 | router_address = '11.10.10.0/12' |
| 528 | res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_network = router_address) |
| 529 | assert_equal(res, True) |
| 530 | |
| 531 | def test_vrouter_with_classA_duplicate_route_update(self): |
| 532 | router_address = '11.10.10.0/8' |
| 533 | res = self.__vrouter_network_verify(5, peers = 1, positive_test = True, start_network = router_address) |
| 534 | assert_equal(res, True) |
| 535 | |
| 536 | def test_vrouter_with_classB_duplicate_route_update(self): |
| 537 | router_address = '11.10.10.0/16' |
| 538 | res = self.__vrouter_network_verify(5, peers = 1, positive_test = True, start_network = router_address) |
| 539 | assert_equal(res, True) |
| 540 | |
| 541 | def test_vrouter_with_classless_duplicate_route_update(self): |
| 542 | router_address = '11.10.10.0/12' |
| 543 | res = self.__vrouter_network_verify(5, peers = 1, positive_test = True, start_network = router_address) |
| 544 | assert_equal(res, True) |
| 545 | |
| 546 | def test_vrouter_with_invalid_peers(self): |
| 547 | peer_info = [('239.255.255.250', '00:00:00:00:01:01'), ('239.255.255.240', '00:00:00:00:02:01')] |
| 548 | res = self.__vrouter_network_verify(5, peers = 2, positive_test = True, |
| 549 | start_peer_address = peer_info, invalid_peers= True) |
| 550 | assert_equal(res, True) |
| 551 | |
| 552 | @nottest |
| 553 | def test_vrouter_with_traffic_sent_between_peers_connected_to_onos(self): |
| 554 | res = self.__vrouter_network_verify(5, peers = 2, positive_test = True, traffic_running_between_peers = True) |
| 555 | assert_equal(res, True) |
| 556 | |
| 557 | @nottest |
| 558 | def test_vrouter_with_routes_time_expire(self): |
| 559 | res = self.__vrouter_network_verify(5, peers = 2, positive_test = True, time_expire = True) |
| 560 | assert_equal(res, True) |
| 561 | |
| 562 | def test_vrouter_with_unreachable_route(self): |
| 563 | res = self.__vrouter_network_verify(5, peers = 2, positive_test = True, unreachable_route_traffic = True) |
| 564 | assert_equal(res, True) |
| 565 | |
| 566 | @nottest |
| 567 | def test_vrouter_with_enabling_disabling_vrouter_app(self): |
| 568 | res = self.__vrouter_network_verify(5, peers = 2, positive_test = True, deactivate_activate_vrouter = True) |
| 569 | assert_equal(res, True) |
| 570 | |
| 571 | def test_vrouter_with_adding_new_routes_in_routing_table(self): |
| 572 | res = self.__vrouter_network_verify(5, peers = 2, positive_test = True) |
| 573 | cmd = 'ip route 21.10.20.0/24 192.168.10.1' |
| 574 | self.quagga_shell(cmd) |
| 575 | self.vrouter_traffic_verify() |
| 576 | self.network_list = [ '21.10.20.0' ] |
| 577 | self.network_mask = 24 |
| 578 | self.vrouter_traffic_verify() |
| 579 | assert_equal(res, True) |
| 580 | |
| 581 | def test_vrouter_with_removing_old_routes_in_routing_table(self): |
| 582 | res = self.__vrouter_network_verify(5, peers = 2, positive_test = True) |
| 583 | cmd = 'ip route 21.10.20.0/24 192.168.10.1' |
| 584 | self.quagga_shell(cmd) |
| 585 | self.vrouter_traffic_verify() |
| 586 | old_network_list = self.network_list |
| 587 | old_network_mask = self.network_mask |
| 588 | self.network_list = [ '21.10.20.0' ] |
| 589 | self.network_mask = 24 |
| 590 | self.vrouter_traffic_verify() |
| 591 | assert_equal(res, True) |
| 592 | cmd = 'no ip route 21.10.20.0/24 192.168.10.1' |
| 593 | self.quagga_shell(cmd) |
A R Karthick | a93829a | 2016-07-01 10:08:23 -0700 | [diff] [blame] | 594 | time.sleep(5) |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 595 | self.vrouter_traffic_verify(positive_test = False) |
| 596 | self.network_mask = old_network_mask |
| 597 | self.network_list = old_network_list |
| 598 | self.vrouter_traffic_verify(positive_test = True) |
| 599 | |
| 600 | def test_vrouter_modifying_nexthop_route_in_routing_table(self): |
| 601 | peer_info = [('192.168.10.1', '00:00:00:00:01:01'), ('192.168.11.1', '00:00:00:00:02:01')] |
| 602 | router_address = '11.10.10.0/24' |
| 603 | res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, |
| 604 | start_peer_address = peer_info, start_network = router_address) |
| 605 | cmd = 'ip route 11.10.10.0/24 192.168.20.1' |
| 606 | self.quagga_shell(cmd) |
| 607 | self.vrouter_traffic_verify(positive_test = True) |
| 608 | assert_equal(res, True) |
| 609 | |
| 610 | |
| 611 | def test_vrouter_deleting_alternative_nexthop_in_routing_table(self): |
| 612 | peer_info = [('192.168.10.1', '00:00:00:00:01:01'), ('192.168.11.1', '00:00:00:00:02:01')] |
| 613 | router_address = '11.10.10.0/24' |
| 614 | res = self.__vrouter_network_verify(1, peers = 2, positive_test = True, |
| 615 | start_peer_address = peer_info, start_network = router_address) |
| 616 | cmd = 'no ip route 11.10.10.0/24 192.168.10.1' |
| 617 | self.quagga_shell(cmd) |
A R Karthick | a93829a | 2016-07-01 10:08:23 -0700 | [diff] [blame] | 618 | time.sleep(5) |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 619 | self.vrouter_traffic_verify(positive_test = False) |
| 620 | assert_equal(res, True) |
| 621 | |
| 622 | def test_vrouter_deleting_some_routes_in_routing_table(self): |
| 623 | peer_info = [('192.168.10.1', '00:00:00:00:01:01'), ('192.168.11.1', '00:00:00:00:02:01')] |
| 624 | router_address = '11.10.10.0/24' |
| 625 | res = self.__vrouter_network_verify(10, peers = 2, positive_test = True, |
| 626 | start_peer_address = peer_info, start_network = router_address) |
| 627 | cmd = 'no ip route 11.10.10.0/24 192.168.10.1' |
| 628 | self.quagga_shell(cmd) |
| 629 | cmd = 'no ip route 11.10.13.0/24 192.168.11.1' |
| 630 | self.quagga_shell(cmd) |
| 631 | cmd = 'no ip route 11.10.14.0/24 192.168.10.1' |
| 632 | self.quagga_shell(cmd) |
| 633 | self.vrouter_traffic_verify(positive_test = True) |
| 634 | assert_equal(res, True) |
| 635 | |
| 636 | |
| 637 | def test_vrouter_deleting_and_adding_routes_in_routing_table(self): |
| 638 | peer_info = [('192.168.10.1', '00:00:00:00:01:01'), ('192.168.11.1', '00:00:00:00:02:01')] |
| 639 | router_address = '11.10.10.0/24' |
| 640 | res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_peer_address = peer_info, start_network = router_address) |
| 641 | cmd = 'no ip route 11.10.10.0/24 192.168.10.1' |
| 642 | self.quagga_shell(cmd) |
| 643 | cmd = 'ip route 11.10.10.0/24 192.168.10.1' |
| 644 | self.quagga_shell(cmd) |
| 645 | self.vrouter_traffic_verify(positive_test = True) |
| 646 | assert_equal(res, True) |
| 647 | |
| 648 | def test_vrouter_toggling_nexthop_interface(self): |
| 649 | peer_info = [('192.168.10.1', '00:00:00:00:01:01'), ('192.168.11.1', '00:00:00:00:02:01')] |
| 650 | router_address = '11.10.10.0/24' |
| 651 | res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_peer_address = peer_info, start_network = router_address) |
A R Karthick | a93829a | 2016-07-01 10:08:23 -0700 | [diff] [blame] | 652 | iface = self.port_map[1] |
| 653 | #toggle the interface to trigger host removal. |
| 654 | cmds = ('ifconfig {} down'.format(iface), |
| 655 | 'sleep 2', |
| 656 | 'ifconfig {} 0'.format(iface),) |
| 657 | for cmd in cmds: |
| 658 | os.system(cmd) |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 659 | self.vrouter_traffic_verify(positive_test = False) |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 660 | host = "192.168.10.1" |
A R Karthick | a93829a | 2016-07-01 10:08:23 -0700 | [diff] [blame] | 661 | cmd = 'ifconfig {0} {1} up'.format(iface, host) |
| 662 | os.system(cmd) |
| 663 | #wait for arp refresh |
| 664 | time.sleep(60) |
ChetanGaonker | 70820bb | 2016-06-29 18:11:57 -0700 | [diff] [blame] | 665 | self.vrouter_traffic_verify(positive_test = True) |
| 666 | assert_equal(res, True) |