summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmma Foley <emma.l.foley@intel.com>2018-10-30 20:36:49 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-10-30 20:36:49 +0000
commit5c2e4acc1b33decbcd8b49c91edb49d4c2f46972 (patch)
treecc9f3c46f9558465b73c87a0b7780591226232f2
parentd61ecbcda464fa91516f4b3555b00ed7fe67da81 (diff)
parent9b968b08e7d52c57db3af4c323c820bb81d9ef34 (diff)
Merge "Add test library name update in DMF and mainflows" into stable/gambia
-rw-r--r--yardstick/network_services/vnf_generic/vnf/tg_landslide.py26
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_landslide.py38
2 files changed, 54 insertions, 10 deletions
diff --git a/yardstick/network_services/vnf_generic/vnf/tg_landslide.py b/yardstick/network_services/vnf_generic/vnf/tg_landslide.py
index 157568618..2fba89b22 100644
--- a/yardstick/network_services/vnf_generic/vnf/tg_landslide.py
+++ b/yardstick/network_services/vnf_generic/vnf/tg_landslide.py
@@ -129,6 +129,17 @@ class LandslideTrafficGen(sample_vnf.SampleVNFTrafficGen):
self.session_profile['reservePorts'] = 'true'
self.session_profile['reservations'] = [reservation]
+ def _update_session_library_name(self, test_session):
+ """Update DMF library name in session profile"""
+ for _ts_group in test_session['tsGroups']:
+ for _tc in _ts_group['testCases']:
+ try:
+ for _mainflow in _tc['parameters']['Dmf']['mainflows']:
+ _mainflow['library'] = \
+ self.vnfd_helper.mgmt_interface['user']
+ except KeyError:
+ pass
+
@staticmethod
def _update_session_tc_params(tc_options, testcase):
for _param_key in tc_options:
@@ -206,6 +217,8 @@ class LandslideTrafficGen(sample_vnf.SampleVNFTrafficGen):
_testcase_idx].update(
self._update_session_tc_params(tc_options, _testcase))
+ self._update_session_library_name(self.session_profile)
+
class LandslideResourceHelper(sample_vnf.ClientResourceHelper):
"""Landslide TG helper class"""
@@ -459,11 +472,14 @@ class LandslideResourceHelper(sample_vnf.ClientResourceHelper):
self._terminated.value = 1
def create_dmf(self, dmf):
- if isinstance(dmf, list):
- for _dmf in dmf:
- self._tcl.create_dmf(_dmf)
- else:
- self._tcl.create_dmf(dmf)
+ if isinstance(dmf, dict):
+ dmf = [dmf]
+ for _dmf in dmf:
+ # Update DMF library name in traffic profile
+ _dmf['dmf'].update(
+ {'library': self.vnfd_helper.mgmt_interface['user']})
+ # Create DMF on Landslide server
+ self._tcl.create_dmf(_dmf)
def delete_dmf(self, dmf):
if isinstance(dmf, list):
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_landslide.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_landslide.py
index 15f7b36c7..1736d0f17 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_landslide.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_landslide.py
@@ -27,7 +27,7 @@ from yardstick.network_services import utils as net_serv_utils
from yardstick.network_services.traffic_profile import landslide_profile
from yardstick.network_services.vnf_generic.vnf import sample_vnf
from yardstick.network_services.vnf_generic.vnf import tg_landslide
-
+from yardstick.network_services.vnf_generic.vnf import base as vnf_base
NAME = "tg__0"
@@ -466,8 +466,10 @@ class TestLandslideTrafficGen(unittest.TestCase):
self.ls_tg.scenario_helper.scenario_cfg = self.SCENARIO_CFG
mock_traffic_profile = mock.Mock(
spec=landslide_profile.LandslideProfile)
- mock_traffic_profile.dmf_config = {'keywords': 'UDP',
- 'dataProtocol': 'udp'}
+ mock_traffic_profile.dmf_config = {
+ 'keywords': 'UDP',
+ 'dataProtocol': 'udp',
+ 'dmf': {'library': 'test', 'name': 'name'}}
mock_traffic_profile.params = self.TRAFFIC_PROFILE
self.ls_tg.resource_helper._user_id = self.TEST_USER_ID
mock_get_tests.return_value = [{'id': self.SUCCESS_RECORD_ID,
@@ -599,6 +601,28 @@ class TestLandslideTrafficGen(unittest.TestCase):
get_session_tc_param_value(_key, _tc.get('type'),
self.ls_tg.session_profile))
+ def test__update_session_library_name(self, *args):
+ _session = copy.deepcopy(SESSION_PROFILE)
+ _session['tsGroups'].pop(0)
+ self.ls_tg.vnfd_helper = mock.MagicMock()
+ self.ls_tg.vnfd_helper.mgmt_interface.__getitem__.side_effect = {
+ 'user': TAS_INFO['user']}
+ self.ls_tg._update_session_library_name(_session)
+ _dmf = _session['tsGroups'][0]['testCases'][0]['parameters']['Dmf']
+ # Expect DMF library name updated in Nodal test types
+ self.assertEqual(TAS_INFO['user'], _dmf['mainflows'][0]['library'])
+
+ def test__update_session_library_name_wrong_tc_type(self, *args):
+ _session = copy.deepcopy(SESSION_PROFILE)
+ _session['tsGroups'].pop(1)
+ self.ls_tg.vnfd_helper = mock.MagicMock()
+ self.ls_tg.vnfd_helper.mgmt_interface.__getitem__.side_effect = {
+ 'user': TAS_INFO['user']}
+ # Expect DMF library name not updated in Node test types
+ self.assertNotIn('Dmf',
+ _session['tsGroups'][0]['testCases'][0]['parameters'])
+ self.ls_tg._update_session_library_name(_session)
+
@mock.patch.object(common_utils, 'open_relative_file')
@mock.patch.object(yaml_loader, 'yaml_load')
@mock.patch.object(tg_landslide.LandslideTrafficGen,
@@ -987,11 +1011,15 @@ class TestLandslideResourceHelper(unittest.TestCase):
def test_create_dmf(self, *args):
self.res_helper._tcl = mock.Mock()
+ self.res_helper.vnfd_helper = mock.Mock(spec=vnf_base.VnfdHelper)
+ self.res_helper.vnfd_helper.mgmt_interface = {'user': TAS_INFO['user']}
self.assertIsNone(self.res_helper.create_dmf(DMF_CFG))
self.res_helper._tcl.create_dmf.assert_called_once_with(DMF_CFG)
def test_create_dmf_as_list(self, *args):
self.res_helper._tcl = mock.Mock()
+ self.res_helper.vnfd_helper = mock.Mock(spec=vnf_base.VnfdHelper)
+ self.res_helper.vnfd_helper.mgmt_interface = {'user': TAS_INFO['user']}
self.assertIsNone(self.res_helper.create_dmf([DMF_CFG]))
self.res_helper._tcl.create_dmf.assert_called_once_with(DMF_CFG)
@@ -1612,7 +1640,7 @@ class TestLandslideTclClient(unittest.TestCase):
self.mock_tcl_handler.execute.assert_has_calls([
mock.call('set dmf_ [ls::create Dmf]'),
mock.call(
- 'ls::get [ls::query LibraryInfo -systemLibraryName test] -Id'),
+ 'ls::get [ls::query LibraryInfo -systemLibraryName user] -Id'),
mock.call('ls::config $dmf_ -Library 2 -Name "Basic UDP"'),
mock.call('ls::config $dmf_ -dataProtocol "udp"'),
# mock.call(
@@ -1638,7 +1666,7 @@ class TestLandslideTclClient(unittest.TestCase):
self.mock_tcl_handler.execute.assert_has_calls([
mock.call('set dmf_ [ls::create Dmf]'),
mock.call(
- 'ls::get [ls::query LibraryInfo -systemLibraryName test] -Id'),
+ 'ls::get [ls::query LibraryInfo -systemLibraryName user] -Id'),
mock.call('ls::config $dmf_ -Library 2 -Name "Basic UDP"'),
mock.call('ls::config $dmf_ -dataProtocol "udp"'),
# mock.call(