Flip the default igmp app to multitable.
Change igmp test accordingly.
Avoid restarting ONOS by toggling the onos core driver/openflow apps.
Avoid configuring the igmp SSM table and port table config used only with the deprecated ciena-cordigmp (non-multi-table) app

Change-Id: Ifa7e1dbec61a4d768885c30fd36f6024798fe754
diff --git a/src/test/cordSubscriber/cordSubscriberTest.py b/src/test/cordSubscriber/cordSubscriberTest.py
index 453a505..b9d23ff 100644
--- a/src/test/cordSubscriber/cordSubscriberTest.py
+++ b/src/test/cordSubscriber/cordSubscriberTest.py
@@ -316,17 +316,9 @@
       def setUpClass(cls):
           '''Load the OLT config and activate relevant apps'''
           cls.update_apps_version()
-          dids = OnosCtrl.get_device_ids()
-          device_map = {}
-          for did in dids:
-                device_map[did] = { 'basic' : { 'driver' : 'pmc-olt' } }
-          network_cfg = {}
-          network_cfg = { 'devices' : device_map }
-          ## Restart ONOS with cpqd driver config for OVS
-          cls.start_onos(network_cfg = network_cfg)
-          cls.install_app_table()
           cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
           if cls.VOLTHA_ENABLED is False:
+                OnosCtrl.config_device_driver()
                 OnosCtrl.cord_olt_config(cls.olt)
           cls.port_map, cls.port_list = cls.olt.olt_port_map()
           cls.switches = cls.port_map['switches']
@@ -338,12 +330,12 @@
       @classmethod
       def tearDownClass(cls):
           '''Deactivate the olt apps and restart OVS back'''
-          apps = cls.olt_apps + ( cls.table_app,)
+          apps = cls.olt_apps
           for app in apps:
               onos_ctrl = OnosCtrl(app)
               onos_ctrl.deactivate()
-          cls.start_onos(network_cfg = {})
-          cls.install_app_igmp()
+          if cls.VOLTHA_ENABLED is False:
+                OnosCtrl.config_device_driver(driver = 'ovs')
 
       @classmethod
       def activate_apps(cls, apps, deactivate = False):
@@ -357,27 +349,6 @@
                   time.sleep(2)
 
       @classmethod
-      def install_app_table(cls):
-            ##Uninstall the existing app if any
-            OnosCtrl.uninstall_app(cls.table_app)
-            time.sleep(2)
-            log_test.info('Installing the multi table app %s for subscriber test' %(cls.table_app_file))
-            OnosCtrl.install_app(cls.table_app_file)
-            time.sleep(3)
-            #onos_ctrl = OnosCtrl(cls.vtn_app)
-            #onos_ctrl.deactivate()
-
-      @classmethod
-      def install_app_igmp(cls):
-            ##Uninstall the table app on class exit
-            OnosCtrl.uninstall_app(cls.table_app)
-            time.sleep(2)
-            log_test.info('Installing back the cord igmp app %s for subscriber test on exit' %(cls.app_file))
-            OnosCtrl.install_app(cls.app_file)
-            #onos_ctrl = OnosCtrl(cls.vtn_app)
-            #onos_ctrl.activate()
-
-      @classmethod
       def start_onos(cls, network_cfg = None):
             if cls.onos_restartable is False:
                   log_test.info('ONOS restart is disabled. Skipping ONOS restart')
@@ -1240,13 +1211,10 @@
           """Test subscriber join and receive for channel surfing"""
           self.num_subscribers = 5
           self.num_channels = 1
-          test_status = True
-          ##Run this test only if ONOS can be restarted as it incurs a network-cfg change
-          if self.onos_restartable is True:
-                test_status = self.subscriber_join_verify(num_subscribers = self.num_subscribers,
-                                                          num_channels = self.num_channels,
-                                                          port_list = self.generate_port_list(self.num_subscribers,
-                                                                                              self.num_channels))
+          test_status = self.subscriber_join_verify(num_subscribers = self.num_subscribers,
+                                                    num_channels = self.num_channels,
+                                                    port_list = self.generate_port_list(self.num_subscribers,
+                                                                                        self.num_channels))
           assert_equal(test_status, True)
 
       def test_cord_subscriber_join_jump(self):
