VOL-498 XPON Test - failing
VOL-499 XPON dispatcher test failing
VOL-644 Rename local envoy images to voltha-envoy in test_dispatcher and text_voltha_xpon

Change-Id: Ie140e9d8b9042675892791db3b1b189d69fc073a
diff --git a/tests/itests/voltha/test_dispatcher.py b/tests/itests/voltha/test_dispatcher.py
index 38bf233..4da1310 100644
--- a/tests/itests/voltha/test_dispatcher.py
+++ b/tests/itests/voltha/test_dispatcher.py
@@ -57,7 +57,13 @@
     'ontani': {'type':'ont_anis',
                'config':'ontani_config'},
     'venet':  {'type':'v_enets',
-               'config':'v_enet_config'}
+               'config':'v_enet_config'},
+    'gemport':{'type':'gemports',
+               'config':'gemports_config'},
+    'tcont':  {'type':'tconts',
+               'config':'tconts_config'},
+    'tdp':    {'type':'traffic_descriptor_profiles',
+               'config':'traffic_descriptor_profiles'}
 }
 
 
@@ -281,59 +287,57 @@
         # A. Create xPON objects instance using REST
         # B. Ensuring that Channeltermination is present on specific instances
         # C. Ensuring that other xPON objects are present in all instances
-        #
-        # TEST COMMENTED OUT - SEE VOL-499
-        # for item in xpon_scenario:
-        #     for key,value in item.items():
-        #         _obj_action = [val for val in key.split('-')]
-        #         _type_config = obj_type_config[_obj_action[0]]
-        #         if _obj_action[1] == "mod":
-        #             continue
-        #         if _obj_action[0] == "cterm":
-        #             if _obj_action[1] == "add":
-        #                 #Ponsim OLT
-        #                 self._create_xpon_object_rest(_type_config,
-        #                                               value,
-        #                                               ponsim_olt.id)
-        #                 self._verify_xpon_object_on_device(
-        #                     _type_config,
-        #                     self.ponsim_voltha_stub_global,
-        #                     ponsim_olt.id)
-        #                 self._delete_xpon_object_rest(_type_config,
-        #                                               value,
-        #                                               ponsim_olt.id)
-        #                 #Simulated OLT
-        #                 self._create_xpon_object_rest(_type_config,
-        #                                               value,
-        #                                               simulated_olt.id)
-        #                 self._verify_xpon_object_on_device(
-        #                     _type_config,
-        #                     self.simulated_voltha_stub_global,
-        #                     simulated_olt.id)
-        #                 self._delete_xpon_object_rest(_type_config,
-        #                                               value,
-        #                                               simulated_olt.id)
-        #             elif _obj_action[1] == "del":
-        #                 continue
-        #         else:
-        #             if _obj_action[1] == "add":
-        #                 self._create_xpon_object_rest(_type_config, value)
-        #                 #Checking with Ponsim OLT
-        #                 self._verify_xpon_object_on_device(
-        #                     _type_config,
-        #                     self.ponsim_voltha_stub_global)
-        #                 #Checking with empty instance
-        #                 self._verify_xpon_object_on_device(
-        #                     _type_config,
-        #                     self.empty_voltha_stub_global)
-        #                 #Checking with Simulated OLT
-        #                 self._verify_xpon_object_on_device(
-        #                     _type_config,
-        #                     self.simulated_voltha_stub_global)
-        #             elif _obj_action[1] == "del":
-        #                 self._delete_xpon_object_rest(_type_config, value)
+        for item in xpon_scenario:
+            for key,value in item.items():
+                _obj_action = [val for val in key.split('-')]
+                _type_config = obj_type_config[_obj_action[0]]
+                if _obj_action[1] == "mod":
+                    continue
+                if _obj_action[0] == "cterm":
+                    if _obj_action[1] == "add":
+                        #Ponsim OLT
+                        self._create_xpon_object_rest(_type_config,
+                                                      value,
+                                                      ponsim_olt.id)
+                        self._verify_xpon_object_on_device(
+                            _type_config,
+                            self.ponsim_voltha_stub_global,
+                            ponsim_olt.id)
+                        self._delete_xpon_object_rest(_type_config,
+                                                      value,
+                                                      ponsim_olt.id)
+                        #Simulated OLT
+                        self._create_xpon_object_rest(_type_config,
+                                                      value,
+                                                      simulated_olt.id)
+                        self._verify_xpon_object_on_device(
+                            _type_config,
+                            self.simulated_voltha_stub_global,
+                            simulated_olt.id)
+                        self._delete_xpon_object_rest(_type_config,
+                                                      value,
+                                                      simulated_olt.id)
+                    elif _obj_action[1] == "del":
+                        continue
+                else:
+                    if _obj_action[1] == "add":
+                        self._create_xpon_object_rest(_type_config, value)
+                        #Checking with Ponsim OLT
+                        self._verify_xpon_object_on_device(
+                            _type_config,
+                            self.ponsim_voltha_stub_global)
+                        #Checking with empty instance
+                        self._verify_xpon_object_on_device(
+                            _type_config,
+                            self.empty_voltha_stub_global)
+                        #Checking with Simulated OLT
+                        self._verify_xpon_object_on_device(
+                            _type_config,
+                            self.simulated_voltha_stub_global)
+                    elif _obj_action[1] == "del":
+                        self._delete_xpon_object_rest(_type_config, value)
 
