3 # Copyright (c) 2016-2017 Intel Corporation
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 from __future__ import absolute_import
23 'stl': mock.MagicMock(),
24 'stl.trex_stl_lib': mock.MagicMock(),
25 'stl.trex_stl_lib.base64': mock.MagicMock(),
26 'stl.trex_stl_lib.binascii': mock.MagicMock(),
27 'stl.trex_stl_lib.collections': mock.MagicMock(),
28 'stl.trex_stl_lib.copy': mock.MagicMock(),
29 'stl.trex_stl_lib.datetime': mock.MagicMock(),
30 'stl.trex_stl_lib.functools': mock.MagicMock(),
31 'stl.trex_stl_lib.imp': mock.MagicMock(),
32 'stl.trex_stl_lib.inspect': mock.MagicMock(),
33 'stl.trex_stl_lib.json': mock.MagicMock(),
34 'stl.trex_stl_lib.linecache': mock.MagicMock(),
35 'stl.trex_stl_lib.math': mock.MagicMock(),
36 'stl.trex_stl_lib.os': mock.MagicMock(),
37 'stl.trex_stl_lib.platform': mock.MagicMock(),
38 'stl.trex_stl_lib.pprint': mock.MagicMock(),
39 'stl.trex_stl_lib.random': mock.MagicMock(),
40 'stl.trex_stl_lib.re': mock.MagicMock(),
41 'stl.trex_stl_lib.scapy': mock.MagicMock(),
42 'stl.trex_stl_lib.socket': mock.MagicMock(),
43 'stl.trex_stl_lib.string': mock.MagicMock(),
44 'stl.trex_stl_lib.struct': mock.MagicMock(),
45 'stl.trex_stl_lib.sys': mock.MagicMock(),
46 'stl.trex_stl_lib.threading': mock.MagicMock(),
47 'stl.trex_stl_lib.time': mock.MagicMock(),
48 'stl.trex_stl_lib.traceback': mock.MagicMock(),
49 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(),
50 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(),
51 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(),
52 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(),
53 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(),
54 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(),
55 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(),
56 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(),
57 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(),
58 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(),
59 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(),
60 'stl.trex_stl_lib.types': mock.MagicMock(),
61 'stl.trex_stl_lib.utils': mock.MagicMock(),
62 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(),
63 'stl.trex_stl_lib.utils.collections': mock.MagicMock(),
64 'stl.trex_stl_lib.utils.common': mock.MagicMock(),
65 'stl.trex_stl_lib.utils.json': mock.MagicMock(),
66 'stl.trex_stl_lib.utils.os': mock.MagicMock(),
67 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(),
68 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(),
69 'stl.trex_stl_lib.utils.random': mock.MagicMock(),
70 'stl.trex_stl_lib.utils.re': mock.MagicMock(),
71 'stl.trex_stl_lib.utils.string': mock.MagicMock(),
72 'stl.trex_stl_lib.utils.sys': mock.MagicMock(),
73 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(),
74 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(),
75 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(),
76 'stl.trex_stl_lib.warnings': mock.MagicMock(),
77 'stl.trex_stl_lib.yaml': mock.MagicMock(),
78 'stl.trex_stl_lib.zlib': mock.MagicMock(),
79 'stl.trex_stl_lib.zmq': mock.MagicMock(),
82 STLClient = mock.MagicMock()
83 stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
87 from yardstick.network_services.traffic_profile.base import TrafficProfile
88 from yardstick.network_services.traffic_profile.fixed import FixedProfile
91 class TestFixedProfile(unittest.TestCase):
93 "schema": "isb:traffic_profile:0.1",
95 "description": "Fixed traffic profile to run UDP traffic",
97 "traffic_type": "FixedTraffic",
98 "frame_rate": 100, # pps
102 VNFD = {'vnfd:vnfd-catalog':
104 [{'short-name': 'VpeVnf',
107 [{'network': '152.16.100.20',
108 'netmask': '255.255.255.0',
109 'gateway': '152.16.100.20',
111 {'network': '152.16.40.20',
112 'netmask': '255.255.255.0',
113 'gateway': '152.16.40.20',
115 'description': 'VPE approximation using DPDK',
116 'name': 'vpevnf-baremetal',
118 [{'network': '0064:ff9b:0:0:0:0:9810:6414',
120 'gateway': '0064:ff9b:0:0:0:0:9810:6414',
122 {'network': '0064:ff9b:0:0:0:0:9810:2814',
124 'gateway': '0064:ff9b:0:0:0:0:9810:2814',
126 'id': 'vpevnf-baremetal',
127 'external-interface':
128 [{'virtual-interface':
129 {'dst_mac': '00:00:00:00:00:04',
130 'vpci': '0000:05:00.0',
131 'local_ip': '152.16.100.19',
132 'type': 'PCI-PASSTHROUGH',
133 'netmask': '255.255.255.0',
134 'dpdk_port_num': '0',
135 'bandwidth': '10 Gbps',
136 'dst_ip': '152.16.100.20',
137 'local_mac': '00:00:00:00:00:01'},
138 'vnfd-connection-point-ref': 'xe0',
140 {'virtual-interface':
141 {'dst_mac': '00:00:00:00:00:03',
142 'vpci': '0000:05:00.1',
143 'local_ip': '152.16.40.19',
144 'type': 'PCI-PASSTHROUGH',
145 'netmask': '255.255.255.0',
146 'dpdk_port_num': '1',
147 'bandwidth': '10 Gbps',
148 'dst_ip': '152.16.40.20',
149 'local_mac': '00:00:00:00:00:02'},
150 'vnfd-connection-point-ref': 'xe1',
152 'description': 'Vpe approximation using DPDK',
154 {'vdu-id': 'vpevnf-baremetal',
160 {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
161 'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
162 {'type': 'VPORT', 'name': 'xe1'}],
163 'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
165 def test___init__(self):
167 FixedProfile(TrafficProfile)
168 self.assertIsNotNone(fixed_profile)
170 def test_execute(self):
171 traffic_generator = mock.Mock(autospec=TrafficProfile)
172 traffic_generator.my_ports = [0, 1]
173 traffic_generator.vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
174 traffic_generator.client = \
175 mock.Mock(return_value=True)
176 fixed_profile = FixedProfile(self.TRAFFIC_PROFILE)
177 fixed_profile.params = self.TRAFFIC_PROFILE
178 fixed_profile.first_run = True
179 self.assertEqual(None, fixed_profile.execute(traffic_generator))