Test: Multiple scenarios for verifying vRouter app
with Quagga.

Change-Id: I8d13c111329add1dd615925d1d765933b35e2bc9
diff --git a/src/test/vrouter/vrouterTest.py b/src/test/vrouter/vrouterTest.py
index 5666348..2d3097e 100644
--- a/src/test/vrouter/vrouterTest.py
+++ b/src/test/vrouter/vrouterTest.py
@@ -20,13 +20,22 @@
 from OltConfig import OltConfig
 from OnosFlowCtrl import OnosFlowCtrl, get_mac
 from onosclidriver import OnosCliDriver
+#from quaggaclidriver import QuaggaCliDriver
 from CordContainer import Container, Onos, Quagga
-from CordTestServer import cord_test_onos_restart, cord_test_quagga_restart, cord_test_quagga_stop
+from CordTestServer import cord_test_onos_restart, cord_test_quagga_restart, cord_test_quagga_stop, cord_test_quagga_shell
 from portmaps import g_subscriber_port_map
 import threading
 import time
 import os
 import json
+import pexpect
+
+#from cli import quagga
+#from quagga import *
+#from cli import requires
+#from cli import system
+#from generic import *
+
 log.setLevel('INFO')
 
 class vrouter_exchange(unittest.TestCase):
@@ -64,6 +73,10 @@
     MAX_PORTS = 100
     peer_list = [ ('192.168.10.1', '00:00:00:00:00:01'), ('192.168.11.1', '00:00:00:00:02:01'), ]
     network_list = []
+    network_mask = 24
+    default_routes_address = ('11.10.10.0/24',)
+    default_peer_address = peer_list
+    quagga_ip = os.getenv('QUAGGA_IP')
 
     @classmethod
     def setUpClass(cls):
@@ -72,7 +85,6 @@
         cls.port_map = cls.olt.olt_port_map()
         if not cls.port_map:
             cls.port_map = g_subscriber_port_map
-        #cls.vrouter_host_load(host = cls.GATEWAY)
         time.sleep(3)
 
     @classmethod
@@ -101,8 +113,10 @@
             assert_equal(status, True)
 
     @classmethod
-    def vrouter_config_get(cls, networks = 4, peers = 1):
-        vrouter_configs = cls.generate_vrouter_conf(networks = networks, peers = peers)
+    def vrouter_config_get(cls, networks = 4, peers = 1, peer_address = None,
+                           route_update = None, router_address = None):
+        vrouter_configs = cls.generate_vrouter_conf(networks = networks, peers = peers,
+                                                    peer_address = peer_address, router_address = router_address)
         return vrouter_configs
         ##ONOS router does not support dynamic reconfigurations
         #for config in vrouter_configs:
@@ -110,21 +124,27 @@
         #    time.sleep(5)
 
     @classmethod
-    def vrouter_host_load(cls):
+    def vrouter_host_load(cls, peer_address = None):
         index = 1
-        for host,_ in cls.peer_list:
+        peer_info = peer_address if peer_address is not None else cls.peer_list
+
+        for host,_ in peer_info:
             iface = cls.port_map[index]
             index += 1
