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 from tests.unit import STL_MOCKS
25 STLClient = mock.MagicMock()
26 stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
30 from yardstick.network_services.traffic_profile.base import TrafficProfile
31 from yardstick.network_services.traffic_profile.fixed import FixedProfile
34 class TestFixedProfile(unittest.TestCase):
36 "schema": "isb:traffic_profile:0.1",
38 "description": "Fixed traffic profile to run UDP traffic",
40 "traffic_type": "FixedTraffic",
41 "frame_rate": 100, # pps
45 VNFD = {'vnfd:vnfd-catalog':
47 [{'short-name': 'VpeVnf',
50 [{'network': '152.16.100.20',
51 'netmask': '255.255.255.0',
52 'gateway': '152.16.100.20',
54 {'network': '152.16.40.20',
55 'netmask': '255.255.255.0',
56 'gateway': '152.16.40.20',
58 'description': 'VPE approximation using DPDK',
59 'name': 'vpevnf-baremetal',
61 [{'network': '0064:ff9b:0:0:0:0:9810:6414',
63 'gateway': '0064:ff9b:0:0:0:0:9810:6414',
65 {'network': '0064:ff9b:0:0:0:0:9810:2814',
67 'gateway': '0064:ff9b:0:0:0:0:9810:2814',
69 'id': 'vpevnf-baremetal',
71 [{'virtual-interface':
72 {'dst_mac': '00:00:00:00:00:04',
73 'vpci': '0000:05:00.0',
74 'local_ip': '152.16.100.19',
75 'type': 'PCI-PASSTHROUGH',
76 'netmask': '255.255.255.0',
78 'bandwidth': '10 Gbps',
79 'dst_ip': '152.16.100.20',
80 'local_mac': '00:00:00:00:00:01'},
81 'vnfd-connection-point-ref': 'xe0',
84 {'dst_mac': '00:00:00:00:00:03',
85 'vpci': '0000:05:00.1',
86 'local_ip': '152.16.40.19',
87 'type': 'PCI-PASSTHROUGH',
88 'netmask': '255.255.255.0',
90 'bandwidth': '10 Gbps',
91 'dst_ip': '152.16.40.20',
92 'local_mac': '00:00:00:00:00:02'},
93 'vnfd-connection-point-ref': 'xe1',
95 'description': 'Vpe approximation using DPDK',
97 {'vdu-id': 'vpevnf-baremetal',
103 {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
104 'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
105 {'type': 'VPORT', 'name': 'xe1'}],
106 'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
108 def test___init__(self):
110 FixedProfile(TrafficProfile)
111 self.assertIsNotNone(fixed_profile)
113 def test_execute(self):
114 traffic_generator = mock.Mock(autospec=TrafficProfile)
115 traffic_generator.my_ports = [0, 1]
116 traffic_generator.vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
117 traffic_generator.client = \
118 mock.Mock(return_value=True)
119 fixed_profile = FixedProfile(self.TRAFFIC_PROFILE)
120 fixed_profile.params = self.TRAFFIC_PROFILE
121 fixed_profile.first_run = True
122 self.assertEqual(None, fixed_profile.execute(traffic_generator))