aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbhijit Sinha <abhijit.sinha@intel.com>2018-11-14 18:13:45 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-11-14 18:13:45 +0000
commit11bfaf23160da0f0391a2152dddb19b3a0bae766 (patch)
tree6afe77279120c6f8178f2cef090fa2e5e5ea863e
parentc48add14dfa5f78e6f6d82afa5e87fd1ef8c5ec0 (diff)
parent91539099916648e0384b4040e8e9b98ca936549d (diff)
Merge "Remove unused functions vpe"
-rw-r--r--yardstick/network_services/vnf_generic/vnf/vpe_vnf.py151
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py73
2 files changed, 0 insertions, 224 deletions
diff --git a/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py b/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py
index 642894e07..349ef7888 100644
--- a/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py
+++ b/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py
@@ -17,13 +17,10 @@ from __future__ import absolute_import
from __future__ import print_function
-import os
import logging
import re
import posixpath
-from six.moves import configparser, zip
-
from yardstick.common import utils
from yardstick.common.process import check_if_process_failed
from yardstick.network_services.helpers.samplevnf_helper import PortPairs
@@ -44,15 +41,6 @@ Pkts in:\\s(\\d+)\r\n\
class ConfigCreate(object):
- @staticmethod
- def vpe_tmq(config, index):
- tm_q = 'TM{0}'.format(index)
- config.add_section(tm_q)
- config.set(tm_q, 'burst_read', '24')
- config.set(tm_q, 'burst_write', '32')
- config.set(tm_q, 'cfg', '/tmp/full_tm_profile_10G.cfg')
- return config
-
def __init__(self, vnfd_helper, socket):
super(ConfigCreate, self).__init__()
self.sw_q = -1
@@ -65,141 +53,6 @@ class ConfigCreate(object):
self.socket = socket
self._dpdk_port_to_link_id_map = None
- @property
- def dpdk_port_to_link_id_map(self):
- # we need interface name -> DPDK port num (PMD ID) -> LINK ID
- # LINK ID -> PMD ID is governed by the port mask
- # LINK instances are created implicitly based on the PORT_MASK application startup
- # argument. LINK0 is the first port enabled in the PORT_MASK, port 1 is the next one,
- # etc. The LINK ID is different than the DPDK PMD-level NIC port ID, which is the actual
- # position in the bitmask mentioned above. For example, if bit 5 is the first bit set
- # in the bitmask, then LINK0 is having the PMD ID of 5. This mechanism creates a
- # contiguous LINK ID space and isolates the configuration file against changes in the
- # board PCIe slots where NICs are plugged in.
- if self._dpdk_port_to_link_id_map is None:
- self._dpdk_port_to_link_id_map = {}
- for link_id, port_name in enumerate(sorted(self.vnfd_helper.port_pairs.all_ports,
- key=self.vnfd_helper.port_num)):
- self._dpdk_port_to_link_id_map[port_name] = link_id
- return self._dpdk_port_to_link_id_map
-
- def vpe_initialize(self, config):
- config.add_section('EAL')
- config.set('EAL', 'log_level', '0')
-
- config.add_section('PIPELINE0')
- config.set('PIPELINE0', 'type', 'MASTER')
- config.set('PIPELINE0', 'core', 's%sC0' % self.socket)
-
- config.add_section('MEMPOOL0')
- config.set('MEMPOOL0', 'pool_size', '256K')
-
- config.add_section('MEMPOOL1')
- config.set('MEMPOOL1', 'pool_size', '2M')
- return config
-
- def vpe_rxq(self, config):
- for port in self.downlink_ports:
- new_section = 'RXQ{0}.0'.format(self.dpdk_port_to_link_id_map[port])
- config.add_section(new_section)
- config.set(new_section, 'mempool', 'MEMPOOL1')
-
- return config
-
- def get_sink_swq(self, parser, pipeline, k, index):
- sink = ""
- pktq = parser.get(pipeline, k)
- if "SINK" in pktq:
- self.sink_q += 1
- sink = " SINK{0}".format(self.sink_q)
- if "TM" in pktq:
- sink = " TM{0}".format(index)
- pktq = "SWQ{0}{1}".format(self.sw_q, sink)
- return pktq
-
- def vpe_upstream(self, vnf_cfg, index=0): # pragma: no cover
- # NOTE(ralonsoh): this function must be covered in UTs.
- parser = configparser.ConfigParser()
- parser.read(os.path.join(vnf_cfg, 'vpe_upstream'))
-
- for pipeline in parser.sections():
- for k, v in parser.items(pipeline):
- if k == "pktq_in":
- if "RXQ" in v:
- port = self.dpdk_port_to_link_id_map[self.uplink_ports[index]]
- value = "RXQ{0}.0".format(port)
- else:
- value = self.get_sink_swq(parser, pipeline, k, index)
-
- parser.set(pipeline, k, value)
-
- elif k == "pktq_out":
- if "TXQ" in v:
- port = self.dpdk_port_to_link_id_map[self.downlink_ports[index]]
- value = "TXQ{0}.0".format(port)
- else:
- self.sw_q += 1
- value = self.get_sink_swq(parser, pipeline, k, index)
-
- parser.set(pipeline, k, value)
-
- new_pipeline = 'PIPELINE{0}'.format(self.n_pipeline)
- if new_pipeline != pipeline:
- parser._sections[new_pipeline] = parser._sections[pipeline]
- parser._sections.pop(pipeline)
- self.n_pipeline += 1
- return parser
-
- def vpe_downstream(self, vnf_cfg, index): # pragma: no cover
- # NOTE(ralonsoh): this function must be covered in UTs.
- parser = configparser.ConfigParser()
- parser.read(os.path.join(vnf_cfg, 'vpe_downstream'))
- for pipeline in parser.sections():
- for k, v in parser.items(pipeline):
-
- if k == "pktq_in":
- port = self.dpdk_port_to_link_id_map[self.downlink_ports[index]]
- if "RXQ" not in v:
- value = self.get_sink_swq(parser, pipeline, k, index)
- elif "TM" in v:
- value = "RXQ{0}.0 TM{1}".format(port, index)
- else:
- value = "RXQ{0}.0".format(port)
-
- parser.set(pipeline, k, value)
-
- if k == "pktq_out":
- port = self.dpdk_port_to_link_id_map[self.uplink_ports[index]]
- if "TXQ" not in v:
- self.sw_q += 1
- value = self.get_sink_swq(parser, pipeline, k, index)
- elif "TM" in v:
- value = "TXQ{0}.0 TM{1}".format(port, index)
- else:
- value = "TXQ{0}.0".format(port)
-
- parser.set(pipeline, k, value)
-
- new_pipeline = 'PIPELINE{0}'.format(self.n_pipeline)
- if new_pipeline != pipeline:
- parser._sections[new_pipeline] = parser._sections[pipeline]
- parser._sections.pop(pipeline)
- self.n_pipeline += 1
- return parser
-
- def create_vpe_config(self, vnf_cfg):
- config = configparser.ConfigParser()
- vpe_cfg = os.path.join("/tmp/vpe_config")
- with open(vpe_cfg, 'w') as cfg_file:
- config = self.vpe_initialize(config)
- config = self.vpe_rxq(config)
- config.write(cfg_file)
- for index, _ in enumerate(self.uplink_ports):
- config = self.vpe_upstream(vnf_cfg, index)
- config.write(cfg_file)
- config = self.vpe_downstream(vnf_cfg, index)
- config = self.vpe_tmq(config, index)
- config.write(cfg_file)
def generate_vpe_script(self, interfaces):
rules = PipelineRules(pipeline_id=1)
@@ -232,10 +85,6 @@ class ConfigCreate(object):
return rules.get_string()
- def generate_tm_cfg(self, vnf_cfg):
- vnf_cfg = os.path.join(vnf_cfg, "full_tm_profile_10G.cfg")
- if os.path.exists(vnf_cfg):
- return open(vnf_cfg).read()
class VpeApproxSetupEnvHelper(DpdkVnfSetupEnvHelper):
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
index 7b937dfb5..8d49cb3f4 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
@@ -16,7 +16,6 @@ from multiprocessing import Process, Queue
import time
import mock
-from six.moves import configparser
import unittest
from yardstick.benchmark.contexts import base as ctx_base
@@ -147,48 +146,6 @@ class TestConfigCreate(unittest.TestCase):
self.assertEqual(config_create.downlink_ports, ['xe1'])
self.assertEqual(config_create.socket, 2)
- def test_dpdk_port_to_link_id(self):
- vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
- config_create = vpe_vnf.ConfigCreate(vnfd_helper, 2)
- self.assertEqual(config_create.dpdk_port_to_link_id_map, {'xe0': 0, 'xe1': 1})
-
- def test_vpe_initialize(self):
- vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
- config_create = vpe_vnf.ConfigCreate(vnfd_helper, 2)
- config = configparser.ConfigParser()
- config_create.vpe_initialize(config)
- self.assertEqual(config.get('EAL', 'log_level'), '0')
- self.assertEqual(config.get('PIPELINE0', 'type'), 'MASTER')
- self.assertEqual(config.get('PIPELINE0', 'core'), 's2C0')
- self.assertEqual(config.get('MEMPOOL0', 'pool_size'), '256K')
- self.assertEqual(config.get('MEMPOOL1', 'pool_size'), '2M')
-
- def test_vpe_rxq(self):
- vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
- config_create = vpe_vnf.ConfigCreate(vnfd_helper, 2)
- config = configparser.ConfigParser()
- config_create.downlink_ports = ['xe0']
- config_create.vpe_rxq(config)
- self.assertEqual(config.get('RXQ0.0', 'mempool'), 'MEMPOOL1')
-
- def test_get_sink_swq(self):
- vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
- config_create = vpe_vnf.ConfigCreate(vnfd_helper, 2)
- config = configparser.ConfigParser()
- config.add_section('PIPELINE0')
- config.set('PIPELINE0', 'key1', 'value1')
- config.set('PIPELINE0', 'key2', 'value2 SINK')
- config.set('PIPELINE0', 'key3', 'TM value3')
- config.set('PIPELINE0', 'key4', 'value4')
- config.set('PIPELINE0', 'key5', 'the SINK value5')
-
- self.assertEqual(config_create.get_sink_swq(config, 'PIPELINE0', 'key1', 5), 'SWQ-1')
- self.assertEqual(config_create.get_sink_swq(config, 'PIPELINE0', 'key2', 5), 'SWQ-1 SINK0')
- self.assertEqual(config_create.get_sink_swq(config, 'PIPELINE0', 'key3', 5), 'SWQ-1 TM5')
- config_create.sw_q += 1
- self.assertEqual(config_create.get_sink_swq(config, 'PIPELINE0', 'key4', 5), 'SWQ0')
- self.assertEqual(config_create.get_sink_swq(config, 'PIPELINE0', 'key5', 5), 'SWQ0 SINK1')
-
def test_generate_vpe_script(self):
vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
vpe_config_vnf = vpe_vnf.ConfigCreate(vnfd_helper, 2)
@@ -214,36 +171,6 @@ class TestConfigCreate(unittest.TestCase):
self.assertIsInstance(result, str)
self.assertNotEqual(result, '')
- def test_create_vpe_config(self):
- vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
- config_create = vpe_vnf.ConfigCreate(vnfd_helper, 23)
- config_create.uplink_ports = ['xe1']
- with mock.patch.object(config_create, 'vpe_upstream') as mock_up, \
- mock.patch.object(config_create, 'vpe_downstream') as \
- mock_down, \
- mock.patch.object(config_create, 'vpe_tmq') as mock_tmq, \
- mock.patch.object(config_create, 'vpe_initialize') as \
- mock_ini, \
- mock.patch.object(config_create, 'vpe_rxq') as mock_rxq:
- mock_ini_obj = mock.Mock()
- mock_rxq_obj = mock.Mock()
- mock_up_obj = mock.Mock()
- mock_down_obj = mock.Mock()
- mock_tmq_obj = mock.Mock()
- mock_ini.return_value = mock_ini_obj
- mock_rxq.return_value = mock_rxq_obj
- mock_up.return_value = mock_up_obj
- mock_down.return_value = mock_down_obj
- mock_tmq.return_value = mock_tmq_obj
- config_create.create_vpe_config('fake_config_file')
-
- mock_rxq.assert_called_once_with(mock_ini_obj)
- mock_up.assert_called_once_with('fake_config_file', 0)
- mock_down.assert_called_once_with('fake_config_file', 0)
- mock_tmq.assert_called_once_with(mock_down_obj, 0)
- mock_up_obj.write.assert_called_once()
- mock_tmq_obj.write.assert_called_once()
-
class TestVpeApproxVnf(unittest.TestCase):