VOL-271: Support itests and utests for WT-385 xPON objects
itests support for the configuration of following WT-385 objects
- v_ont_ani
- ont_ani
- v_enet
Code optimization for the test cases
README.md is updated to reflect the itests
Change-Id: I0a93be85a50ad4c18d005b1402ffd7da9cc2f71a
diff --git a/tests/itests/README.md b/tests/itests/README.md
index 555df7b..644b4ee 100644
--- a/tests/itests/README.md
+++ b/tests/itests/README.md
@@ -157,10 +157,10 @@
cd /cord/incubator/voltha
. ./env.sh
nosetests -s tests/itests/voltha/test_dispatcher.py
-```
+```
-* **Voltha_Xpon**: This tests uses the ponsim OLT to verfiy addition, modification and deletion
-of channelgroups, channelpartition, channelpair, channeltermination for xpon
+* **Voltha_Xpon**: This test uses the ponsim-OLT to verfiy addition, modification and deletion
+of channelgroups, channelpartition, channelpair, channeltermination, VOntani, Ontani, VEnet for xpon
First start the Voltha ensemble:
```
diff --git a/tests/itests/voltha/test_voltha_xpon.py b/tests/itests/voltha/test_voltha_xpon.py
index 50b89c1..ebaed72 100644
--- a/tests/itests/voltha/test_voltha_xpon.py
+++ b/tests/itests/voltha/test_voltha_xpon.py
@@ -1,35 +1,49 @@
from tests.itests.voltha.rest_base import RestBase
-from google.protobuf.json_format import MessageToDict
+from google.protobuf.json_format import MessageToDict, ParseDict
import unittest
from voltha.protos import bbf_fiber_base_pb2 as fb
-from voltha.protos import bbf_fiber_channelgroup_body_pb2 as cg
-from voltha.protos import bbf_fiber_channelpair_body_pb2 as cpair
-from voltha.protos import bbf_fiber_channelpartition_body_pb2 as cpart
-from voltha.protos import bbf_fiber_channeltermination_body_pb2 as cterm
-from voltha.protos import ietf_interfaces_pb2 as itf
-from voltha.protos import bbf_fiber_types_pb2 as fbtypes
from voltha.protos.device_pb2 import Device
from common.utils.consulhelpers import get_endpoint_from_consul
+'''
+These tests uses the ponsim OLT to verfiy addition, modification and deletion
+of channelgroups, channelpartition, channelpair, channeltermination, vOntAni, OntAni
+and VEnets for xpon
+The prerequisite for this test are:
+ 1. voltha ensemble is running
+ docker-compose -f compose/docker-compose-system-test.yml up -d
+ 2. ponsim olt is running with PONSIM-OLT
+ sudo -s
+ . ./env.sh
+ ./ponsim/main.py -v
+'''
+
device_type = 'ponsim_olt'
host_and_port = '172.17.0.1:50060'
scenario = [
- {'cg-add': {"interface": {
- "enabled": True,
- "name": "Manhattan",
- "description": "Channel Group for Manhattan"
- },
- "data": {
- "polling_period": 100,
- "system_id": "000000",
- "raman_mitigation": "RAMAN_NONE"
- },
- "name": "Manhattan"
+ {'cg-add': {
+ 'pb2': fb.ChannelgroupConfig(),
+ 'rpc': {
+ "interface": {
+ "enabled": True,
+ "name": "Manhattan",
+ "description": "Channel Group for Manhattan.."
+ },
+ "data": {
+ "polling_period": 100,
+ "system_id": "000000",
+ "raman_mitigation": "RAMAN_NONE"
+ },
+ "name": "Manhattan"
}
- },
- {'cpart-add': {"interface": {
+ }
+ },
+ {'cpart-add': {
+ 'pb2': fb.ChannelpartitionConfig(),
+ 'rpc': {
+ "interface": {
"enabled": True,
"name": "WTC",
"description": "Channel Partition for World Trade Center in Manhattan"
@@ -44,8 +58,12 @@
},
"name": "WTC"
}
- },
- {'cpair-add': {"interface": {
+ }
+ },
+ {'cpair-add': {
+ 'pb2': fb.ChannelpairConfig(),
+ 'rpc': {
+ "interface": {
"enabled": True,
"name": "PON port",
"description": "Channel Pair for Freedom Tower in WTC"
@@ -60,8 +78,12 @@
},
"name": "PON port"
}
- },
- {'cterm-add': {"interface": {
+ }
+ },
+ {'cterm-add': {
+ 'pb2': fb.ChannelterminationConfig(),
+ 'rpc': {
+ "interface": {
"enabled": True,
"name": "PON port",
"description": "Channel Termination for Freedom Tower"
@@ -72,16 +94,84 @@
},
"name": "PON port"
}
- },
- {'cterm-del': {"name": "PON port"}},
- {'cpair-del': {"name": "PON port"}},
- {'cpart-del': {"name": "WTC"}},
- {'cg-del': {"name": "Manhattan"}}
+ }
+ },
+ {'vontani-add': {
+ 'pb2': fb.VOntaniConfig(),
+ 'rpc': {
+ "interface": {
+ "enabled": True,
+ "name": "ATT Silver User",
+ "description": "ATT Silver User in Freedom Tower"
+ },
+ "data": {
+ "preferred_chanpair": "PON port",
+ "expected_serial_number": "ALCL00000000",
+ "parent_ref": "WTC",
+ "onu_id": 1
+ },
+ "name": "ATT Silver User"
+ }
+ }
+ },
+ {'ontani-add': {
+ 'pb2': fb.OntaniConfig(),
+ 'rpc': {
+ "interface": {
+ "enabled": True,
+ "name": "ATT Silver User",
+ "description": "ATT Silver User in Freedom Tower"
+ },
+ "data": {
+ "upstream_fec_indicator": True,
+ "mgnt_gemport_aes_indicator": False
+ },
+ "name": "ATT Silver User"
+ }
+ }
+ },
+ {'venet-add': {
+ 'pb2': fb.VEnetConfig(),
+ 'rpc': {
+ "interface": {
+ "enabled": True,
+ "name": "ATT SU Enet UNI-1-1",
+ "description": "Ethernet port - 1"
+ },
+ "data": {
+ "v_ontani_ref": "ATT Silver User"
+ },
+ "name": "ATT SU Enet UNI-1-1"
+ }
+ }
+ },
+ {'cg-mod': {
+ 'pb2': fb.ChannelgroupConfig(),
+ 'rpc': {
+ "interface": {
+ "enabled": True,
+ "name": "Manhattan",
+ "description": "Channel Group for Manhattan"
+ },
+ "data": {
+ "polling_period": 100,
+ "system_id": "000000",
+ "raman_mitigation": "RAMAN_NONE"
+ },
+ "name": "Manhattan"
+ }
+ }
+ },
+ {'venet-del': { 'rpc': {"name": "ATT SU Enet UNI-1-1"}, 'pb2': fb.VEnetConfig()}},
+ {'ontani-del': { 'rpc': {"name": "ATT Silver User"}, 'pb2': fb.OntaniConfig()}},
+ {'vontani-del': { 'rpc': {"name": "ATT Silver User"}, 'pb2': fb.VOntaniConfig()}},
+ {'cterm-del': { 'rpc': {"name": "PON port"}, 'pb2': fb.ChannelterminationConfig()}},
+ {'cpair-del': { 'rpc': {"name": "PON port"}, 'pb2': fb.ChannelpairConfig()}},
+ {'cpart-del': { 'rpc': {"name": "WTC"}, 'pb2': fb.ChannelpartitionConfig()}},
+ {'cg-del': { 'rpc': {"name": "Manhattan"}, 'pb2': fb.ChannelgroupConfig()}}
]
-EMPTY_STRING=''
-DEFAULT_INT=0
+
id = 3 #for ordering the test cases
-ref = dict([])
LOCAL_CONSUL = "localhost:8500"
# Retrieve details of the REST entry point
rest_endpoint = get_endpoint_from_consul(LOCAL_CONSUL, 'chameleon-rest')
@@ -98,15 +188,6 @@
self.assertEqual(res['state'], 'HEALTHY')
class TestXPon(RestBase):
- """
- The prerequisite for this test are:
- 1. voltha ensemble is running
- docker-compose -f compose/docker-compose-system-test.yml up -d
- 2. ponsim olt is running with PONSIM-OLT
- sudo -s
- . ./env.sh
- ./ponsim/main.py -v
- """
def test_002_setup_device(self):
global device
device = self.add_device()
@@ -206,168 +287,23 @@
return True
return False
-#~~~~~~~~~~~~~~~~~~~~~~~~ Config Classes ~~~~~~~~~~~~~~~~~~~~~~~~~~
-class ChannelGroupConfig:
- #Class Variables
- name=EMPTY_STRING
- description=EMPTY_STRING
- type=EMPTY_STRING
- enabled=True
- link_up_down_trap_enable=itf.Interface.LinkUpDownTrapEnableType.Name(0)
- #channelgroup data
- system_id='0000000'
- polling_period=DEFAULT_INT
- raman_mitigation=fbtypes.RamanMitigationType.Name(0)
-
- def mk_config(self):
- #returns the default values if not intialized by the caller
- return fb.ChannelgroupConfig(
- name=self.name,
- interface=itf.Interface(
- name=self.name,
- description=self.description,
- type=self.type,
- enabled=self.enabled,
- link_up_down_trap_enable=self.link_up_down_trap_enable
- ),
- data=cg.ChannelgroupConfigData(
- polling_period=self.polling_period,
- system_id=self.system_id,
- raman_mitigation=self.raman_mitigation
- )
- )
-
-class ChannelPartitionConfig:
- #Class Variables
- name=EMPTY_STRING
- description=EMPTY_STRING
- type=EMPTY_STRING
- enabled=True
- link_up_down_trap_enable=itf.Interface.LinkUpDownTrapEnableType.Name(0)
- #channelpartition config data
- channelgroup_ref=EMPTY_STRING
- fec_downstream=True
- closest_ont_distance=DEFAULT_INT
- differential_fiber_distance=DEFAULT_INT
- authentication_method=fbtypes.AuthMethodType.Name(0)
- multicast_aes_indicator=True
-
- def mk_config(self):
- #returns the default values if not intialized by the caller
- return fb.ChannelpartitionConfig(
- name=self.name,
- interface=itf.Interface(
- name=self.name,
- description=self.description,
- type=self.type,
- enabled=self.enabled,
- link_up_down_trap_enable=self.link_up_down_trap_enable
- ),
- data=cpart.ChannelpartitionConfigData(
- channelgroup_ref=self.channelgroup_ref,
- fec_downstream=self.fec_downstream,
- closest_ont_distance=self.closest_ont_distance,
- differential_fiber_distance=self.differential_fiber_distance,
- authentication_method=self.authentication_method,
- multicast_aes_indicator=self.multicast_aes_indicator
- )
- )
-
-class ChannelPairConfig:
- #Class Variables
- name=EMPTY_STRING
- description=EMPTY_STRING
- type=EMPTY_STRING
- enabled=True
- link_up_down_trap_enable=itf.Interface.LinkUpDownTrapEnableType.Name(0)
- #channel pair config data
- channelgroup_ref=EMPTY_STRING
- channelpartition_ref=EMPTY_STRING
- channelpair_type=fbtypes.ChannelpairType.Name(0)
- channelpair_linerate=fbtypes.ChannelpairSpeedType.Name(0)
- gpon_ponid_interval=DEFAULT_INT
- gpon_ponid_odn_class=fbtypes.PonIdOdnClassType.Name(0)
-
- def mk_config(self):
- #returns the default values if not intialized by the caller
- return fb.ChannelpairConfig(
- name=self.name,
- interface=itf.Interface(
- name=self.name,
- description=self.description,
- type=self.type,
- enabled=self.enabled,
- link_up_down_trap_enable=self.link_up_down_trap_enable
- ),
- data=cpair.ChannelpairConfigData(
- channelgroup_ref=self.channelgroup_ref,
- channelpartition_ref=self.channelpartition_ref,
- channelpair_type=self.channelpair_type,
- channelpair_linerate=self.channelpair_linerate,
- gpon_ponid_interval=self.gpon_ponid_interval,
- gpon_ponid_odn_class=self.gpon_ponid_odn_class
- )
- )
-
-class ChannelTerminationConfig:
- #Class Variables
- name=EMPTY_STRING
- description=EMPTY_STRING
- type=EMPTY_STRING
- enabled=True
- link_up_down_trap_enable=itf.Interface.LinkUpDownTrapEnableType.Name(0)
- #channel termination config data
- channelpair_ref=EMPTY_STRING
- meant_for_type_b_primary_role=True
- ngpon2_twdm_admin_label=DEFAULT_INT
- ngpon2_ptp_admin_label=DEFAULT_INT
- xgs_ponid=DEFAULT_INT
- xgpon_ponid=DEFAULT_INT
- gpon_ponid=EMPTY_STRING
- pon_tag=EMPTY_STRING
- ber_calc_period=DEFAULT_INT
- location=EMPTY_STRING
- url_to_reach=EMPTY_STRING
-
- def mk_config(self):
- #returns the default values if not intialized by the caller
- return fb.ChannelterminationConfig(
- name=self.name,
- interface=itf.Interface(
- name=self.name,
- description=self.description,
- type=self.type,
- enabled=self.enabled,
- link_up_down_trap_enable=self.link_up_down_trap_enable
- ),
- data=cterm.ChannelterminationConfigData(
- channelpair_ref=self.channelpair_ref,
- meant_for_type_b_primary_role=self.meant_for_type_b_primary_role,
- ngpon2_twdm_admin_label=self.ngpon2_twdm_admin_label,
- ngpon2_ptp_admin_label=self.ngpon2_ptp_admin_label,
- xgs_ponid=self.xgs_ponid,
- xgpon_ponid=self.xgpon_ponid,
- gpon_ponid=self.gpon_ponid,
- pon_tag=self.pon_tag,
- ber_calc_period=self.ber_calc_period,
- location=self.location,
- url_to_reach=self.url_to_reach
- )
- )
-
#~~~~~~~~~~~~~~ Function to create test cases on the fly ~~~~~~~~~~~~~~~~
def create_dynamic_method(key, value):
obj_type_config = {
- 'cg': { 'type': 'channel_groups', 'config' : 'channelgroup_config', 'class' : ChannelGroupConfig() },
- 'cpart': { 'type': 'channel_partitions', 'config' : 'channelpartition_config', 'class' : ChannelPartitionConfig() },
- 'cpair': { 'type': 'channel_pairs', 'config' : 'channelpair_config', 'class' : ChannelPairConfig() },
- 'cterm': { 'type': 'channel_terminations', 'config' : 'channeltermination_config', 'class' : ChannelTerminationConfig() }
+ 'cg': { 'type': 'channel_groups', 'config' : 'channelgroup_config' },
+ 'cpart': { 'type': 'channel_partitions', 'config' : 'channelpartition_config' },
+ 'cpair': { 'type': 'channel_pairs', 'config' : 'channelpair_config' },
+ 'cterm': { 'type': 'channel_terminations', 'config' : 'channeltermination_config' },
+ 'vontani': { 'type': 'v_ont_anis', 'config': 'v_ontani_config' },
+ 'ontani': { 'type': 'ont_anis', 'config': 'ontani_config' },
+ 'venet': { 'type': 'v_enets', 'config': 'v_enet_config' }
}
def _add(self, type, config, req, name):
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]), True)
def _mod(self, type, config, req, name):
result = self.modify(type, req, name)
@@ -384,21 +320,16 @@
_mod(self, type_config['type'], type_config['config'], req, name)
elif obj_action == 'del':
_del(self, type_config['type'], type_config['config'], req, name)
+
+ def _config(self):
+ ParseDict(value['rpc'], value['pb2'])
+ return value['pb2']
def dynamic_test_method(self):
- for k,v in value.items(): #this should be a dictionary
- _obj_action = [val for val in key.split('-')]
- _type_config = obj_type_config[_obj_action[0]]
- name = '{}-{}'.format(_obj_action[0], value['name'])
- if(name not in ref):
- ref.update({name: _type_config['class']})
- if(isinstance(v, dict)):
- for nk, nv in v.items():
- setattr(ref[name], nk, nv)
- else:
- setattr(ref[name], k, v)
- req = ref[name].mk_config()
- _operate(self, _obj_action[1], _type_config, req, name.replace('{}-'.format(_obj_action[0]), ''))
+ _obj_action = [val for val in key.split('-')]
+ _type_config = obj_type_config[_obj_action[0]]
+ _req = _config(self)
+ _operate(self, _obj_action[1], _type_config, _req, value['rpc']['name'])
return dynamic_test_method
@@ -413,4 +344,4 @@
del dynamic_method
if __name__ == '__main__':
- unittest.main()
\ No newline at end of file
+ unittest.main()