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