diff --git a/src/test/igmp/igmpTest.py b/src/test/igmp/igmpTest.py
index bd99d5e..041a324 100644
--- a/src/test/igmp/igmpTest.py
+++ b/src/test/igmp/igmpTest.py
@@ -57,7 +57,6 @@
 class igmp_exchange(CordLogger):
 
     V_INF1 = 'veth0'
-    V_INF2 = 'veth1'
     MGROUP1 = '239.1.2.3'
     MGROUP2 = '239.2.2.3'
     MINVALIDGROUP1 = '255.255.255.255'
@@ -85,12 +84,15 @@
 
     @classmethod
     def setUpClass(cls):
-          cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
-          cls.port_map, _ = cls.olt.olt_port_map()
-          OnosCtrl.cord_olt_config(cls.olt)
+        cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
+        cls.port_map, _ = cls.olt.olt_port_map()
+        OnosCtrl.config_device_driver()
+        OnosCtrl.cord_olt_config(cls.olt)
+        time.sleep(2)
 
     @classmethod
-    def tearDownClass(cls): pass
+    def tearDownClass(cls):
+        OnosCtrl.config_device_driver(driver = 'ovs')
 
     def setUp(self):
         ''' Activate the igmp app'''
@@ -111,6 +113,7 @@
         time.sleep(2)
 
     def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False):
+          return
           ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } }
           ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate']
 	  if flag: #to maintain seperate group-source pair.
@@ -341,10 +344,12 @@
         igmpState = IGMPTestState(groups = groups, df = df)
         igmpStateRecv = IGMPTestState(groups = groups, df = df)
         igmpStateList = (igmpState, igmpStateRecv)
-        mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb, arg = igmpState)
+        tx_intf = self.port_map[self.PORT_TX_DEFAULT]
+        rx_intf = self.port_map[self.PORT_RX_DEFAULT]
+        mcastTraffic = McastTraffic(groups, iface= tx_intf, cb = self.send_mcast_cb, arg = igmpState)
         self.df = df
         self.mcastTraffic = mcastTraffic
-        self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
+        self.recv_socket = L3PacketSocket(iface = rx_intf, type = ETH_P_IP)
 
         def igmp_srp_task(stateList):
             igmpSendState, igmpRecvState = stateList
@@ -357,7 +362,7 @@
                 self.igmp_verify_join(stateList)
                 self.df.callback(0)
 
-        self.send_igmp_join(groups)
+        self.send_igmp_join(groups, iface = rx_intf)
         mcastTraffic.start()
         self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
         reactor.callLater(0, igmp_srp_task, igmpStateList)
@@ -365,23 +370,27 @@
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
     def test_igmp_leave_verify_traffic(self):
-        groups = [self.MGROUP1, self.MGROUP1]
-        leave_groups = ['224.0.1.10']
+        groups = [self.MGROUP1]
+        leave_groups = [self.MGROUP1]
 	self.onos_ssm_table_load(groups)
         df = defer.Deferred()
         igmpState = IGMPTestState(groups = groups, df = df)
         IGMPTestState(groups = groups, df = df)
