summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--samples/vnf_samples/nsut/udp_replay/tc_baremetal_rfc2544_ipv4_1flow_64B_trex.yaml40
-rw-r--r--samples/vnf_samples/nsut/udp_replay/udp_replay-vnf-topology.yaml50
-rw-r--r--samples/vnf_samples/vnf_descriptors/udp_replay_vnf.yaml78
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py467
-rw-r--r--yardstick/network_services/vnf_generic/vnf/udp_replay.py97
5 files changed, 732 insertions, 0 deletions
diff --git a/samples/vnf_samples/nsut/udp_replay/tc_baremetal_rfc2544_ipv4_1flow_64B_trex.yaml b/samples/vnf_samples/nsut/udp_replay/tc_baremetal_rfc2544_ipv4_1flow_64B_trex.yaml
new file mode 100644
index 000000000..a2b73b6ec
--- /dev/null
+++ b/samples/vnf_samples/nsut/udp_replay/tc_baremetal_rfc2544_ipv4_1flow_64B_trex.yaml
@@ -0,0 +1,40 @@
+# Copyright (c) 2016-2017 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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.
+
+---
+schema: yardstick:task:0.1
+scenarios:
+- type: NSPerf
+ traffic_profile: ../../traffic_profiles/ipv4_throughput_cgnapt.yaml
+ topology: udp_replay-vnf-topology.yaml
+ nodes:
+ tg__1: trafficgen_1.yardstick
+ vnf__1: vnf.yardstick
+ options:
+ packetsize: 64
+ traffic_type: 4
+ rfc2544:
+ allowed_drop_rate: 0.0001 - 0.0001
+ runner:
+ type: Iteration
+ iterations: 10
+ interval: 35
+ traffic_options:
+ flow: ../../traffic_profiles/ipv4_1flow_Packets.yaml
+ imix: ../../traffic_profiles/imix_voice.yaml
+context:
+ type: Node
+ name: yardstick
+ nfvi_type: baremetal
+ file: /etc/yardstick/nodes/pod.yaml
diff --git a/samples/vnf_samples/nsut/udp_replay/udp_replay-vnf-topology.yaml b/samples/vnf_samples/nsut/udp_replay/udp_replay-vnf-topology.yaml
new file mode 100644
index 000000000..b13de7e90
--- /dev/null
+++ b/samples/vnf_samples/nsut/udp_replay/udp_replay-vnf-topology.yaml
@@ -0,0 +1,50 @@
+# Copyright (c) 2016-2017 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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.
+
+nsd:nsd-catalog:
+ nsd:
+ - id: 3tg-topology
+ name: 3tg-topology
+ short-name: 3tg-topology
+ description: 3tg-topology
+ constituent-vnfd:
+ - member-vnf-index: '1'
+ vnfd-id-ref: tg__1
+ VNF model: ../../vnf_descriptors/tg_rfc2544_tpl.yaml #VNF type
+ - member-vnf-index: '2'
+ vnfd-id-ref: vnf__1
+ VNF model: ../../vnf_descriptors/udp_replay_vnf.yaml #VNF type
+
+ vld:
+ - id: private_1
+ name: tg__1 to vnf__1 link 1
+ type: ELAN
+ vnfd-connection-point-ref:
+ - member-vnf-index-ref: '1'
+ vnfd-connection-point-ref: xe0
+ vnfd-id-ref: tg__1
+ - member-vnf-index-ref: '2'
+ vnfd-connection-point-ref: xe0
+ vnfd-id-ref: vnf__1
+
+ - id: public_1
+ name: vnf__1 to tg__1 link 2
+ type: ELAN
+ vnfd-connection-point-ref:
+ - member-vnf-index-ref: '2'
+ vnfd-connection-point-ref: xe1
+ vnfd-id-ref: vnf__1
+ - member-vnf-index-ref: '1'
+ vnfd-connection-point-ref: xe1
+ vnfd-id-ref: tg__1
diff --git a/samples/vnf_samples/vnf_descriptors/udp_replay_vnf.yaml b/samples/vnf_samples/vnf_descriptors/udp_replay_vnf.yaml
new file mode 100644
index 000000000..33c07a6f4
--- /dev/null
+++ b/samples/vnf_samples/vnf_descriptors/udp_replay_vnf.yaml
@@ -0,0 +1,78 @@
+#
+# Copyright 2016-2017 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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.
+#
+# This needs to be adjusted for every hardware setup
+#
+vnfd:vnfd-catalog:
+ vnfd:
+ - id: UdpReplayApproxVnf
+ name: UdpReplayApproxVnf
+ short-name: UdpReplayVnf
+ description: UdpReplayVnf approximation using DPDK
+ mgmt-interface:
+ vdu-id: udp_replayvnf-baremetal
+ {% if user is defined %}
+ user: '{{user}}' # Value filled by vnfdgen
+ {% endif %}
+ {% if password is defined %}
+ password: '{{password}}' # Value filled by vnfdgen
+ {% endif %}
+ {% if ip is defined %}
+ ip: '{{ip}}' # Value filled by vnfdgen
+ {% endif %}
+ {% if key_filename is defined %}
+ key_filename: '{{key_filename}}' # Value filled by vnfdgen
+ {% endif %}
+ connection-point:
+ - name: xe0
+ type: VPORT
+ - name: xe1
+ type: VPORT
+ vdu:
+ - id: udp_replayvnf-baremetal
+ name: udp_replayvnf-baremetal
+ description: UdpReplayVnf approximation using DPDK
+ external-interface:
+ - name: xe0
+ virtual-interface:
+ type: PCI-PASSTHROUGH
+ # Substitution variables MUST be quoted. Otherwise Python can misinterpet them.
+ vpci: '{{ interfaces.xe0.vpci }}' # Value filled by vnfdgen
+ dpdk_port_num: '{{ interfaces.xe0.dpdk_port_num }}' # Value filled by vnfdgen
+ local_ip: '{{ interfaces.xe0.local_ip }}' # Value filled by vnfdgen
+ dst_ip: '{{ interfaces.xe0.dst_ip }}' # Value filled by vnfdgen
+ local_mac: '{{ interfaces.xe0.local_mac }}' # Value filled by vnfdgen
+ netmask: '{{ interfaces.xe0.netmask }}' # Value filled by vnfdgen
+ dst_mac: '{{ interfaces.xe0.dst_mac }}' # Value filled by vnfdgen
+ bandwidth: 10 Gbps
+ vnfd-connection-point-ref: xe0
+ - name: xe1
+ virtual-interface:
+ type: PCI-PASSTHROUGH
+ # Substitution variables MUST be quoted. Otherwise Python can misinterpet them.
+ vpci: '{{ interfaces.xe1.vpci }}' # Value filled by vnfdgen
+ dpdk_port_num: '{{ interfaces.xe1.dpdk_port_num }}' # Value filled by vnfdgen
+ local_ip: '{{ interfaces.xe1.local_ip }}' # Value filled by vnfdgen
+ dst_ip: '{{ interfaces.xe1.dst_ip }}' # Value filled by vnfdgen
+ local_mac: '{{ interfaces.xe1.local_mac }}' # Value filled by vnfdgen
+ netmask: '{{ interfaces.xe1.netmask }}' # Value filled by vnfdgen
+ dst_mac: '{{ interfaces.xe1.dst_mac }}' # Value filled by vnfdgen
+ bandwidth: 10 Gbps
+ vnfd-connection-point-ref: xe1
+ benchmark:
+ kpi:
+ - packets_in
+ - packets_fwd
+ - packets_dropped
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py b/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py
new file mode 100644
index 000000000..08bf06b74
--- /dev/null
+++ b/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py
@@ -0,0 +1,467 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2016-2017 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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 unittest
+import mock
+import os
+
+
+STL_MOCKS = {
+ 'stl': mock.MagicMock(),
+ 'stl.trex_stl_lib': mock.MagicMock(),
+ 'stl.trex_stl_lib.base64': mock.MagicMock(),
+ 'stl.trex_stl_lib.binascii': mock.MagicMock(),
+ 'stl.trex_stl_lib.collections': mock.MagicMock(),
+ 'stl.trex_stl_lib.copy': mock.MagicMock(),
+ 'stl.trex_stl_lib.datetime': mock.MagicMock(),
+ 'stl.trex_stl_lib.functools': mock.MagicMock(),
+ 'stl.trex_stl_lib.imp': mock.MagicMock(),
+ 'stl.trex_stl_lib.inspect': mock.MagicMock(),
+ 'stl.trex_stl_lib.json': mock.MagicMock(),
+ 'stl.trex_stl_lib.linecache': mock.MagicMock(),
+ 'stl.trex_stl_lib.math': mock.MagicMock(),
+ 'stl.trex_stl_lib.os': mock.MagicMock(),
+ 'stl.trex_stl_lib.platform': mock.MagicMock(),
+ 'stl.trex_stl_lib.pprint': mock.MagicMock(),
+ 'stl.trex_stl_lib.random': mock.MagicMock(),
+ 'stl.trex_stl_lib.re': mock.MagicMock(),
+ 'stl.trex_stl_lib.scapy': mock.MagicMock(),
+ 'stl.trex_stl_lib.socket': mock.MagicMock(),
+ 'stl.trex_stl_lib.string': mock.MagicMock(),
+ 'stl.trex_stl_lib.struct': mock.MagicMock(),
+ 'stl.trex_stl_lib.sys': mock.MagicMock(),
+ 'stl.trex_stl_lib.threading': mock.MagicMock(),
+ 'stl.trex_stl_lib.time': mock.MagicMock(),
+ 'stl.trex_stl_lib.traceback': mock.MagicMock(),
+ 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(),
+ 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(),
+ 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(),
+ 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(),
+ 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(),
+ 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(),
+ 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(),
+ 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(),
+ 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(),
+ 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(),
+ 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(),
+ 'stl.trex_stl_lib.types': mock.MagicMock(),
+ 'stl.trex_stl_lib.utils': mock.MagicMock(),
+ 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(),
+ 'stl.trex_stl_lib.utils.collections': mock.MagicMock(),
+ 'stl.trex_stl_lib.utils.common': mock.MagicMock(),
+ 'stl.trex_stl_lib.utils.json': mock.MagicMock(),
+ 'stl.trex_stl_lib.utils.os': mock.MagicMock(),
+ 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(),
+ 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(),
+ 'stl.trex_stl_lib.utils.random': mock.MagicMock(),
+ 'stl.trex_stl_lib.utils.re': mock.MagicMock(),
+ 'stl.trex_stl_lib.utils.string': mock.MagicMock(),
+ 'stl.trex_stl_lib.utils.sys': mock.MagicMock(),
+ 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(),
+ 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(),
+ 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(),
+ 'stl.trex_stl_lib.warnings': mock.MagicMock(),
+ 'stl.trex_stl_lib.yaml': mock.MagicMock(),
+ 'stl.trex_stl_lib.zlib': mock.MagicMock(),
+ 'stl.trex_stl_lib.zmq': mock.MagicMock(),
+}
+
+STLClient = mock.MagicMock()
+stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
+stl_patch.start()
+
+if stl_patch:
+ from yardstick.network_services.vnf_generic.vnf.udp_replay import UdpReplayApproxVnf
+ from yardstick.network_services.vnf_generic.vnf import udp_replay
+
+TEST_FILE_YAML = 'nsb_test_case.yaml'
+
+
+NAME = "tg__1"
+
+
+@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Process")
+class TestAclApproxVnf(unittest.TestCase):
+ VNFD = {'vnfd:vnfd-catalog':
+ {'vnfd':
+ [{'short-name': 'VpeVnf',
+ 'vdu':
+ [{'routing_table':
+ [{'network': '152.16.100.20',
+ 'netmask': '255.255.255.0',
+ 'gateway': '152.16.100.20',
+ 'if': 'xe0'},
+ {'network': '152.16.40.20',
+ 'netmask': '255.255.255.0',
+ 'gateway': '152.16.40.20',
+ 'if': 'xe1'}],
+ 'description': 'VPE approximation using DPDK',
+ 'name': 'vpevnf-baremetal',
+ 'nd_route_tbl':
+ [{'network': '0064:ff9b:0:0:0:0:9810:6414',
+ 'netmask': '112',
+ 'gateway': '0064:ff9b:0:0:0:0:9810:6414',
+ 'if': 'xe0'},
+ {'network': '0064:ff9b:0:0:0:0:9810:2814',
+ 'netmask': '112',
+ 'gateway': '0064:ff9b:0:0:0:0:9810:2814',
+ 'if': 'xe1'}],
+ 'id': 'vpevnf-baremetal',
+ 'external-interface':
+ [{'virtual-interface':
+ {'dst_mac': '00:00:00:00:00:04',
+ 'vpci': '0000:05:00.0',
+ 'local_ip': '152.16.100.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': '0',
+ 'bandwidth': '10 Gbps',
+ 'driver': "i40e",
+ 'dst_ip': '152.16.100.20',
+ 'local_iface_name': 'xe0',
+ 'local_mac': '00:00:00:00:00:02'},
+ 'vnfd-connection-point-ref': 'xe0',
+ 'name': 'xe0'},
+ {'virtual-interface':
+ {'dst_mac': '00:00:00:00:00:03',
+ 'vpci': '0000:05:00.1',
+ 'local_ip': '152.16.40.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'driver': "i40e",
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': '1',
+ 'bandwidth': '10 Gbps',
+ 'dst_ip': '152.16.40.20',
+ 'local_iface_name': 'xe1',
+ 'local_mac': '00:00:00:00:00:01'},
+ 'vnfd-connection-point-ref': 'xe1',
+ 'name': 'xe1'}]}],
+ 'description': 'Vpe approximation using DPDK',
+ 'mgmt-interface':
+ {'vdu-id': 'vpevnf-baremetal',
+ 'host': '1.2.1.1',
+ 'password': 'r00t',
+ 'user': 'root',
+ 'ip': '1.2.1.1'},
+ 'benchmark':
+ {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
+ 'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
+ {'type': 'VPORT', 'name': 'xe1'}],
+ 'id': 'UdpReplayApproxVnf', 'name': 'VPEVnfSsh'}]}}
+
+ scenario_cfg = {'options': {'packetsize': 64, 'traffic_type': 4,
+ 'rfc2544': {'allowed_drop_rate': '0.8 - 1'},
+ 'vnf__1': {'rules': 'acl_1rule.yaml',
+ 'vnf_config': {'lb_config': 'SW',
+ 'lb_count': 1,
+ 'worker_config':
+ '1C/1T',
+ 'worker_threads': 1}}
+ },
+ 'task_id': 'a70bdf4a-8e67-47a3-9dc1-273c14506eb7',
+ 'tc': 'tc_ipv4_1Mflow_64B_packetsize',
+ 'runner': {'object': 'NetworkServiceTestCase',
+ 'interval': 35,
+ 'output_filename': '/tmp/yardstick.out',
+ 'runner_id': 74476, 'duration': 400,
+ 'type': 'Duration'},
+ 'traffic_profile': 'ipv4_throughput_acl.yaml',
+ 'traffic_options': {'flow': 'ipv4_Packets_acl.yaml',
+ 'imix': 'imix_voice.yaml'},
+ 'type': 'ISB',
+ 'nodes': {'tg__2': 'trafficgen_2.yardstick',
+ 'tg__1': 'trafficgen_1.yardstick',
+ 'vnf__1': 'vnf.yardstick'},
+ 'topology': 'vpe-tg-topology-baremetal.yaml'}
+
+ context_cfg = {'nodes': {'trafficgen_2.yardstick':
+ {'member-vnf-index': '3',
+ 'role': 'TrafficGen',
+ 'name': 'trafficgen_2.yardstick',
+ 'vnfd-id-ref': 'tg__2',
+ 'ip': '1.2.1.1',
+ 'interfaces':
+ {'xe0': {'local_iface_name': 'ens513f0',
+ 'vld_id': 'public',
+ 'netmask': '255.255.255.0',
+ 'local_ip': '152.16.40.20',
+ 'dst_mac': '00:00:00:00:00:01',
+ 'local_mac': '00:00:00:00:00:03',
+ 'dst_ip': '152.16.40.19',
+ 'driver': 'ixgbe',
+ 'vpci': '0000:02:00.0',
+ 'dpdk_port_num': 0},
+ 'xe1': {'local_iface_name': 'ens513f1',
+ 'netmask': '255.255.255.0',
+ 'network': '202.16.100.0',
+ 'local_ip': '202.16.100.20',
+ 'local_mac': '00:1e:67:d0:60:5d',
+ 'driver': 'ixgbe',
+ 'vpci': '0000:02:00.1',
+ 'dpdk_port_num': 1}},
+ 'password': 'r00t',
+ 'VNF model': 'l3fwd_vnf.yaml',
+ 'user': 'root'},
+ 'trafficgen_1.yardstick':
+ {'member-vnf-index': '1',
+ 'role': 'TrafficGen',
+ 'name': 'trafficgen_1.yardstick',
+ 'vnfd-id-ref': 'tg__1',
+ 'ip': '1.2.1.1',
+ 'interfaces':
+ {'xe0': {'local_iface_name': 'ens785f0',
+ 'vld_id': 'private',
+ 'netmask': '255.255.255.0',
+ 'local_ip': '152.16.100.20',
+ 'dst_mac': '00:00:00:00:00:02',
+ 'local_mac': '00:00:00:00:00:04',
+ 'dst_ip': '152.16.100.19',
+ 'driver': 'i40e',
+ 'vpci': '0000:05:00.0',
+ 'dpdk_port_num': 0},
+ 'xe1': {'local_iface_name': 'ens785f1',
+ 'netmask': '255.255.255.0',
+ 'local_ip': '152.16.100.21',
+ 'local_mac': '00:00:00:00:00:01',
+ 'driver': 'i40e',
+ 'vpci': '0000:05:00.1',
+ 'dpdk_port_num': 1}},
+ 'password': 'r00t',
+ 'VNF model': 'tg_rfc2544_tpl.yaml',
+ 'user': 'root'},
+ 'vnf__1':
+ {'name': 'vnf.yardstick',
+ 'vnfd-id-ref': 'vnf__1',
+ 'ip': '1.2.1.1',
+ 'interfaces':
+ {'xe0': {'local_iface_name': 'ens786f0',
+ 'vld_id': 'private',
+ 'netmask': '255.255.255.0',
+ 'local_ip': '152.16.100.19',
+ 'dst_mac': '00:00:00:00:00:04',
+ 'local_mac': '00:00:00:00:00:02',
+ 'dst_ip': '152.16.100.20',
+ 'driver': 'i40e',
+ 'vpci': '0000:05:00.0',
+ 'dpdk_port_num': 0},
+ 'xe1': {'local_iface_name': 'ens786f1',
+ 'vld_id': 'public',
+ 'netmask': '255.255.255.0',
+ 'local_ip': '152.16.40.19',
+ 'dst_mac': '00:00:00:00:00:03',
+ 'local_mac': '00:00:00:00:00:01',
+ 'dst_ip': '152.16.40.20',
+ 'driver': 'i40e',
+ 'vpci': '0000:05:00.1',
+ 'dpdk_port_num': 1}},
+ 'routing_table':
+ [{'netmask': '255.255.255.0',
+ 'gateway': '152.16.100.20',
+ 'network': '152.16.100.20',
+ 'if': 'xe0'},
+ {'netmask': '255.255.255.0',
+ 'gateway': '152.16.40.20',
+ 'network': '152.16.40.20',
+ 'if': 'xe1'}],
+ 'member-vnf-index': '2',
+ 'host': '1.2.1.1',
+ 'role': 'vnf',
+ 'user': 'root',
+ 'nd_route_tbl':
+ [{'netmask': '112',
+ 'gateway': '0064:ff9b:0:0:0:0:9810:6414',
+ 'network': '0064:ff9b:0:0:0:0:9810:6414',
+ 'if': 'xe0'},
+ {'netmask': '112',
+ 'gateway': '0064:ff9b:0:0:0:0:9810:2814',
+ 'network': '0064:ff9b:0:0:0:0:9810:2814',
+ 'if': 'xe1'}],
+ 'password': 'r00t',
+ 'VNF model': 'udp_replay.yaml'}}}
+
+ def test___init__(self, mock_process):
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd)
+ self.assertIsNone(udp_approx_vnf._vnf_process)
+
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
+ def test_collect_kpi(self, mock_time, mock_process):
+ with mock.patch("yardstick.ssh.SSH") as ssh:
+ ssh_mock = mock.Mock(autospec=ssh.SSH)
+ ssh_mock.execute = \
+ mock.Mock(return_value=(0, "", ""))
+ ssh.from_node.return_value = ssh_mock
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ result = "stats\r\r\n\r\nUDP_Replay stats:\r\n--------------\r\n" \
+ "Port\t\tRx Packet\t\tTx Packet\t\tRx Pkt Drop\t\tTx Pkt Drop \r\n"\
+ "0\t\t7374156\t\t7374136\t\t\t0\t\t\t0\r\n" \
+ "1\t\t7374316\t\t7374315\t\t\t0\t\t\t0\r\n\r\nReplay>\r\r\nReplay>"
+ udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd)
+ udp_approx_vnf.q_in = mock.MagicMock()
+ udp_approx_vnf.q_out = mock.MagicMock()
+ udp_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
+ udp_approx_vnf.all_ports = [0, 1]
+ udp_approx_vnf.interfaces = vnfd["vdu"][0]['external-interface']
+ udp_approx_vnf.get_stats = mock.Mock(return_value=result)
+ result = {'collect_stats': {}, 'packets_dropped': 0,
+ 'packets_fwd': 14748451, 'packets_in': 14748472}
+ self.assertEqual(result, udp_approx_vnf.collect_kpi())
+
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
+ def test_vnf_execute_command(self, mock_time, mock_process):
+ with mock.patch("yardstick.ssh.SSH") as ssh:
+ ssh_mock = mock.Mock(autospec=ssh.SSH)
+ ssh_mock.execute = \
+ mock.Mock(return_value=(0, "", ""))
+ ssh.from_node.return_value = ssh_mock
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd)
+ cmd = "quit"
+ self.assertEqual("", udp_approx_vnf.vnf_execute(cmd))
+
+ def test_get_stats(self, mock_process):
+ with mock.patch("yardstick.ssh.SSH") as ssh:
+ ssh_mock = mock.Mock(autospec=ssh.SSH)
+ ssh_mock.execute = \
+ mock.Mock(return_value=(0, "", ""))
+ ssh.from_node.return_value = ssh_mock
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd)
+ udp_approx_vnf.q_in = mock.MagicMock()
+ udp_approx_vnf.q_out = mock.MagicMock()
+ udp_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
+ mock_result = \
+ "CG-NAPT(.*\n)*Received 100, Missed 0, Dropped 0,Translated 100,ingress"
+ udp_approx_vnf.vnf_execute = mock.Mock(return_value=mock_result)
+ self.assertEqual(mock_result,
+ udp_approx_vnf.get_stats())
+
+ def _get_file_abspath(self, filename):
+ curr_path = os.path.dirname(os.path.abspath(__file__))
+ file_path = os.path.join(curr_path, filename)
+ return file_path
+
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.udp_replay.open')
+ def test__build_pipeline_kwargs(self, mock_open, mock_process):
+ with mock.patch("yardstick.ssh.SSH") as ssh:
+ ssh_mock = mock.Mock(autospec=ssh.SSH)
+ ssh.from_node.return_value = ssh_mock
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd)
+ udp_approx_vnf._build_config = mock.MagicMock()
+ udp_approx_vnf.queue_wrapper = mock.MagicMock()
+ udp_approx_vnf.nfvi_type = "baremetal"
+ udp_approx_vnf.bound_pci = []
+ udp_approx_vnf.all_ports = [0, 1]
+ udp_approx_vnf.ssh_helper = mock.MagicMock(
+ **{"provision_tool.return_value": "tool_path"})
+ udp_approx_vnf.vnf_cfg = {'lb_config': 'SW',
+ 'lb_count': 1,
+ 'worker_config': '1C/1T',
+ 'worker_threads': 1}
+ udp_approx_vnf.options = {'traffic_type': '4',
+ 'topology': 'nsb_test_case.yaml'}
+
+ udp_approx_vnf._build_pipeline_kwargs()
+ self.assertEqual(udp_approx_vnf.pipeline_kwargs, {
+ 'config': '(0, 0, 1)(1, 0, 2)',
+ 'cpu_mask_hex': '0x6',
+ 'hw_csum': '',
+ 'ports_len_hex': '0x3',
+ 'tool_path': 'tool_path',
+ 'whitelist': ''
+ })
+
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.udp_replay.hex")
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.udp_replay.eval")
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.udp_replay.open')
+ def test_run_udp_replay(self, mock_open, eval, hex, mock_process):
+ with mock.patch("yardstick.ssh.SSH") as ssh:
+ ssh_mock = mock.Mock(autospec=ssh.SSH)
+ ssh_mock.execute = \
+ mock.Mock(return_value=(0, "", ""))
+ ssh_mock.run = \
+ mock.Mock(return_value=(0, "", ""))
+ ssh.from_node.return_value = ssh_mock
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd)
+ udp_approx_vnf._build_config = mock.MagicMock()
+ udp_approx_vnf.queue_wrapper = mock.MagicMock()
+ udp_approx_vnf.ssh_helper = mock.MagicMock()
+ udp_approx_vnf.ssh_helper.run = mock.MagicMock()
+ udp_approx_vnf.vnf_cfg = {'lb_config': 'SW',
+ 'lb_count': 1,
+ 'worker_config': '1C/1T',
+ 'worker_threads': 1}
+ udp_approx_vnf.options = {'traffic_type': '4',
+ 'topology': 'nsb_test_case.yaml'}
+
+ udp_approx_vnf._run()
+ udp_approx_vnf.ssh_helper.run.assert_called_once()
+
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
+ def test_instantiate(self, Context, mock_process):
+ with mock.patch("yardstick.ssh.SSH") as ssh:
+ ssh_mock = mock.Mock(autospec=ssh.SSH)
+ ssh_mock.execute = \
+ mock.Mock(return_value=(0, "", ""))
+ ssh.from_node.return_value = ssh_mock
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd)
+ self.scenario_cfg['vnf_options'] = {'cgnapt': {'cfg': "",
+ 'rules': ""}}
+ udp_approx_vnf._run_udp_replay = mock.Mock(return_value=0)
+ udp_approx_vnf._parse_rule_file = mock.Mock(return_value={})
+ udp_approx_vnf.deploy_udp_replay_vnf = mock.Mock(return_value=1)
+ udp_approx_vnf.q_out.put("Replay>")
+ udp_approx_vnf.get_my_ports = mock.Mock(return_value=[0, 1])
+ udp_replay.WAIT_TIME = 3
+ udp_approx_vnf.get_nfvi_type = mock.Mock(return_value="baremetal")
+
+ udp_approx_vnf._vnf_process = mock.MagicMock()
+ udp_approx_vnf._vnf_process.is_alive = \
+ mock.Mock(return_value=1)
+ self.assertIsNone(udp_approx_vnf.instantiate(self.scenario_cfg,
+ self.context_cfg))
+
+ def test_scale(self, mock_process):
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd)
+ flavor = ""
+ self.assertRaises(NotImplementedError, udp_approx_vnf.scale, flavor)
+
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
+ def test_terminate(self, mock_time, mock_process):
+ with mock.patch("yardstick.ssh.SSH") as ssh:
+ ssh_mock = mock.Mock(autospec=ssh.SSH)
+ ssh_mock.execute = \
+ mock.Mock(return_value=(0, "", ""))
+ ssh.from_node.return_value = ssh_mock
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd)
+ udp_approx_vnf._vnf_process = mock.MagicMock()
+ udp_approx_vnf._vnf_process.terminate = mock.Mock()
+ udp_approx_vnf.used_drivers = {"01:01.0": "i40e",
+ "01:01.1": "i40e"}
+ udp_approx_vnf.execute_command = mock.Mock()
+ udp_approx_vnf.ssh_helper = ssh_mock
+ udp_approx_vnf.dpdk_nic_bind = "dpdk_nic_bind.py"
+ self.assertEqual(None, udp_approx_vnf.terminate())
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/yardstick/network_services/vnf_generic/vnf/udp_replay.py b/yardstick/network_services/vnf_generic/vnf/udp_replay.py
new file mode 100644
index 000000000..6e206f2b2
--- /dev/null
+++ b/yardstick/network_services/vnf_generic/vnf/udp_replay.py
@@ -0,0 +1,97 @@
+# Copyright (c) 2016-2017 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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 logging
+
+from yardstick.network_services.vnf_generic.vnf.sample_vnf import SampleVNF
+
+LOG = logging.getLogger(__name__)
+
+# UDP_Replay should work the same on all systems, we can provide the binary
+REPLAY_PIPELINE_COMMAND = (
+ """sudo {tool_path} -c {cpu_mask_hex} -n 4 -w {whitelist} -- """
+ """{hw_csum} -p {ports_len_hex} --config='{config}'"""
+)
+# {tool_path} -p {ports_len_hex} -f {cfg_file} -s {script}'
+
+
+class UdpReplayApproxVnf(SampleVNF):
+
+ APP_NAME = "UDP_Replay"
+ APP_WORD = "UDP_Replay"
+ PIPELINE_COMMAND = REPLAY_PIPELINE_COMMAND
+ VNF_PROMPT = 'Replay>'
+
+ CSUM_MAP = {
+ 'baremetal': '',
+ 'sriov': '',
+ }
+
+ def scale(self, flavor=""):
+ """ scale vnfbased on flavor input """
+ raise NotImplementedError
+
+ def _build_config(self):
+ pass
+
+ def _deploy(self):
+ self.generate_port_pairs()
+ super(UdpReplayApproxVnf, self)._deploy()
+
+ def _build_pipeline_kwargs(self):
+ tool_path = self.ssh_helper.provision_tool(self.APP_NAME)
+ ports_mask = 2 ** len(self.all_ports) - 1
+ ports_mask_hex = hex(ports_mask)
+ cpu_mask_hex = hex(ports_mask * 2)
+ hw_csum = self.CSUM_MAP.get(self.nfvi_type, "--no-hw-csum")
+ config_value = "".join(str((port, 0, port + 1)) for port in self.all_ports)
+
+ whitelist = " -w ".join(self.bound_pci)
+ self.pipeline_kwargs = {
+ 'ports_len_hex': ports_mask_hex,
+ 'tool_path': tool_path,
+ 'hw_csum': hw_csum,
+ 'whitelist': whitelist,
+ 'cpu_mask_hex': cpu_mask_hex,
+ 'config': config_value,
+ }
+
+ def collect_kpi(self):
+ def get_sum(offset):
+ return sum(int(i) for i in split_stats[offset::5])
+
+ stats = self.get_stats()
+ stats_words = stats.split()
+ split_stats = stats_words[stats_words.index('0'):][:len(self.all_ports) * 5]
+ result = {
+ "packets_in": get_sum(1),
+ "packets_fwd": get_sum(2),
+ "packets_dropped": get_sum(3) + get_sum(4),
+ "collect_stats": {},
+ }
+
+ LOG.debug("UDP Replay collect KPIs %s", result)
+ return result
+
+ def get_stats(self):
+ """
+ Method for checking the statistics
+
+ :return:
+ UDP Replay statistics
+ """
+ cmd = 'UDP_Replay stats'
+ out = self.vnf_execute(cmd)
+ return out