-            config_cmds = ( 'ifconfig {0} {1}'.format(iface, host),
+            log.info('Assigning ip %s to interface %s' %(host, iface))
+            config_cmds = ( 'ifconfig {} 0'.format(iface),
+                            'ifconfig {0} {1}'.format(iface, host),
                             'arping -I {0} {1} -c 2'.format(iface, host),
                             )
             for cmd in config_cmds:
                 os.system(cmd)
 
     @classmethod
-    def vrouter_host_unload(cls):
+    def vrouter_host_unload(cls, peer_address = None):
         index = 1
-        for host,_ in cls.peer_list:
+        peer_info = peer_address if peer_address is not None else cls.peer_list
+
+        for host,_ in peer_info:
             iface = cls.port_map[index]
             index += 1
             config_cmds = ('ifconfig {} 0'.format(iface), )
@@ -144,9 +164,9 @@
         return cord_test_onos_restart(config = config)
 
     @classmethod
-    def start_quagga(cls, networks = 4):
+    def start_quagga(cls, networks = 4, peer_address = None, router_address = None):
         log.info('Restarting Quagga container with configuration for %d networks' %(networks))
-        config = cls.generate_conf(networks = networks)
+        config = cls.generate_conf(networks = networks, peer_address = peer_address, router_address = router_address)
         if networks <= 10000:
             boot_delay = 25
         else:
@@ -156,46 +176,16 @@
         cord_test_quagga_restart(config = config, boot_delay = boot_delay)
 
     @classmethod
-    def zgenerate_vrouter_conf(cls, networks = 4):
+    def generate_vrouter_conf(cls, networks = 4, peers = 1, peer_address = None, router_address = None):
         num = 0
-        start_network = ( 11 << 24) | ( 0 << 16) | ( 0 << 8) | 0
-        end_network =   ( 200 << 24 ) | ( 0 << 16)  | (0 << 8) | 0
-        ports_dict = { 'ports' : {} }
-        interface_list = []
-        for n in xrange(start_network, end_network):
-            if n & 255 == 0:
-                port_map = ports_dict['ports']
-                port = num + 1 if num < cls.MAX_PORTS - 1 else cls.MAX_PORTS - 1
-                device_port_key = '{0}/{1}'.format(cls.device_id, port)
-                try:
-                    interfaces = port_map[device_port_key]['interfaces']
-                except:
-                    port_map[device_port_key] = { 'interfaces' : [] }
-                    interfaces = port_map[device_port_key]['interfaces']
-
-                ips = '%d.%d.%d.2/24'%( (n >> 24) & 0xff, ( ( n >> 16) & 0xff ), ( (n >> 8 ) & 0xff ) )
-                if num < cls.MAX_PORTS - 1:
-                    interface_dict = { 'name' : 'b1-{}'.format(port), 'ips': [ips], 'mac' : '00:00:00:00:00:01' }
-                    interfaces.append(interface_dict)
-                    interface_list.append(interface_dict['name'])
-                else:
-                    interfaces[0]['ips'].append(ips)
-                num += 1
-                if num == networks:
-                    break
-        quagga_dict = { 'apps': { 'org.onosproject.router' : { 'router' : {} } } }
-        quagga_router_dict = quagga_dict['apps']['org.onosproject.router']['router']
-        quagga_router_dict['ospfEnabled'] = True
-        quagga_router_dict['interfaces'] = interface_list
-        quagga_router_dict['controlPlaneConnectPoint'] = '{0}/{1}'.format(cls.device_id,
-                                                                          networks + 1 if networks < cls.MAX_PORTS else cls.MAX_PORTS )
-        return (cls.vrouter_device_dict, ports_dict, quagga_dict)
-
-    @classmethod
-    def generate_vrouter_conf(cls, networks = 4, peers = 1):
-        num = 0
-        start_peer = ( 192 << 24) | ( 168 << 16)  |  (10 << 8) | 0
-        end_peer =   ( 200 << 24 ) | (168 << 16)  |  (10 << 8) | 0
+        if peer_address is None:
+           start_peer = ( 192 << 24) | ( 168 << 16)  |  (10 << 8) | 0
+           end_peer =   ( 200 << 24 ) | (168 << 16)  |  (10 << 8) | 0
+        else:
+           ip = peer_address[0][0]
+           start_ip = ip.split('.')
+           start_peer = ( int(start_ip[0]) << 24) | ( int(start_ip[1]) << 16)  |  ( int(start_ip[2]) << 8) | 0
+           end_peer =   ((int(start_ip[0]) + 8) << 24 ) | (int(start_ip[1]) << 16)  |  (int(start_ip[2]) << 8) | 0
         local_network = end_peer + 1
         ports_dict = { 'ports' : {} }
         interface_list = []
@@ -241,23 +231,33 @@
         return (cls.vrouter_device_dict, ports_dict, quagga_dict)
 
     @classmethod
-    def generate_conf(cls, networks = 4):
+    def generate_conf(cls, networks = 4, peer_address = None, router_address = None):
         num = 0
-        start_network = ( 11 << 24) | ( 10 << 16) | ( 10 << 8) | 0
-        end_network =   ( 172 << 24 ) | ( 0 << 16)  | (0 << 8) | 0
+        if router_address is None:
+            start_network = ( 11 << 24) | ( 10 << 16) | ( 10 << 8) | 0
+            end_network =   ( 172 << 24 ) | ( 0 << 16)  | (0 << 8) | 0
+            network_mask = 24
+        else:
+           ip = router_address
+           start_ip = ip.split('.')
+           network_mask = int(start_ip[3].split('/')[1])
+           start_ip[3] = (start_ip[3].split('/'))[0]
+           start_network = (int(start_ip[0]) << 24) | ( int(start_ip[1]) << 16)  |  ( int(start_ip[2]) << 8) | 0
+           end_network = (172 << 24 ) | (int(start_ip[1]) << 16)  |  (int(start_ip[2]) << 8) | 0
         net_list = []
-        peer_list = cls.peer_list
+        peer_list = peer_address if peer_address is not None else cls.peer_list
         network_list = []
         for n in xrange(start_network, end_network, 256):
             net = '%d.%d.%d.0'%( (n >> 24) & 0xff, ( ( n >> 16) & 0xff ), ( (n >> 8 ) & 0xff ) )
             network_list.append(net)
             gateway = peer_list[num % len(peer_list)][0]
-            net_route = 'ip route {0}/24 {1}'.format(net, gateway)
+            net_route = 'ip route {0}/{1} {2}'.format(net, network_mask, gateway)
             net_list.append(net_route)
             num += 1
             if num == networks:
                 break
         cls.network_list = network_list
+        cls.network_mask = network_mask
         zebra_routes = '\n'.join(net_list)
         #log.info('Zebra routes: \n:%s\n' %cls.zebra_conf + zebra_routes)
         return cls.zebra_conf + zebra_routes
@@ -273,13 +273,14 @@
         time.sleep(3)
 
     @classmethod
-    def vrouter_configure(cls, networks = 4, peers = 1):
-        ##Deactivate vrouter
-        vrouter_configs = cls.vrouter_config_get(networks = networks, peers = peers)
+    def vrouter_configure(cls, networks = 4, peers = 1, peer_address = None,
+                          route_update = None, router_address = None, time_expire = None, adding_new_routes = None):
+        vrouter_configs = cls.vrouter_config_get(networks = networks, peers = peers,
+                                                 peer_address = peer_address, route_update = route_update)
         cls.start_onos(network_cfg = vrouter_configs)
         cls.vrouter_host_load()
         ##Start quagga
-        cls.start_quagga(networks = networks)
+        cls.start_quagga(networks = networks, peer_address = peer_address, router_address = router_address)
         return vrouter_configs
 
     def vrouter_port_send_recv(self, ingress, egress, dst_mac, dst_ip, positive_test = True):
@@ -310,18 +311,27 @@
         t.join()
         assert_equal(self.success, True)
 
-    def vrouter_traffic_verify(self, positive_test = True):
-        peers = len(self.peer_list)
+    def vrouter_traffic_verify(self, positive_test = True, peer_address = None):
+        if peer_address is None:
+            peers = len(self.peer_list)
+            peer_list = self.peer_list
+        else:
+            peers = len(peer_address)
+            peer_list = peer_address
         egress = peers + 1
         num = 0
         num_hosts = 5 if positive_test else 1
+        src_mac = '00:00:00:00:00:02'
+        src_ip = '1.1.1.1'
+        if self.network_mask != 24:
+            peers = 1
         for network in self.network_list:
             num_ips = num_hosts
             octets = network.split('.')
             for i in xrange(num_ips):
                 octets[-1] = str(int(octets[-1]) + 1)
                 dst_ip = '.'.join(octets)
-                dst_mac = self.peer_list[ num % peers ] [1]
+                dst_mac = peer_list[ num % peers ] [1]
                 port = (num % peers)
                 ingress = port + 1
                 #Since peers are on the same network
@@ -329,8 +339,17 @@
                 self.vrouter_port_send_recv(ingress, egress, dst_mac, dst_ip, positive_test = positive_test)
             num += 1
 
-    def __vrouter_network_verify(self, networks, peers = 1, positive_test = True):
-        _, ports_map, egress_map = self.vrouter_configure(networks = networks, peers = peers)
+    def __vrouter_network_verify(self, networks, peers = 1, positive_test = True,
+                                 start_network = None, start_peer_address = None, route_update = None,
+                                 invalid_peers = None, time_expire = None, unreachable_route_traffic = None,
+                                 deactivate_activate_vrouter = None, adding_new_routes = None):
+
+        _, ports_map, egress_map = self.vrouter_configure(networks = networks, peers = peers,
+                                                          peer_address = start_peer_address,
+                                                          route_update = route_update,
+                                                          router_address = start_network,
+                                                          time_expire = time_expire,
+                                                          adding_new_routes = adding_new_routes)
         self.cliEnter()
         ##Now verify
         hosts = json.loads(self.cli.hosts(jsonFormat = True))
@@ -339,14 +358,41 @@
         if networks <= 10000:
             routes = json.loads(self.cli.routes(jsonFormat = True))
             #log.info('Routes: %s' %routes)
-            assert_equal(len(routes['routes4']), networks)
+            if start_network is not None:
+               if start_network.split('/')[1] is 24:
+                  assert_equal(len(routes['routes4']), networks)
+               if start_network.split('/')[1] is not 24:
+                  assert_equal(len(routes['routes4']), 1)
+            if start_network is None and invalid_peers is None:
+               assert_equal(len(routes['routes4']), networks)
+            if invalid_peers is not None:
+               assert_equal(len(routes['routes4']), 0)
             flows = json.loads(self.cli.flows(jsonFormat = True))
             flows = filter(lambda f: f['flows'], flows)
             #log.info('Flows: %s' %flows)
             assert_not_equal(len(flows), 0)
-        self.vrouter_traffic_verify()
+        if invalid_peers is None:
+            self.vrouter_traffic_verify()
         if positive_test is False:
             self.__vrouter_network_verify_negative(networks, peers = peers)
+        if time_expire is True:
+            self.start_quagga(networks = networks, peer_address = start_peer_address, router_address = '12.10.10.1/24')
+            self.vrouter_traffic_verify()
+        if unreachable_route_traffic is True:
+            network_list_backup = self.network_list
+            self.network_list = ['2.2.2.2','3.3.3.3','4.4.4.4','5.5.5.5']
+            self.vrouter_traffic_verify(positive_test = False)
+            self.network_list = network_list_backup
+        if deactivate_activate_vrouter is True:
+            log.info('Deactivating vrouter app in ONOS controller for negative scenario')
+            self.vrouter_activate(deactivate = True)
+            #routes = json.loads(self.cli.routes(jsonFormat = False, cmd_exist = False))
+            #assert_equal(len(routes['routes4']), 'Command not found')
+            log.info('Activating vrouter app again in ONOS controller for negative scenario')
+            self.vrouter_activate(deactivate = False)
+            routes = json.loads(self.cli.routes(jsonFormat = True))
+            assert_equal(len(routes['routes4']), networks)
+            self.vrouter_traffic_verify()
         self.cliExit()
         self.vrouter_host_unload()
         return True
@@ -370,72 +416,218 @@
         self.vrouter_traffic_verify()
         log.info('OVS flows have been successfully reinstalled after Quagga was restarted')
 
-    def test_vrouter_1(self):
-        '''Test vrouter with 5 routes'''
+    def quagga_shell(self, cmd):
+        shell_cmds = ('vtysh', '"conf t"', '"{}"'.format(cmd))
+        quagga_cmd = ' -c '.join(shell_cmds)
+        return cord_test_quagga_shell(quagga_cmd)
+
+    def test_vrouter_with_5_routes(self):
         res = self.__vrouter_network_verify(5, peers = 1)
         assert_equal(res, True)
 
-    def test_vrouter_2(self):
-        '''Test vrouter with 5 routes with 2 peers'''
+    def test_vrouter_with_5_routes_2_peers(self):
         res = self.__vrouter_network_verify(5, peers = 2)
         assert_equal(res, True)
 
-    def test_vrouter_3(self):
-        '''Test vrouter with 6 routes with 3 peers'''
+    def test_vrouter_with_6_routes_3_peers(self):
         res = self.__vrouter_network_verify(6, peers = 3)
         assert_equal(res, True)
 
-    def test_vrouter_4(self):
-        '''Test vrouter with 50 routes'''
+    def test_vrouter_with_50_routes(self):
         res = self.__vrouter_network_verify(50, peers = 1)
         assert_equal(res, True)
 
-    def test_vrouter_5(self):
-        '''Test vrouter with 50 routes and 5 peers'''
+    def test_vrouter_with_50_routes_5_peers(self):
         res = self.__vrouter_network_verify(50, peers = 5)
         assert_equal(res, True)
 
-    def test_vrouter_6(self):
-        '''Test vrouter with 100 routes'''
+    def test_vrouter_with_100_routes(self):
         res = self.__vrouter_network_verify(100, peers = 1)
         assert_equal(res, True)
 
-    def test_vrouter_7(self):
-        '''Test vrouter with 100 routes and 10 peers'''
+    def test_vrouter_with_100_routes_10_peers(self):
         res = self.__vrouter_network_verify(100, peers = 10)
         assert_equal(res, True)
 
-    def test_vrouter_8(self):
-        '''Test vrouter with 300 routes'''
+    def test_vrouter_with_300_routes(self):
         res = self.__vrouter_network_verify(300, peers = 1)
         assert_equal(res, True)
 
-    def test_vrouter_9(self):
-        '''Test vrouter with 1000 routes'''
+    def test_vrouter_with_1000_routes(self):
         res = self.__vrouter_network_verify(1000, peers = 1)
         assert_equal(res, True)
 
-    def test_vrouter_10(self):
-        '''Test vrouter with 10000 routes'''
+    def test_vrouter_with_10000_routes(self):
         res = self.__vrouter_network_verify(10000, peers = 1)
         assert_equal(res, True)
 
     @nottest
-    def test_vrouter_11(self):
-        '''Test vrouter with 100000 routes'''
+    def test_vrouter_with_100000_routes(self):
         res = self.__vrouter_network_verify(100000, peers = 1)
         assert_equal(res, True)
 
     @nottest
-    def test_vrouter_12(self):
-        '''Test vrouter with 1000000 routes'''
+    def test_vrouter_with_1000000_routes(self):
         res = self.__vrouter_network_verify(1000000, peers = 1)
         assert_equal(res, True)
 
-    def test_vrouter_13(self):
-        '''Test vrouter by installing 5 routes, removing Quagga and re-starting Quagga back'''
+    def test_vrouter_with_5_routes_stopping_quagga(self):
         res = self.__vrouter_network_verify(5, peers = 1, positive_test = False)
 
-    def test_vrouter_14(self):
-        '''Test vrouter by installing 50 routes, removing Quagga and re-starting Quagga back'''
+    def test_vrouter_with_50_routes_stopping_quagga(self):
         res = self.__vrouter_network_verify(50, peers = 1, positive_test = False)
+
+    def test_vrouter_with_route_update(self):
+        res = self.__vrouter_network_verify(5, peers = 2, positive_test = True)
+        assert_equal(res, True)
+        peer_info = [('192.168.20.1', '00:00:00:00:01:01'), ('192.168.21.1', '00:00:00:00:02:01')]
+        res = self.__vrouter_network_verify(5, peers = 2, positive_test = True,
+                                            start_peer_address = peer_info, route_update = True)
+        assert_equal(res, True)
+
+    def test_vrouter_with_classA_route_update(self):
+        router_address = '11.10.10.0/8'
+        res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_network = router_address)
+        assert_equal(res, True)
+
+    def test_vrouter_with_classB_route_update(self):
+        router_address = '11.10.10.0/16'
+        res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_network = router_address)
+        assert_equal(res, True)
+
+    def test_vrouter_with_classless_route_update(self):
+        router_address = '11.10.10.0/12'
+        res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_network = router_address)
+        assert_equal(res, True)
+
+    def test_vrouter_with_classA_duplicate_route_update(self):
+        router_address = '11.10.10.0/8'
+        res = self.__vrouter_network_verify(5, peers = 1, positive_test = True, start_network = router_address)
+        assert_equal(res, True)
+
+    def test_vrouter_with_classB_duplicate_route_update(self):
+        router_address = '11.10.10.0/16'
+        res = self.__vrouter_network_verify(5, peers = 1, positive_test = True, start_network = router_address)
+        assert_equal(res, True)
+
+    def test_vrouter_with_classless_duplicate_route_update(self):
+        router_address = '11.10.10.0/12'
+        res = self.__vrouter_network_verify(5, peers = 1, positive_test = True, start_network = router_address)
+        assert_equal(res, True)
+
+    def test_vrouter_with_invalid_peers(self):
+        peer_info = [('239.255.255.250', '00:00:00:00:01:01'), ('239.255.255.240', '00:00:00:00:02:01')]
+        res = self.__vrouter_network_verify(5, peers = 2, positive_test = True,
+                                            start_peer_address = peer_info, invalid_peers= True)
+        assert_equal(res, True)
+
+    @nottest
+    def test_vrouter_with_traffic_sent_between_peers_connected_to_onos(self):
+        res = self.__vrouter_network_verify(5, peers = 2, positive_test = True, traffic_running_between_peers = True)
+        assert_equal(res, True)
+
+    @nottest
+    def test_vrouter_with_routes_time_expire(self):
+        res = self.__vrouter_network_verify(5, peers = 2, positive_test = True, time_expire = True)
+        assert_equal(res, True)
+
+    def test_vrouter_with_unreachable_route(self):
+        res = self.__vrouter_network_verify(5, peers = 2, positive_test = True, unreachable_route_traffic = True)
+        assert_equal(res, True)
+
+    @nottest
+    def test_vrouter_with_enabling_disabling_vrouter_app(self):
+        res = self.__vrouter_network_verify(5, peers = 2, positive_test = True, deactivate_activate_vrouter = True)
+        assert_equal(res, True)
+
+    def test_vrouter_with_adding_new_routes_in_routing_table(self):
+        res = self.__vrouter_network_verify(5, peers = 2, positive_test = True)
+        cmd = 'ip route 21.10.20.0/24 192.168.10.1'
+        self.quagga_shell(cmd)
+        self.vrouter_traffic_verify()
+        self.network_list = [ '21.10.20.0' ]
+        self.network_mask = 24
+        self.vrouter_traffic_verify()
+        assert_equal(res, True)
+
+    def test_vrouter_with_removing_old_routes_in_routing_table(self):
+        res = self.__vrouter_network_verify(5, peers = 2, positive_test = True)
+        cmd = 'ip route 21.10.20.0/24 192.168.10.1'
+        self.quagga_shell(cmd)
+        self.vrouter_traffic_verify()
+        old_network_list = self.network_list
+        old_network_mask = self.network_mask
+        self.network_list = [ '21.10.20.0' ]
+        self.network_mask = 24
+        self.vrouter_traffic_verify()
+        assert_equal(res, True)
+        cmd = 'no ip route 21.10.20.0/24 192.168.10.1'
+        self.quagga_shell(cmd)
+        self.vrouter_traffic_verify(positive_test = False)
+        self.network_mask = old_network_mask
+        self.network_list = old_network_list
+        self.vrouter_traffic_verify(positive_test = True)
+
+    def test_vrouter_modifying_nexthop_route_in_routing_table(self):
+        peer_info = [('192.168.10.1', '00:00:00:00:01:01'), ('192.168.11.1', '00:00:00:00:02:01')]
+        router_address = '11.10.10.0/24'
+        res = self.__vrouter_network_verify(1, peers = 1, positive_test = True,
+                                            start_peer_address = peer_info, start_network  = router_address)
+        cmd = 'ip route 11.10.10.0/24 192.168.20.1'
+        self.quagga_shell(cmd)
+        self.vrouter_traffic_verify(positive_test = True)
+        assert_equal(res, True)
+
+
+    def test_vrouter_deleting_alternative_nexthop_in_routing_table(self):
+        peer_info = [('192.168.10.1', '00:00:00:00:01:01'), ('192.168.11.1', '00:00:00:00:02:01')]
+        router_address = '11.10.10.0/24'
+        res = self.__vrouter_network_verify(1, peers = 2, positive_test = True,
+                                            start_peer_address = peer_info, start_network  = router_address)
+        cmd = 'no ip route 11.10.10.0/24 192.168.10.1'
+        self.quagga_shell(cmd)
+        self.vrouter_traffic_verify(positive_test = False)
+        assert_equal(res, True)
+
+    def test_vrouter_deleting_some_routes_in_routing_table(self):
+        peer_info = [('192.168.10.1', '00:00:00:00:01:01'), ('192.168.11.1', '00:00:00:00:02:01')]
+        router_address = '11.10.10.0/24'
+        res = self.__vrouter_network_verify(10, peers = 2, positive_test = True,
+                                            start_peer_address = peer_info, start_network  = router_address)
+        cmd = 'no ip route 11.10.10.0/24 192.168.10.1'
+        self.quagga_shell(cmd)
+        cmd = 'no ip route 11.10.13.0/24 192.168.11.1'
+        self.quagga_shell(cmd)
+        cmd = 'no ip route 11.10.14.0/24 192.168.10.1'
+        self.quagga_shell(cmd)
+        self.vrouter_traffic_verify(positive_test = True)
+        assert_equal(res, True)
+
+
+    def test_vrouter_deleting_and_adding_routes_in_routing_table(self):
+        peer_info = [('192.168.10.1', '00:00:00:00:01:01'), ('192.168.11.1', '00:00:00:00:02:01')]
+        router_address = '11.10.10.0/24'
+        res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_peer_address = peer_info, start_network  = router_address)
+        cmd = 'no ip route 11.10.10.0/24 192.168.10.1'
+        self.quagga_shell(cmd)
+        cmd = 'ip route 11.10.10.0/24 192.168.10.1'
+        self.quagga_shell(cmd)
+        self.vrouter_traffic_verify(positive_test = True)
+        assert_equal(res, True)
+
+    def test_vrouter_toggling_nexthop_interface(self):
+        peer_info = [('192.168.10.1', '00:00:00:00:01:01'), ('192.168.11.1', '00:00:00:00:02:01')]
+        router_address = '11.10.10.0/24'
+        res = self.__vrouter_network_verify(1, peers = 1, positive_test = True, start_peer_address = peer_info, start_network  = router_address)
+        #iface = cls.port_map[0]
+        iface = g_subscriber_port_map
+        cmd = 'ifconfig {} 0'.format(iface),
+        self.vrouter_traffic_verify(positive_test = False)
+        os.system(cmd)
+        host = "192.168.10.1"
+        cmd = 'ifconfig {0} {1}'.format(iface, host),
+        self.vrouter_traffic_verify(positive_test = True)
+        assert_equal(res, True)
+
+
+