-        mcastTraffic = McastTraffic(groups, iface= 'veth2', cb = self.send_mcast_cb,
+        tx_intf = self.port_map[self.PORT_TX_DEFAULT]
+        rx_intf = self.port_map[self.PORT_RX_DEFAULT]
+        mcastTraffic = McastTraffic(groups, iface= tx_intf, cb = self.send_mcast_cb,
                                     arg = igmpState)
         self.df = df
         self.mcastTraffic = mcastTraffic
-        self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
+        self.recv_socket = L3PacketSocket(iface = rx_intf, type = ETH_P_IP)
 
 	mcastTraffic.start()
-	self.send_igmp_join(groups)
-	self.send_igmp_leave(leave_groups, delay = 3)
+	self.send_igmp_join(groups, iface = rx_intf)
+        time.sleep(5)
+	self.send_igmp_leave(leave_groups, delay = 3, iface = rx_intf)
+        time.sleep(10)
 	join_state = IGMPTestState(groups = leave_groups)
-	status = self.igmp_not_recv_task(self.V_INF1,leave_groups, join_state)
+	status = self.igmp_not_recv_task(rx_intf, leave_groups, join_state)
 	log_test.info('verified status for igmp recv task %s'%status)
 	assert status == 1 , 'EXPECTED RESULT'
 	self.df.callback(0)
@@ -397,6 +406,7 @@
         self.iterations = 0
         self.num_groups = len(self.groups)
         self.MAX_TEST_ITERATIONS = 10
+        rx_intf = self.port_map[self.PORT_RX_DEFAULT]
 
         def igmp_srp_task(v):
               if self.iterations < self.MAX_TEST_ITERATIONS:
@@ -405,11 +415,11 @@
                           self.num_groups = random.randint(0, len(self.groups))
                           self.send_igmp_join(self.groups[:self.num_groups],
                                               src_list = self.src_list,
-                                              iface = 'veth0', delay = 0)
+                                              iface = rx_intf, delay = 0)
                     else:
                           self.send_igmp_leave(self.groups[:self.num_groups],
                                                src_list = self.src_list,
-                                               iface = 'veth0', delay = 0)
+                                               iface = rx_intf, delay = 0)
                     self.iterations += 1
                     v ^= 1
                     reactor.callLater(1.0 + 0.5*self.num_groups,
diff --git a/src/test/setup/cord-test.py b/src/test/setup/cord-test.py
index 73b2db5..2b89284 100755
--- a/src/test/setup/cord-test.py
+++ b/src/test/setup/cord-test.py
@@ -471,7 +471,7 @@
 onos_app_version = '3.0-SNAPSHOT'
 cord_tester_base = os.path.dirname(os.path.realpath(__file__))
 olt_config_default = os.path.join(cord_tester_base, 'olt_config.json')
-onos_app_file = os.path.abspath('{0}/../apps/ciena-cordigmp-'.format(cord_tester_base) + onos_app_version + '.oar')
+onos_app_file = os.path.abspath('{0}/../apps/ciena-cordigmp-multitable-'.format(cord_tester_base) + onos_app_version + '.oar')
 cord_test_server_address = '{}:{}'.format(CORD_TEST_HOST, CORD_TEST_PORT)
 identity_file_default = '/etc/maas/ansible/id_rsa'
 onos_log_level = 'INFO'
diff --git a/src/test/utils/Channels.py b/src/test/utils/Channels.py
index 80a086e..b9363f9 100644
--- a/src/test/utils/Channels.py
+++ b/src/test/utils/Channels.py
@@ -90,6 +90,7 @@
         time.sleep(2)
 
     def ssm_table_load(self, groups):
+          return
           ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } }
           ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate']
           for g in groups:
@@ -101,6 +102,7 @@
           self.onos_load_config(ssm_dict)
 
     def cord_port_table_load(self, cord_port_map):
+          return
           cord_group_dict = {'apps' : { 'org.ciena.cordigmp' : { 'cordIgmpTranslate' : [] } } }
           cord_group_xlate_list = cord_group_dict['apps']['org.ciena.cordigmp']['cordIgmpTranslate']
           for group, ports in cord_port_map.items():
diff --git a/src/test/utils/OnosCtrl.py b/src/test/utils/OnosCtrl.py
index 319125e..95e6368 100644
--- a/src/test/utils/OnosCtrl.py
+++ b/src/test/utils/OnosCtrl.py
@@ -256,3 +256,20 @@
            resp = requests.post(url, auth = cls.auth, data = json_data)
            return resp.ok, resp.status_code
         return False, 400
+
+    @classmethod
+    def config_device_driver(cls, controller = None, dids = None, driver = 'pmc-olt'):
+        driver_apps = ('org.onosproject.drivers', 'org.onosproject.openflow-base',)
+        if dids is None:
+            dids = cls.get_device_ids(controller = controller)
+        device_map = {}
+        for did in dids:
+            device_map[did] = { 'basic' : { 'driver' : driver } }
+        network_cfg = { 'devices' : device_map }
+        cls.config(network_cfg)
+        for driver in driver_apps:
+            cls(driver).deactivate()
+        time.sleep(2)
+        for driver in driver_apps:
+            cls(driver).activate()
+        time.sleep(5)