blob: 00a79445d716b9c5dddd64c91129f16664206e21 [file] [log] [blame]
Anil Kumar Sanka8915c832017-02-02 01:07:53 +00001#
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
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
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#
16import unittest
17from nose.tools import *
18from scapy.all import *
A.R Karthickbe7768c2017-03-17 11:39:41 -070019from CordTestUtils import get_mac
20from OnosCtrl import OnosCtrl
Anil Kumar Sanka8915c832017-02-02 01:07:53 +000021from OltConfig import OltConfig
22from OnosFlowCtrl import OnosFlowCtrl
23from onosclidriver import OnosCliDriver
24#from quaggaclidriver import QuaggaCliDriver
25from CordContainer import Container, Onos, Quagga
26from CordTestServer import cord_test_onos_restart, cord_test_quagga_restart, cord_test_quagga_stop, cord_test_quagga_shell
27from portmaps import g_subscriber_port_map
28from CordLogger import CordLogger
29import threading
30import time
31import os
32import json
33import pexpect
34import random
35from netaddr.ip import IPNetwork, IPAddress
36
37#from cli import quagga
38#from quagga import *
39#from cli import requires
40#from cli import system
41#from generic import *
42
43log.setLevel('INFO')
44
45class ipv6vrouter_exchange(CordLogger):
46
47 apps = ('org.onosproject.vrouter', 'org.onosproject.fwd')
48 device_id = 'of:' + get_mac()
49 vrouter_device_dict = { "devices" : {
50 "{}".format(device_id) : {
51 "basic" : {
52 "driver" : "softrouter"
53 }
54 }
55 },
56 }
57 zebra_conf = '''
58password zebra
59log stdout
60service advanced-vty
61!
62!debug zebra rib
63!debug zebra kernel
64!debug zebra fpm
65!
66interface eth1
67 ipv6 address 2001::10/32
68line vty
69 exec-timeout 0 0
70'''
71
72#! ip address 10.10.0.3/16
73 test_path = os.path.dirname(os.path.realpath(__file__))
74 quagga_config_path = os.path.join(test_path, '..', 'setup/quagga-config')
75 onos_config_path = os.path.join(test_path, '..', 'setup/onos-config')
76 GATEWAY = '1000:10:0:0:0:0:0:164'
77 INGRESS_PORT = 1
78 EGRESS_PORT = 2
79 MAX_PORTS = 100
80 peer_list = [ ('2001:0:10:0:0:0:10:1', '00:00:00:00:00:01'), ('2001:0:20:0:0:0:20:1', '00:00:00:00:02:01'), ]
81 network_list = []
82 network_mask = 64
83 default_routes_address = ('1001:0:10:0::/32',)
84 default_peer_address = peer_list
85 quagga_ip = os.getenv('QUAGGA_IP')
86
87 @classmethod
88 def setUpClass(cls):
89 ''' Activate the vrouter apps'''
90 cls.olt = OltConfig()
91 cls.port_map, _ = cls.olt.olt_port_map()
92 if not cls.port_map:
93 cls.port_map = g_subscriber_port_map
94 time.sleep(3)
95 cls.load_device_id()
96
97 @classmethod
98 def tearDownClass(cls):
99 '''Deactivate the vrouter apps'''
100 cls.vrouter_host_unload()
101 cls.start_onos(network_cfg = {})
102
103 @classmethod
104 def load_device_id(cls):
105 did = OnosCtrl.get_device_id()
106 cls.device_id = did
107 cls.vrouter_device_dict = { "devices" : {
108 "{}".format(did) : {
109 "basic" : {
110 "driver" : "softrouter"
111 }
112 }
113 },
114 }
115
116 def cliEnter(self):
117 retries = 0
118 while retries < 3:
119 self.cli = OnosCliDriver(connect = True)
120 if self.cli.handle:
121 break
122 else:
123 retries += 1
124 time.sleep(2)
125
126 def cliExit(self):
127 self.cli.disconnect()
128
129 @classmethod
130 def onos_load_config(cls, config):
131 status, code = OnosCtrl.config(config)
132 if status is False:
133 log.info('JSON request returned status %d' %code)
134 assert_equal(status, True)
135
136 @classmethod
137 def vrouter_config_get(cls, networks = 4, peers = 1, peer_address = None,
138 route_update = None, router_address = None, specific_peer = None):
139 vrouter_configs = cls.generate_vrouter_conf(networks = networks, peers = peers,specific_peer = specific_peer,
140 peer_address = peer_address, router_address = router_address)
141 return vrouter_configs
142
143 @classmethod
144 def host_config_load(cls, host_config = None):
145 for host in host_config:
146 status, code = OnosCtrl.host_config(host)
147 if status is False:
148 log.info('JSON request returned status %d' %code)
149 assert_equal(status, True)
150
151 @classmethod
152 def generate_host_config(cls,hosts_list=None):
153 num = 1
154 hosts_dict = {}
155 if hosts_list is not None:
156 hosts = hosts_list
157 else:
158 hosts = cls.peer_list
159 for host, mac in hosts:
160 port = num if num < cls.MAX_PORTS - 1 else cls.MAX_PORTS - 1
161 hosts_dict[host] = {'mac':mac, 'vlan':'none', 'ipAddresses':[host], 'location':{ 'elementId' : '{}'.format(cls.device_id), 'port': port}}
162 num += 1
163 return hosts_dict.values()
164
165
166 @classmethod
167 def vrouter_host_load(cls, peer_address = None):
168 index = 1
169 peer_info = peer_address if peer_address is not None else cls.peer_list
170
171 for host,_ in peer_info:
172 iface = cls.port_map[index]
173 index += 1
174 log.info('Assigning ip %s to interface %s' %(host, iface))
175 config_cmds = ( 'ifconfig {} 0'.format(iface),
176 'ifconfig {0} inet6 add {1}/64'.format(iface, host),
177 'arping -I {0} {1} -c 2'.format(iface, host),
178 )
179 for cmd in config_cmds:
180 os.system(cmd)
181
182 @classmethod
183 def vrouter_host_unload(cls, peer_address = None):
184 index = 1
185 peer_info = peer_address if peer_address is not None else cls.peer_list
186
187 for host,_ in peer_info:
188 iface = cls.port_map[index]
189 index += 1
190 config_cmds = ('ifconfig {} 0'.format(iface), )
191 for cmd in config_cmds:
192 os.system(cmd)
193
194 @classmethod
195 def start_onos(cls, network_cfg = None):
196 if type(network_cfg) is tuple:
197 res = []
198 for v in network_cfg:
199 res += v.items()
200 config = dict(res)
201 else:
202 config = network_cfg
203 log.info('Restarting ONOS with new network configuration %s'%config)
204 return cord_test_onos_restart(config = config)
205
206 @classmethod
207 def randomipv6(cls, subnet='2001::', prefix=64):
208 random.seed()
209 ipv6_address = IPAddress(subnet) + random.getrandbits(16)
210 ipv6_network = IPNetwork(ipv6_address)
211 ipv6_network.prefixlen = prefix
212 output = '{},{}'.format(ipv6_address,ipv6_network)
213 return '{}'.format(ipv6_address),'{}'.format(ipv6_network)
214
215 @classmethod
216 def start_quagga(cls, networks = 4, peer_address = None, router_address = None):
217 log.info('Peer address in quagga start is %s'%peer_address)
218 log.info('Restarting Quagga container with configuration for %d networks' %(networks))
219 config = cls.generate_conf(networks = networks, peer_address = peer_address, router_address = router_address)
220 if networks <= 10000:
221 boot_delay = 25
222 else:
223 delay_map = [60, 100, 150, 200, 300, 450, 600, 800, 1000, 1200]
224 n = min(networks/100000, len(delay_map)-1)
225 boot_delay = delay_map[n]
226 cord_test_quagga_restart(config = config, boot_delay = boot_delay)
227
228 @classmethod
229 def generate_vrouter_conf(cls, networks = 4, peers = 1, peer_address = None, specific_peer = None,router_address = None):
230 num = 0
231 count = 0
232 if peer_address is None:
233 start_peer = ( 10 << 16 )
234 end_peer = ( 9999 << 16 )
235 else:
236 ip = peer_address[0][0]
237 start_ip = ip.split(':')
238 start_peer = ( int(start_ip[6]) << 16)
239 end_peer = ( 9999 << 16 )
240 local_network = end_peer + 1
241 ports_dict = { 'ports' : {} }
242 interface_list = []
243 peer_list = []
244 for n in xrange(start_peer, end_peer, 65536):
245 port_map = ports_dict['ports']
246 port = num+1 if count < cls.MAX_PORTS - 1 else cls.MAX_PORTS - 1
247 device_port_key = '{0}/{1}'.format(cls.device_id, port)
248 try:
249 interfaces = port_map[device_port_key]['interfaces']
250 except:
251 port_map[device_port_key] = { 'interfaces' : [] }
252 interfaces = port_map[device_port_key]['interfaces']
253 if specific_peer is None:
254 peer_ip = '2001:0:0:0:0:0:' + '%s:1'%( ( n >> 16 ) & 0xffff )
255 else:
256 start_ip[6] = '%s'%( ( n >> 16 ) & 0xffff )
257 start_ip[-1] = '1'
258 peer_ip = ':'.join(start_ip)
259 peer_nt = peer_ip + '/112'
260 mac = RandMAC()._fix()
261 peer_list.append((peer_ip, mac))
262 log.info('peer ip is %s and and peer network is %s'%(peer_ip,peer_nt))
263 if num < cls.MAX_PORTS - 1:
264 interface_dict = { 'name' : 'b1-{}'.format(port), 'ips': [peer_nt], 'mac' : mac }
265 interfaces.append(interface_dict)
266 interface_list.append(interface_dict['name'])
267 else:
268 interfaces[0]['ips'].append(peer_nt)
269 num += 1
270 if num == peers:
271 break
272 quagga_dict = { 'apps': { 'org.onosproject.router' : { 'router' : {}, 'bgp' : { 'bgpSpeakers' : [] } } } }
273 quagga_router_dict = quagga_dict['apps']['org.onosproject.router']['router']
274 quagga_router_dict['ospfEnabled'] = True
275 quagga_router_dict['interfaces'] = interface_list
276 quagga_router_dict['controlPlaneConnectPoint'] = '{0}/{1}'.format(cls.device_id, peers + 1)
277
278 #bgp_speaker_dict = { 'apps': { 'org.onosproject.router' : { 'bgp' : { 'bgpSpeakers' : [] } } } }
279 bgp_speakers_list = quagga_dict['apps']['org.onosproject.router']['bgp']['bgpSpeakers']
280 speaker_dict = {}
281 speaker_dict['name'] = 'bgp{}'.format(peers+1)
282 speaker_dict['connectPoint'] = '{0}/{1}'.format(cls.device_id, peers + 1)
283 speaker_dict['peers'] = peer_list
284 bgp_speakers_list.append(speaker_dict)
285 cls.peer_list = peer_list
286 return (cls.vrouter_device_dict, ports_dict, quagga_dict)
287
288
289 @classmethod
290 def generate_conf(cls, networks = 4, peer_address = None, router_address = None):
291 num = 0
292 if router_address is None:
293 start_network = ( 10 << 16 )
294 end_network = ( 9999 << 16 )
295 network_mask = 112
296 else:
297 ip = router_address
298 start_ip = ip.split(':')
299 network_mask = int(start_ip[7].split('/')[1])
300 start_network = (int(start_ip[6]) << 16)
301 end_network = (9999 << 16)
302 net_list = []
303 peer_list = peer_address if peer_address is not None else cls.peer_list
304 network_list = []
305 for n in xrange(start_network, end_network, 65536):
306 if router_address is None:
307 net = '3001:0:0:0:0:0:' + '%s:0'%( ( n >> 16 ) & 0xffff )
308 else:
309 start_ip[6] = '%s'%( ( n >> 16 ) & 0xffff )
310 net = ':'.join((start_ip[0],start_ip[1],start_ip[2],start_ip[3],start_ip[4],start_ip[5],start_ip[6],start_ip[7][0]))
311 network_list.append(net)
312 gateway = peer_list[num % len(peer_list)][0]
313 net_route = 'ipv6 route {0}/{1} {2}'.format(net, network_mask, gateway)
314 net_list.append(net_route)
315 num += 1
316 if num == networks:
317 break
318 cls.network_list = network_list
319 cls.network_mask = network_mask
320 zebra_routes = '\n'.join(net_list)
321 return cls.zebra_conf + zebra_routes
322
323 @classmethod
324 def vrouter_activate(cls, deactivate = False):
325 app = 'org.onosproject.vrouter'
326 onos_ctrl = OnosCtrl(app)
327 if deactivate is True:
328 onos_ctrl.deactivate()
329 else:
330 onos_ctrl.activate()
331 time.sleep(3)
332
333 @classmethod
334 def vrouter_configure(cls, networks = 4, peers = 1, peer_address = None,specific_peer = None,
335 route_update = None, router_address = None, time_expire = None, adding_new_routes = None):
336 vrouter_configs = cls.vrouter_config_get(networks = networks, peers = peers,specific_peer = specific_peer,
337 peer_address = peer_address, route_update = route_update)
338 cls.start_onos(network_cfg = vrouter_configs)
339 hostcfg = cls.generate_host_config()
340 cls.host_config_load(host_config = hostcfg)
341 ##Start quagga
342 cls.start_quagga(networks = networks, peer_address = peer_address, router_address = router_address)
343 return vrouter_configs
344
345 def vrouter_port_send_recv(self, ingress, egress, dst_mac, dst_ip, positive_test = True):
346 src_mac = '00:00:00:00:00:02'
347 src_ip = '1000:11:12:13:14:15:16:17'
348 self.success = False if positive_test else True
349 timeout = 10 if positive_test else 1
350 count = 2 if positive_test else 1
351 self.start_sending = True
352 def recv_task():
353 def recv_cb(pkt):
354 log.info('Pkt seen with ingress ip %s, egress ip %s' %(pkt[IP].src, pkt[IP].dst))
355 self.success = True if positive_test else False
356 sniff(count=count, timeout=timeout,
357 lfilter = lambda p: IP in p and p[IP].dst == dst_ip and p[IP].src == src_ip,
358 prn = recv_cb, iface = self.port_map[ingress])
359 self.start_sending = False
360
361 t = threading.Thread(target = recv_task)
362 t.start()
363 L2 = Ether(src = src_mac, dst = dst_mac)
364 L3 = IPv6(src=src_ip,dst = dst_ip)
365 pkt = L2/L3
366 log.info('Sending a packet with dst ip %s, dst mac %s on port %s to verify if flows are correct' %
367 (dst_ip, dst_mac, self.port_map[egress]))
368 while self.start_sending is True:
369 sendp(pkt, count=50, iface = self.port_map[egress])
370 t.join()
371 assert_equal(self.success, True)
372
373 def vrouter_traffic_verify(self, positive_test = True, peer_address = None):
374 if peer_address is None:
375 peers = len(self.peer_list)
376 peer_list = self.peer_list
377 else:
378 peers = len(peer_address)
379 peer_list = peer_address
380 egress = peers + 1
381 num = 0
382 num_hosts = 5 if positive_test else 1
383 src_mac = '00:00:00:00:00:02'
384 src_ip = '1000:11:12:13:14:15:16:17'
385 last_bytes = [1234,8364,7360,'0af3','fdac']
386 for network in self.network_list:
387 num_ips = num_hosts
388 octets = network.split(':')
389 for byte in last_bytes:
390 octets[-1] = str(byte)
391 dst_ip = ':'.join(octets)
392 dst_mac = peer_list[ num % peers ] [1]
393 port = (num % peers)
394 ingress = port + 1
395 #Since peers are on the same network
396 ##Verify if flows are setup by sending traffic across
397 self.vrouter_port_send_recv(ingress, egress, dst_mac, dst_ip, positive_test = positive_test)
398 num += 1
399
400 def __vrouter_network_verify(self, networks, peers = 1, positive_test = True,
401 start_network = None, start_peer_address = None, route_update = None,
402 invalid_peers = None, time_expire = None, unreachable_route_traffic = None,
403 deactivate_activate_vrouter = None, adding_new_routes = None,
404 specific_peer = None):
405
406 _, ports_map, egress_map = self.vrouter_configure(networks = networks, peers = peers,
407 peer_address = start_peer_address,
408 route_update = route_update,
409 router_address = start_network,
410 time_expire = time_expire,
411 adding_new_routes = adding_new_routes,
412 specific_peer = specific_peer)
413 if self.network_list > 50:
414 wait = len(self.network_list)/20
415 time.sleep(wait)
416 log.info('waiting for %d seconds to verify routes in ONOS'%wait)
417 else:
418 time.sleep(5)
419 self.cliEnter()
420 routes = json.loads(self.cli.routes(jsonFormat = True))
421 assert_equal(len(routes['routes6']), networks)
422 if invalid_peers is None:
423 self.vrouter_traffic_verify()
424 if time_expire is True:
425 self.start_quagga(networks = networks, peer_address = start_peer_address, router_address = '12.10.10.1/24')
426 self.vrouter_traffic_verify()
427 if unreachable_route_traffic is True:
428 network_list_backup = self.network_list
429 self.network_list = ['1:1:1:1:1:1:1:1','2:2:2:2:2:2:2:2','3:3:3:3:3:3:3:3','4:4:4:4:4:4:4:4']
430 self.vrouter_traffic_verify(positive_test = False)
431 self.network_list = network_list_backup
432 if deactivate_activate_vrouter is True:
433 log.info('Deactivating vrouter app in ONOS controller for negative scenario')
434 self.vrouter_activate(deactivate = True)
435 #routes = json.loads(self.cli.routes(jsonFormat = False, cmd_exist = False))
436 #assert_equal(len(routes['routes4']), 'Command not found')
437 log.info('Activating vrouter app again in ONOS controller for negative scenario')
438 self.vrouter_activate(deactivate = False)
439 if self.network_list > 50:
440 wait = len(self.network_list)/20
441 time.sleep(wait)
442 log.info('waiting for %d seconds to verify routes in ONOS'%wait)
443 else:
444 time.sleep(5)
445 routes = json.loads(self.cli.routes(jsonFormat = True))
446 assert_equal(len(routes['routes4']), networks)
447 self.vrouter_traffic_verify()
448 self.cliExit()
449 return True
450
451 def __vrouter_network_verify_negative(self, networks, peers = 1):
452 ##Stop quagga. Test traffic again to see if flows were removed
453 log.info('Stopping Quagga container')
454 cord_test_quagga_stop()
455 self.vrouter_traffic_verify(positive_test = False)
456 log.info('OVS flows have been removed successfully after Quagga was stopped')
457 self.start_quagga(networks = networks)
458 self.vrouter_traffic_verify()
459 log.info('OVS flows have been successfully reinstalled after Quagga was restarted')
460
461 def quagga_shell(self, cmd):
462 shell_cmds = ('vtysh', '"conf t"', '"{}"'.format(cmd))
463 quagga_cmd = ' -c '.join(shell_cmds)
464 return cord_test_quagga_shell(quagga_cmd)
465
466 def test_vrouter_ipv6_with_5_routes(self):
467 res = self.__vrouter_network_verify(5, peers = 1)
468 assert_equal(res, True)
469
470 def test_vrouter_ipv6_with_5_routes_quagga_restart_without_config(self):
471 res = self.__vrouter_network_verify(5, peers = 1)
472 assert_equal(res, True)
473 log.info('Restart Quagga container without config retain')
474 cord_test_quagga_restart()
475 self.vrouter_traffic_verify(positive_test = False)
476
477 def test_vrouter_ipv6_with_5_routes_quagga_restart_with_config(self):
478 res = self.__vrouter_network_verify(5, peers = 1)
479 assert_equal(res, True)
480 log.info('verifying vrouter traffic after Quagga restart with config retain')
481 #cord_test_quagga_restart()
482 self.start_quagga(networks=5)
483 self.vrouter_traffic_verify(positive_test = True)
484
485 def test_vrouter_ipv6_with_5_routes_quagga_stop(self):
486 res = self.__vrouter_network_verify(5, peers = 1)
487 assert_equal(res, True)
488 log.info('verifying vrouter traffic after Quagga stop')
489 cord_test_quagga_stop()
490 self.vrouter_traffic_verify(positive_test = False)
491
492 def test_vrouter_ipv6_with_5_routes_quagga_stop_and_start(self):
493 res = self.__vrouter_network_verify(5, peers = 1)
494 assert_equal(res, True)
495 log.info('verifying vrouter traffic after Quagga stop and start again')
496 cord_test_quagga_stop()
497 self.vrouter_traffic_verify(positive_test = False)
498 self.start_quagga(networks=5)
499 self.vrouter_traffic_verify(positive_test = True)
500
501 def test_vrouter_ipv6_with_5_routes_onos_restart_without_config(self):
502 res = self.__vrouter_network_verify(5, peers = 1)
503 assert_equal(res, True)
504 log.info('verifying vrouter traffic after ONOS restart without config retain')
505 cord_test_onos_restart()
506 self.vrouter_traffic_verify(positive_test = False)
507
508 def test_vrouter_ipv6_with_5_routes_onos_restart_with_config(self):
509 res = self.__vrouter_network_verify(5, peers = 1)
510 assert_equal(res, True)
511 log.info('verifying vrouter traffic after ONOS restart with config retain')
512 vrouter_configs = self.vrouter_config_get(networks = 5, peers = 1,
513 peer_address = None, route_update = None)
514 self.start_onos(network_cfg=vrouter_configs)
515 mac = RandMAC()._fix()
516 hostcfg = self.generate_host_config(hosts_list = [('2001:0:0:0:0:0:10:1',mac)])
517 self.host_config_load(host_config = hostcfg)
518 time.sleep(10)
519 self.vrouter_traffic_verify(positive_test = True)
520
521 def test_vrouter_ipv6_with_5_routes_restart_quagga_and_onos_with_config(self):
522 res = self.__vrouter_network_verify(5, peers = 1)
523 assert_equal(res, True)
524 log.info('verifying vrouter traffic after Quagga and ONOS restart with config retain')
525 #cord_test_quagga_restart()
526 self.start_quagga(networks=5)
527 vrouter_configs = self.vrouter_config_get(networks = 5, peers = 1,
528 peer_address = None, route_update = None)
529 self.start_onos(network_cfg = vrouter_configs)
530 mac = RandMAC()._fix()
531 hostcfg = self.generate_host_config(hosts_list = [('2001:0:0:0:0:0:10:1',mac)])
532 self.host_config_load(host_config = hostcfg)
533 time.sleep(10)
534 self.vrouter_traffic_verify(positive_test = True)
535
536 def test_vrouter_ipv6_with_5_routes_2_peers(self):
537 res = self.__vrouter_network_verify(5, peers = 2)
538 assert_equal(res, True)
539
540 def test_vrouter_ipv6_with_6_routes_3_peers(self):
541 res = self.__vrouter_network_verify(6, peers = 3)
542 assert_equal(res, True)
543
544 def test_vrouter_ipv6_with_50_routes(self):
545 res = self.__vrouter_network_verify(50, peers = 1)
546 assert_equal(res, True)
547
548 def test_vrouter_ipv6_with_50_routes_5_peers(self):
549 res = self.__vrouter_network_verify(50, peers = 5)
550 assert_equal(res, True)
551
552 def test_vrouter_ipv6_with_100_routes(self):
553 res = self.__vrouter_network_verify(100, peers = 1)
554 assert_equal(res, True)
555
556 def test_vrouter_ipv6_with_100_routes_10_peers(self):
557 res = self.__vrouter_network_verify(100, peers = 10)
558 assert_equal(res, True)
559
560 def test_vrouter_ipv6_with_300_routes(self):
561 res = self.__vrouter_network_verify(300, peers = 1)
562 assert_equal(res, True)
563
564 def test_vrouter_ipv6_with_1k_routes(self):
565 res = self.__vrouter_network_verify(1000, peers = 1)
566 assert_equal(res, True)
567
568 def test_vrouter_ipv6_with_9k_routes(self):
569 res = self.__vrouter_network_verify(9000, peers = 1)
570 assert_equal(res, True)
571
572 @nottest # Need to implement logic for generating more than 10000 routes
573 def test_vrouter_ipv6_with_100000_routes(self):
574 res = self.__vrouter_network_verify(100000, peers = 1)
575 assert_equal(res, True)
576
577 @nottest # Need to implement logic for generating more than 10000 routes
578 def test_vrouter_ipv6_with_1000000_routes(self):
579 res = self.__vrouter_network_verify(1000000, peers = 1)
580 assert_equal(res, True)
581
582 def test_vrouter_ipv6_with_route_update(self):
583 res = self.__vrouter_network_verify(5, peers = 2, positive_test = True)
584 assert_equal(res, True)
585 peer_info = [('2001:0:0:0:0:0:72:1', '00:00:00:00:01:01'), ('2001:0:0:0:0:0:73:1', '00:00:00:00:02:01')]
586 res = self.__vrouter_network_verify(5, peers = 2, positive_test = True,
587 start_peer_address = peer_info, route_update = True)
588 assert_equal(res, True)
589
590 def test_vrouter_ipv6_with_64bit_mask_route_update(self):
591 router_address = '3001:0:0:0:0:0:56:0/64'
592 res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_network = router_address)
593 assert_equal(res, True)
594
595 def test_vrouter_ipv6_with_32bit_route_update(self):
596 router_address = '3112:90c4:836a:7e56:0:0:06:0/32'
597 res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_network = router_address)
598 assert_equal(res, True)
599
600 def test_vrouter_ipv6_with_16bit_route_update(self):
601 router_address = '9961:9474:0:8472:f30a:0:06:0/16'
602 res = self.__vrouter_network_verify(1, peers = 1, positive_test = True,start_network = router_address)
603 assert_equal(res, True)
604
605 def test_vrouter_ipv6_with_48bit_route_update(self):
606 router_address = 'c34a:9737:14cd:8730:0:0:06:0/48'
607 res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_network = router_address)
608 assert_equal(res, True)
609
610 def test_vrouter_ipv6_with_classless_route_update(self):
611 router_address = '3001:430d:76cb:f56e:873:0:677:0/67'
612 res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_network = router_address)
613 assert_equal(res, True)
614
615 def test_vrouter_ipv6_with_classless_duplicate_route_update(self):
616 router_address = '3001:8730:732:723:0:0:677:0/116'
617 res = self.__vrouter_network_verify(5, peers = 1, positive_test = True, start_network = router_address)
618 assert_equal(res, True)
619
620 def test_vrouter_ipv6_with_invalid_peers(self):
621 peer_info = [('FE80:0:0:0:C800:27FF:10:8', '00:00:00:00:01:01'), ('FE80:0:0:0:C800:27FF:11:8', '00:00:00:00:02:01')]
622 res = self.__vrouter_network_verify(5, peers = 2, positive_test = True,
623 start_peer_address = peer_info, specific_peer=True,invalid_peers= True)
624 assert_equal(res, True)
625
626 @nottest
627 def test_vrouter_with_traffic_sent_between_peers_connected_to_onos(self):
628 res = self.__vrouter_network_verify(5, peers = 2, positive_test = True, traffic_running_between_peers = True)
629 assert_equal(res, True)
630
631 @nottest
632 def test_vrouter_with_routes_time_expire(self):
633 res = self.__vrouter_network_verify(5, peers = 2, positive_test = True, time_expire = True)
634 assert_equal(res, True)
635
636 def test_vrouter_ipv6_with_unreachable_route(self):
637 res = self.__vrouter_network_verify(5, peers = 2, positive_test = True, unreachable_route_traffic = True)
638 assert_equal(res, True)
639
640 @nottest
641 def test_vrouter_ipv6_with_enabling_disabling_vrouter_app(self):
642 res = self.__vrouter_network_verify(5, peers = 2, positive_test = True, deactivate_activate_vrouter = True)
643 assert_equal(res, True)
644
645 def test_vrouter_ipv6_with_adding_new_routes_in_routing_table(self):
646 res = self.__vrouter_network_verify(5, peers = 2, positive_test = True)
647 cmd = 'ipv6 route 4001:0:0:0:0:0:677:0/64 2001:0:0:0:0:0:10:1'
648 self.quagga_shell(cmd)
649 self.vrouter_traffic_verify()
650 self.network_list = [ '4001:0:0:0:0:0:677:0' ]
651 self.network_mask = 64
652 self.vrouter_traffic_verify()
653 assert_equal(res, True)
654
655 def test_vrouter_ipv6_with_adding_new_routes_in_quagga_routing_table_and_restart(self):
656 res = self.__vrouter_network_verify(5, peers = 2, positive_test = True)
657 cmd = 'ipv6 route 4001:0:0:0:0:0:677:0/64 2001:0:0:0:0:0:10:1'
658 self.quagga_shell(cmd)
659 self.vrouter_traffic_verify()
660 self.network_list = [ '4001:0:0:0:0:0:677:0' ]
661 self.network_mask = 64
662 self.vrouter_traffic_verify()
663 log.info('verifying vrouter traffic for added routes after Quagga restart with old config only retain')
664 #cord_test_quagga_restart()
665 self.start_quagga(networks=5)
666 self.vrouter_traffic_verify(positive_test = False)
667 assert_equal(res, True)
668
669 def test_vrouter_ipv6_with_removing_old_routes_in_routing_table(self):
670 res = self.__vrouter_network_verify(5, peers = 2, positive_test = True)
671 cmd = 'ipv6 route 4001:0:0:0:0:0:677:0/64 2001:0:0:0:0:0:10:1'
672 self.quagga_shell(cmd)
673 self.vrouter_traffic_verify()
674 old_network_list = self.network_list
675 old_network_mask = self.network_mask
676 self.network_list = [ '4001:0:0:0:0:0:677:0' ]
677 self.network_mask = 64
678 self.vrouter_traffic_verify()
679 assert_equal(res, True)
680 cmd = 'no ipv6 route 4001:0:0:0:0:0:677:0/64 2001:0:0:0:0:0:10:1'
681 self.quagga_shell(cmd)
682 time.sleep(5)
683 self.vrouter_traffic_verify(positive_test = False)
684 self.network_mask = old_network_mask
685 self.network_list = old_network_list
686 self.vrouter_traffic_verify(positive_test = True)
687
688 def test_vrouter_ipv6_modifying_nexthop_route_in_routing_table(self):
689 peer_info = [('2001:0:0:0:0:0:12:1', '00:00:00:00:01:01'), ('2001:0:0:0:0:0:13:1', '00:00:00:00:02:01')]
690 router_address = '3001:0:0:0:0:0:677:0/112'
691 res = self.__vrouter_network_verify(1, peers = 1, positive_test = True,
692 start_peer_address = peer_info, start_network = router_address)
693 cmd = 'no ipv6 route 3001:0:0:0:0:0:677:0/112 2001:0:0:0:0:0:18:1'
694 self.quagga_shell(cmd)
695 self.vrouter_traffic_verify(positive_test = True)
696 assert_equal(res, True)
697
698
699 def test_vrouter_ipv6_deleting_alternative_nexthop_in_routing_table(self):
700 peer_info = [('2001:0:0:0:0:0:12:1', '00:00:00:00:01:01'), ('2001:0:0:0:0:0:13:1', '00:00:00:00:02:01')]
701 router_address = '3001:0:0:0:0:0:677:0/112'
702 res = self.__vrouter_network_verify(1, peers = 2, positive_test = True,
703 start_peer_address = peer_info, start_network = router_address)
704 cmd = 'no ipv6 route 3001:0:0:0:0:0:677:0/112 2001:0:0:0:0:0:12:1'
705 self.quagga_shell(cmd)
706 time.sleep(5)
707 self.vrouter_traffic_verify(positive_test = False)
708 assert_equal(res, True)
709
710 def test_vrouter_ipv6_deleting_some_routes_in_routing_table(self):
711 peer_info = [('2001:0:0:0:0:0:12:1', '00:00:00:00:01:01'), ('2001:0:0:0:0:0:13:1', '00:00:00:00:02:01')]
712 router_address = '3001:0:0:0:0:0:677:0/112'
713 res = self.__vrouter_network_verify(10, peers = 2, positive_test = True,
714 start_peer_address = peer_info, start_network = router_address)
715 cmd = 'no ipv6 route 3001:0:0:0:0:0:677:0/112 2001:0:0:0:0:0:12:1'
716 self.quagga_shell(cmd)
717 cmd = 'no ipv6 route 3001:0:0:0:0:0:678:0/112 2001:0:0:0:0:0:13:1'
718 self.quagga_shell(cmd)
719 cmd = 'no ipv6 route 3001:0:0:0:0:0:679:0/112 2001:0:0:0:0:0:12:1'
720 self.quagga_shell(cmd)
721 self.vrouter_traffic_verify(positive_test = True)
722 assert_equal(res, True)
723
724 def test_vrouter_ipv6_deleting_some_routes_in_quagga_routing_table_and_restart(self):
725 peer_info = [('2001:0:0:0:0:0:12:1', '00:00:00:00:01:01'), ('2001:0:0:0:0:0:13:1', '00:00:00:00:02:01')]
726 router_address = '3001:0:0:0:0:0:677:0/112'
727 res = self.__vrouter_network_verify(10, peers = 2, positive_test = True,
728 start_peer_address = peer_info, start_network = router_address)
729 cmd = 'no ipv6 route 3001:0:0:0:0:0:677:0/112 2001:0:0:0:0:0:12:1'
730 self.quagga_shell(cmd)
731 cmd = 'no ipv6 route 3001:0:0:0:0:0:678:0/112 2001:0:0:0:0:0:13:1'
732 self.quagga_shell(cmd)
733 cmd = 'no ipv6 route 3001:0:0:0:0:0:679:0/112 2001:0:0:0:0:0:12:1'
734 self.quagga_shell(cmd)
735 self.network_list = [ '3001:0:0:0:0:0:677:0','3001:0:0:0:0:0:678:0','3001:0:0:0:0:0:679:0' ]
736 self.network_mask = 112
737 self.vrouter_traffic_verify(positive_test = False)
738 self.network_list = [ '3001:0:0:0:0:0:680:0','3001:0:0:0:0:0:681:0' ]
739 self.vrouter_traffic_verify(positive_test = True)
740 #cord_test_quagga_restart()
741 self.start_quagga(networks=10)
742 self.network_list = [ '3001:0:0:0:0:0:677:0','3001:0:0:0:0:0:681:0' ]
743 self.vrouter_traffic_verify(positive_test = True)
744 assert_equal(res, True)
745
746
747 def test_vrouter_ipv6_deleting_and_adding_routes_in_routing_table(self):
748 peer_info = [('2001:0:0:0:0:0:12:1', '00:00:00:00:01:01'), ('2001:0:0:0:0:0:13:1', '00:00:00:00:02:01')]
749 router_address = '3001:0:0:0:0:0:677:0/64'
750 res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_peer_address = peer_info, start_network = router_address)
751 cmd = 'no ipv6 route 3001:0:0:0:0:0:677:0/64 2001:0:0:0:0:0:12:1'
752 self.quagga_shell(cmd)
753 cmd = 'ipv6 route 3001:0:0:0:0:0:677:0/64 2001:0:0:0:0:0:12:1'
754 self.quagga_shell(cmd)
755 self.vrouter_traffic_verify(positive_test = True)
756 assert_equal(res, True)
757
758 def test_vrouter_ipv6_toggling_nexthop_interface(self):
759 peer_info = [('2001:0:0:0:0:0:12:1', '00:00:00:00:01:01'), ('2001:0:0:0:0:0:13:1', '00:00:00:00:02:01')]
760 router_address = '3001:0:0:0:0:0:677:0/64'
761 res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_peer_address = peer_info, start_network = router_address)
762 iface = self.port_map[1]
763 #toggle the interface to trigger host removal.
764 cmds = ('ifconfig {} down'.format(iface),
765 'sleep 2',
766 'ifconfig {} 0'.format(iface),)
767 for cmd in cmds:
768 os.system(cmd)
769 self.vrouter_traffic_verify(positive_test = False)
770 host = "2001:0:0:0:0:0:12:1"
771 cmd = 'ifconfig {0} {1} up'.format(iface, host)
772 os.system(cmd)
773 #wait for arp refresh
774 time.sleep(60)
775 self.vrouter_traffic_verify(positive_test = True)
776 assert_equal(res, True)