-        # TODO:  More tests to be added as new features are added
+        #TODO:  More tests to be added as new features are added
 
 
     def _get_grpc_address(self, voltha_instance):
@@ -370,7 +374,7 @@
 
     def set_rest_endpoint(self):
         self.rest_endpoint = get_endpoint_from_consul(LOCAL_CONSUL,
-                                                      'envoy-8443')
+                                                      'voltha-envoy-8443')
         self.base_url = 'https://' + self.rest_endpoint
 
     def set_kafka_endpoint(self):
@@ -824,6 +828,12 @@
             res = stub.GetAllOntaniConfig(Empty())
         elif obj_type["type"] == "v_enets":
             res = stub.GetAllVEnetConfig(Empty())
+        elif obj_type["type"] == "gemports":
+            res = stub.GetAllGemportsConfigData(Empty())
+        elif obj_type["type"] == "tconts":
+            res = stub.GetAllTcontsConfigData(Empty())
+        elif obj_type["type"] == "traffic_descriptor_profiles":
+            res = stub.GetAllTrafficDescriptorProfileData(Empty())
         return res
 
     def _create_xpon_object_rest(self, obj_type, value, device_id=None):
diff --git a/tests/itests/voltha/test_voltha_xpon.py b/tests/itests/voltha/test_voltha_xpon.py
index 74fb435..fc9c9d6 100644
--- a/tests/itests/voltha/test_voltha_xpon.py
+++ b/tests/itests/voltha/test_voltha_xpon.py
@@ -217,10 +217,10 @@
         'pb2': gemport.GemportsConfigData(),
         'rpc': {
             "aes_indicator": True,
-            "name": "GEMPORT 2",
+            "name": "GEMPORT 3",
             "traffic_class": 0,
             "itf_ref": "Enet UNI 1",
-            "tcont_ref": "TCont 2",
+            "tcont_ref": "TCont 3",
             "gemport_id": 0
             }
         }
@@ -231,7 +231,7 @@
 id = 3
 LOCAL_CONSUL = "localhost:8500"
 # Retrieve details of the REST entry point
-rest_endpoint = get_endpoint_from_consul(LOCAL_CONSUL, 'envoy-8443')
+rest_endpoint = get_endpoint_from_consul(LOCAL_CONSUL, 'voltha-envoy-8443')
 # Construct the base_url
 BASE_URL = 'https://' + rest_endpoint
 
@@ -344,9 +344,11 @@
         if isinstance(req, fb.ChannelgroupConfig):
             result['cg_index'] = 0
         elif isinstance(req, tcont.TcontsConfigData):
-            result['alloc_id'] = 0
+            if not dict1['alloc_id']:
+                result['alloc_id'] = 0
         elif isinstance(req, gemport.GemportsConfigData):
-            result['gemport_id'] = 0
+            if not dict1['gemport_id']:
+                result['gemport_id'] = 0
         return dict1 == result
 
 
@@ -379,7 +381,7 @@
         result, prev_len = self.add(type, config, req, name)
         self.assertEqual(result[config][prev_len]['name'], name)
         self.assertEqual(len(result[config]), prev_len+1)
-        self.assertEqual(self.search(req, result[config][0]), True)
+        self.assertEqual(self.search(req, result[config][prev_len]), True)
 
     def _mod(self, type, config, req, name):
         result = self.modify(type, req, name)