aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2017-11-28 16:39:15 +0000
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-01-04 01:25:47 +0000
commitf07dc0ecbad33522627df9cd9bc5b12f8cde0159 (patch)
treec5eb26257c3926fa9d2fe12b3fd1f5f69ceb873d
parent67bd29933789e7f31c52290fdd43835e54f89eaf (diff)
Remove tool provisioning in PROX helper
Tool provisioning in PROX setup environment helper is not needed [1]. The tool (PROX traffic injector) is already provided during the VNF building: ./ansible/nsb_setup.yml --> ./ansible/build_yardstick_image.yml --> ./ansible/ubuntu_server_cloudimg_modify_samplevnfs.yml --> ./ansible/roles/install_samplevnf [1]https://github.com/opnfv/yardstick/blob/master/yardstick/network_services/vnf_generic/vnf/prox_helpers.py#L641 JIRA: YARDSTICK-872 Change-Id: I0f925a7967a35a97901fbe5053793a791a7b1b01 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py120
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py18
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py17
-rw-r--r--yardstick/network_services/vnf_generic/vnf/prox_helpers.py54
4 files changed, 98 insertions, 111 deletions
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py b/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
index 84eb5dc0d..ed49c7000 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
@@ -15,13 +15,12 @@
# limitations under the License.
#
-from __future__ import absolute_import
-
+from itertools import repeat, chain
+import mock
import os
import socket
+import time
import unittest
-from itertools import repeat, chain
-import mock
from tests.unit import STL_MOCKS
from yardstick.network_services.vnf_generic.vnf.base import VnfdHelper
@@ -288,29 +287,32 @@ no data length value
"""
-@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
class TestProxSocketHelper(unittest.TestCase):
+
+ def setUp(self):
+ self.mock_time_sleep = mock.patch.object(time, 'sleep').start()
+
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.socket')
- def test___init__(self, mock_socket, mock_time):
+ def test___init__(self, mock_socket):
expected = mock_socket.socket()
prox = ProxSocketHelper()
result = prox._sock
self.assertEqual(result, expected)
- def test_connect(self, mock_time):
+ def test_connect(self):
mock_sock = mock.MagicMock()
prox = ProxSocketHelper(mock_sock)
prox.connect('10.20.30.40', 23456)
self.assertEqual(mock_sock.connect.call_count, 1)
- def test_get_sock(self, mock_time):
+ def test_get_sock(self):
mock_sock = mock.MagicMock()
prox = ProxSocketHelper(mock_sock)
result = prox.get_socket()
self.assertIs(result, mock_sock)
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.select')
- def test_get_data(self, mock_select, mock_time):
+ def test_get_data(self, mock_select):
mock_select.select.side_effect = [[1], [0]]
mock_socket = mock.MagicMock()
mock_recv = mock_socket.recv()
@@ -336,7 +338,7 @@ class TestProxSocketHelper(unittest.TestCase):
self.assertEqual(ret, 'jumped over')
self.assertEqual(len(prox._pkt_dumps), 3)
- def test__parse_socket_data_mixed_data(self, mock_time):
+ def test__parse_socket_data_mixed_data(self):
prox = ProxSocketHelper(mock.MagicMock())
ret = prox._parse_socket_data(PACKET_DUMP_NON_1, False)
self.assertEqual(ret, 'not_a_dump,1,2')
@@ -346,7 +348,7 @@ class TestProxSocketHelper(unittest.TestCase):
self.assertEqual(ret, 'not_a_dump,1,2')
self.assertEqual(len(prox._pkt_dumps), 1)
- def test__parse_socket_data_bad_data(self, mock_time):
+ def test__parse_socket_data_bad_data(self):
prox = ProxSocketHelper(mock.MagicMock())
with self.assertRaises(ValueError):
prox._parse_socket_data(PACKET_DUMP_BAD_1, False)
@@ -357,7 +359,7 @@ class TestProxSocketHelper(unittest.TestCase):
ret = prox._parse_socket_data(PACKET_DUMP_BAD_3, False)
self.assertEqual(ret, 'pktdump,3')
- def test__parse_socket_data_pkt_dump_only(self, mock_time):
+ def test__parse_socket_data_pkt_dump_only(self):
prox = ProxSocketHelper(mock.MagicMock())
ret = prox._parse_socket_data('', True)
self.assertFalse(ret)
@@ -368,20 +370,20 @@ class TestProxSocketHelper(unittest.TestCase):
ret = prox._parse_socket_data(PACKET_DUMP_2, True)
self.assertTrue(ret)
- def test_put_command(self, mock_time):
+ def test_put_command(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.put_command("data")
mock_socket.sendall.assert_called_once()
- def test_put_command_socket_error(self, mock_time):
+ def test_put_command_socket_error(self):
mock_socket = mock.MagicMock()
mock_socket.sendall.side_effect = OSError
prox = ProxSocketHelper(mock_socket)
prox.put_command("data")
mock_socket.sendall.assert_called_once()
- def test_get_packet_dump(self, mock_time):
+ def test_get_packet_dump(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox._pkt_dumps = []
@@ -391,67 +393,67 @@ class TestProxSocketHelper(unittest.TestCase):
self.assertEqual(prox.get_packet_dump(), 234)
self.assertEqual(prox._pkt_dumps, [])
- def test_stop_all_reset(self, mock_time):
+ def test_stop_all_reset(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.stop_all_reset()
mock_socket.sendall.assert_called()
- def test_stop_all(self, mock_time):
+ def test_stop_all(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.stop_all()
mock_socket.sendall.assert_called()
- def test_stop(self, mock_time):
+ def test_stop(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.stop([3, 4, 5], 16)
mock_socket.sendall.assert_called()
- def test_start_all(self, mock_time):
+ def test_start_all(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.start_all()
mock_socket.sendall.assert_called()
- def test_start(self, mock_time):
+ def test_start(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.start([3, 4, 5])
mock_socket.sendall.assert_called()
- def test_reset_stats(self, mock_time):
+ def test_reset_stats(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.reset_stats()
mock_socket.sendall.assert_called()
- def test_set_pkt_size(self, mock_time):
+ def test_set_pkt_size(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.set_pkt_size([3, 4, 5], 1024)
self.assertEqual(mock_socket.sendall.call_count, 3)
- def test_set_value(self, mock_time):
+ def test_set_value(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.set_value([3, 4, 5], 10, 20, 30)
self.assertEqual(mock_socket.sendall.call_count, 3)
- def test_reset_values(self, mock_time):
+ def test_reset_values(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.reset_values([3, 4, 5])
self.assertEqual(mock_socket.sendall.call_count, 3)
- def test_set_speed(self, mock_time):
+ def test_set_speed(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.set_speed([3, 4, 5], 1000)
self.assertEqual(mock_socket.sendall.call_count, 3)
- def test_slope_speed(self, mock_time):
+ def test_slope_speed(self):
core_data = [
{
'cores': [3, 4, 5],
@@ -473,13 +475,13 @@ class TestProxSocketHelper(unittest.TestCase):
prox.slope_speed(core_data, 5, 5)
self.assertEqual(set_speed.call_count, 10)
- def test_set_pps(self, mock_time):
+ def test_set_pps(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.set_pps([3, 4, 5], 1000, 512)
self.assertEqual(mock_socket.sendall.call_count, 3)
- def test_lat_stats(self, mock_time):
+ def test_lat_stats(self):
latency_output = [
'1, 2 , 3', # has white space
'4,5', # too short
@@ -510,7 +512,7 @@ class TestProxSocketHelper(unittest.TestCase):
self.assertEqual(mock_socket.sendall.call_count, 5)
self.assertEqual(result, expected)
- def test_get_all_tot_stats_error(self, mock_time):
+ def test_get_all_tot_stats_error(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.get_data = mock.MagicMock(return_value='3,4,5')
@@ -518,7 +520,7 @@ class TestProxSocketHelper(unittest.TestCase):
result = prox.get_all_tot_stats()
self.assertEqual(result, expected)
- def test_get_all_tot_stats(self, mock_time):
+ def test_get_all_tot_stats(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.get_data = mock.MagicMock(return_value='3,4,5,6')
@@ -526,7 +528,7 @@ class TestProxSocketHelper(unittest.TestCase):
result = prox.get_all_tot_stats()
self.assertEqual(result, expected)
- def test_hz(self, mock_time):
+ def test_hz(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.get_data = mock.MagicMock(return_value='3,4,5,6')
@@ -534,7 +536,7 @@ class TestProxSocketHelper(unittest.TestCase):
result = prox.hz()
self.assertEqual(result, expected)
- def test_core_stats(self, mock_time):
+ def test_core_stats(self):
core_stats = [
'3,4,5,6',
'7,8,9,10,NaN',
@@ -548,7 +550,7 @@ class TestProxSocketHelper(unittest.TestCase):
result = prox.core_stats([3, 4, 5], 16)
self.assertEqual(result, expected)
- def test_port_stats(self, mock_time):
+ def test_port_stats(self):
port_stats = [
','.join(str(n) for n in range(3, 15)),
','.join(str(n) for n in range(8, 32, 2)),
@@ -562,7 +564,7 @@ class TestProxSocketHelper(unittest.TestCase):
result = prox.port_stats([3, 4, 5])
self.assertEqual(result, expected)
- def test_measure_tot_stats(self, mock_time):
+ def test_measure_tot_stats(self):
start_tot = 3, 4, 5, 6
end_tot = 7, 9, 11, 13
delta_tot = 4, 5, 6, 7
@@ -584,7 +586,7 @@ class TestProxSocketHelper(unittest.TestCase):
pass
self.assertEqual(result, expected)
- def test_tot_stats(self, mock_time):
+ def test_tot_stats(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.get_data = mock.MagicMock(return_value='3,4,5,6')
@@ -592,7 +594,7 @@ class TestProxSocketHelper(unittest.TestCase):
result = prox.tot_stats()
self.assertEqual(result, expected)
- def test_tot_ierrors(self, mock_time):
+ def test_tot_ierrors(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.get_data = mock.MagicMock(return_value='3,4,5,6')
@@ -600,25 +602,25 @@ class TestProxSocketHelper(unittest.TestCase):
result = prox.tot_ierrors()
self.assertEqual(result, expected)
- def test_set_count(self, mock_time):
+ def test_set_count(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.set_count(432, [3, 4, 5])
self.assertEqual(mock_socket.sendall.call_count, 3)
- def test_dump_rx(self, mock_time):
+ def test_dump_rx(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.dump_rx(3, 5, 8)
self.assertEqual(mock_socket.sendall.call_count, 1)
- def test_quit(self, mock_time):
+ def test_quit(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.quit()
mock_socket.sendall.assert_called()
- def test_force_quit(self, mock_time):
+ def test_force_quit(self):
mock_socket = mock.MagicMock()
prox = ProxSocketHelper(mock_socket)
prox.force_quit()
@@ -1062,8 +1064,7 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
self.assertEqual(helper._prox_config_data, '44')
self.assertEqual(helper.remote_path, '55')
- @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.find_relative_file')
- def test_build_config(self, mock_find_path):
+ def test_build_config(self):
vnf1 = {
'prox_args': {'-f': ""},
'prox_path': '/opt/nsb_bin/prox',
@@ -1075,10 +1076,9 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
],
}
- mock_find_path.side_effect = ['1', '2']
- vnfd_helper = mock.MagicMock()
- ssh_helper = mock.MagicMock()
- ssh_helper.provision_tool.return_value = "/opt/nsb_bin/prox"
+ vnfd_helper = mock.Mock()
+ ssh_helper = mock.Mock()
+ ssh_helper.join_bin_path.return_value = '/opt/nsb_bin/prox'
scenario_helper = ScenarioHelper('vnf1')
scenario_helper.scenario_cfg = {
'task_path': 'a/b',
@@ -1087,12 +1087,16 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
},
}
- helper = ProxDpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- helper.remote_path = "/tmp/prox.cfg"
- expected = "sudo bash -c 'cd /opt/nsb_bin; /opt/nsb_bin/prox -o cli -f -f /tmp/prox.cfg '"
- with mock.patch.object(helper, "build_config_file") as mock_build_config:
+ expected = ("sudo bash -c 'cd /opt/nsb_bin; /opt/nsb_bin/prox -o cli "
+ "-f -f /tmp/prox.cfg '")
+
+ helper = ProxDpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper,
+ scenario_helper)
+ with mock.patch.object(helper, 'build_config_file') as mock_cfg_file:
+ helper.remote_path = '/tmp/prox.cfg'
prox_cmd = helper.build_config()
self.assertEqual(prox_cmd, expected)
+ mock_cfg_file.assert_called_once()
def test__insert_additional_file(self):
vnfd_helper = mock.MagicMock()
@@ -1256,16 +1260,6 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
result = helper.put_string_to_file('my long string', 'a/b')
self.assertEqual(result, expected)
- def test__build_pipeline_kwarags(self):
- vnfd_helper = mock.MagicMock()
- ssh_helper = mock.MagicMock()
- ssh_helper.provision_tool.return_value = "/tmp/nosuch"
- scenario_helper = mock.MagicMock()
-
- helper = ProxDpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- helper._build_pipeline_kwargs()
- self.assertEqual(helper.pipeline_kwargs, {'tool_path': '/tmp/nosuch', 'tool_dir': '/tmp'})
-
def test_copy_to_target(self):
vnfd_helper = mock.MagicMock()
vnfd_helper.interfaces = []
@@ -1416,7 +1410,7 @@ class TestProxResourceHelper(unittest.TestCase):
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.RETRY_INTERVAL', 0)
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.ProxSocketHelper')
- def test_sut(self, mock_socket_helper):
+ def test_sut(self, *args):
helper = ProxResourceHelper(mock.MagicMock())
self.assertIsNone(helper.client)
result = helper.sut
@@ -1466,7 +1460,7 @@ class TestProxResourceHelper(unittest.TestCase):
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.ProxSocketHelper')
- def test__connect(self, mock_socket_helper_type, mock_time):
+ def test__connect(self, mock_socket_helper_type, *args):
client = mock_socket_helper_type()
client.connect.side_effect = chain(repeat(socket.error, 5), [None])
@@ -1869,7 +1863,7 @@ class TestProxProfileHelper(unittest.TestCase):
self.assertIs(result, expected)
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
- def test_traffic_context(self, mock_time):
+ def test_traffic_context(self, *args):
setup_helper = mock.MagicMock()
setup_helper.vnfd_helper.interfaces = []
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
index ee6c67eb7..769279066 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
@@ -373,24 +373,6 @@ class TestProxApproxVnf(unittest.TestCase):
file_path = os.path.join(curr_path, filename)
return file_path
- @mock.patch('yardstick.benchmark.scenarios.networking.vnf_generic.open', create=True)
- @mock.patch('yardstick.network_services.helpers.iniparser.open', create=True)
- @mock.patch(SSH_HELPER)
- def test_run_prox(self, ssh, *args):
- mock_ssh(ssh)
-
- prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)
- prox_approx_vnf.scenario_helper.scenario_cfg = self.SCENARIO_CFG
- prox_approx_vnf.ssh_helper.provision_tool.return_value = '/tool_path12/tool_file34'
- prox_approx_vnf.setup_helper.remote_path = 'configs/file56.cfg'
-
- expected = "sudo bash -c 'cd /tool_path12; " \
- "/tool_path12/tool_file34 -o cli -t -f /tmp/l3-swap-2.cfg '"
-
- prox_approx_vnf._run()
- result = prox_approx_vnf.ssh_helper.run.call_args[0][0]
- self.assertEqual(result, expected)
-
@mock.patch(SSH_HELPER)
def bad_test_instantiate(self, *args):
prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
index b4306ce61..beb4f8f9f 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
@@ -1879,6 +1879,23 @@ class TestSampleVnf(unittest.TestCase):
self.assertRaises(y_exceptions.FunctionNotImplemented,
sample_vnf.scale)
+ def test__run(self):
+ test_cmd = 'test cmd'
+ run_kwargs = {'arg1': 'val1', 'arg2': 'val2'}
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ sample_vnf = SampleVNF('vnf1', vnfd)
+ sample_vnf.ssh_helper = mock.Mock()
+ sample_vnf.setup_helper = mock.Mock()
+ with mock.patch.object(sample_vnf, '_build_config',
+ return_value=test_cmd), \
+ mock.patch.object(sample_vnf, '_build_run_kwargs'):
+ sample_vnf.run_kwargs = run_kwargs
+ sample_vnf._run()
+ sample_vnf.ssh_helper.drop_connection.assert_called_once()
+ sample_vnf.ssh_helper.run.assert_called_once_with(test_cmd,
+ **run_kwargs)
+ sample_vnf.setup_helper.kill_vnf.assert_called_once()
+
class TestSampleVNFTrafficGen(unittest.TestCase):
diff --git a/yardstick/network_services/vnf_generic/vnf/prox_helpers.py b/yardstick/network_services/vnf_generic/vnf/prox_helpers.py
index ba066333d..285ead3b6 100644
--- a/yardstick/network_services/vnf_generic/vnf/prox_helpers.py
+++ b/yardstick/network_services/vnf_generic/vnf/prox_helpers.py
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import absolute_import
import array
import io
@@ -363,9 +362,9 @@ class ProxSocketHelper(object):
""" send data to the remote instance """
LOG.debug("Sending data to socket: [%s]", to_send.rstrip('\n'))
try:
- # TODO: sendall will block, we need a timeout
+ # NOTE: sendall will block, we need a timeout
self._sock.sendall(to_send.encode('utf-8'))
- except:
+ except: # pylint: disable=bare-except
pass
def get_packet_dump(self):
@@ -539,7 +538,7 @@ class ProxSocketHelper(object):
finally:
container['end_tot'] = end = self.get_all_tot_stats()
- container['delta'] = TotStatsTuple(end - start for start, end in zip(start, end))
+ container['delta'] = TotStatsTuple(e - s for s, e in zip(start, end))
def tot_stats(self):
"""Get the total statistics from the remote system"""
@@ -637,13 +636,6 @@ class ProxDpdkVnfSetupEnvHelper(DpdkVnfSetupEnvHelper):
raise KeyError(template.format(section_key, section_name))
return result
- def _build_pipeline_kwargs(self):
- tool_path = self.ssh_helper.provision_tool(tool_file=self.APP_NAME)
- self.pipeline_kwargs = {
- 'tool_path': tool_path,
- 'tool_dir': os.path.dirname(tool_path),
- }
-
def copy_to_target(self, config_file_path, prox_file):
remote_path = os.path.join("/tmp", prox_file)
self.ssh_helper.put(config_file_path, remote_path)
@@ -685,14 +677,13 @@ class ProxDpdkVnfSetupEnvHelper(DpdkVnfSetupEnvHelper):
if port_section_name != section_name:
continue
- for index, section_data in enumerate(section):
+ for section_data in section:
if section_data[0] == "mac":
section_data[1] = "hardware"
# search for dst mac
for _, section in sections:
- # for index, (item_key, item_val) in enumerate(section):
- for index, section_data in enumerate(section):
+ for section_data in section:
item_key, item_val = section_data
if item_val.startswith("@@dst_mac"):
tx_port_iter = re.finditer(r'\d+', item_val)
@@ -713,14 +704,14 @@ class ProxDpdkVnfSetupEnvHelper(DpdkVnfSetupEnvHelper):
return sections
for section_name, section in sections:
- for index, section_data in enumerate(section):
+ for section_data in section:
try:
if section_data[0].startswith("dofile"):
section_data[0] = self._insert_additional_file(section_data[0])
if section_data[1].startswith("dofile"):
section_data[1] = self._insert_additional_file(section_data[1])
- except:
+ except: # pylint: disable=bare-except
pass
return sections
@@ -753,9 +744,9 @@ class ProxDpdkVnfSetupEnvHelper(DpdkVnfSetupEnvHelper):
a custom method
"""
out = []
- for i, (section_name, section) in enumerate(prox_config):
+ for (section_name, section) in prox_config:
out.append("[{}]".format(section_name))
- for index, item in enumerate(section):
+ for item in section:
key, value = item
if key == "__name__":
continue
@@ -816,7 +807,7 @@ class ProxDpdkVnfSetupEnvHelper(DpdkVnfSetupEnvHelper):
self.lua = self.generate_prox_lua_file()
if len(self.lua) > 0:
self.upload_prox_lua("parameters.lua", self.lua)
- except:
+ except: # pylint: disable=bare-except
pass
prox_files = options.get('prox_files', [])
@@ -837,17 +828,20 @@ class ProxDpdkVnfSetupEnvHelper(DpdkVnfSetupEnvHelper):
self.build_config_file()
options = self.scenario_helper.options
-
prox_args = options['prox_args']
- LOG.info("Provision and start the %s", self.APP_NAME)
- self._build_pipeline_kwargs()
- self.pipeline_kwargs["args"] = " ".join(
- " ".join([k, v if v else ""]) for k, v in prox_args.items())
- self.pipeline_kwargs["cfg_file"] = self.remote_path
+ tool_path = self.ssh_helper.join_bin_path(self.APP_NAME)
+
+ self.pipeline_kwargs = {
+ 'tool_path': tool_path,
+ 'tool_dir': os.path.dirname(tool_path),
+ 'cfg_file': self.remote_path,
+ 'args': ' '.join(' '.join([str(k), str(v) if v else ''])
+ for k, v in prox_args.items())
+ }
- cmd_template = "sudo bash -c 'cd {tool_dir}; {tool_path} -o cli {args} -f {cfg_file} '"
- prox_cmd = cmd_template.format(**self.pipeline_kwargs)
- return prox_cmd
+ cmd_template = ("sudo bash -c 'cd {tool_dir}; {tool_path} -o cli "
+ "{args} -f {cfg_file} '")
+ return cmd_template.format(**self.pipeline_kwargs)
# this might be bad, sometimes we want regular ResourceHelper methods, like collect_kpi
@@ -1057,7 +1051,7 @@ class ProxDataHelper(object):
self.tsc_hz = float(self.sut.hz())
def line_rate_to_pps(self):
- # FIXME Don't hardcode 10Gb/s
+ # NOTE: to fix, don't hardcode 10Gb/s
return self.port_count * TEN_GIGABIT / BITS_PER_BYTE / (self.pkt_size + 20)
@@ -1658,7 +1652,7 @@ class ProxlwAFTRProfileHelper(ProxProfileHelper):
tun_ports = []
inet_ports = []
- re_port = re.compile('port (\d+)')
+ re_port = re.compile(r'port (\d+)')
for section_name, section in self.resource_helper.setup_helper.prox_config_data:
match = re_port.search(section_name)
if not match: