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
22 from yardstick.network_services.traffic_profile.base import TrafficProfile
23 from yardstick.network_services.traffic_profile.fixed import FixedProfile
26 class TestFixedProfile(unittest.TestCase):
28 "schema": "isb:traffic_profile:0.1",
30 "description": "Fixed traffic profile to run UDP traffic",
32 "traffic_type": "FixedTraffic",
33 "frame_rate": 100, # pps
37 VNFD = {'vnfd:vnfd-catalog':
39 [{'short-name': 'VpeVnf',
42 [{'network': '152.16.100.20',
43 'netmask': '255.255.255.0',
44 'gateway': '152.16.100.20',
46 {'network': '152.16.40.20',
47 'netmask': '255.255.255.0',
48 'gateway': '152.16.40.20',
50 'description': 'VPE approximation using DPDK',
51 'name': 'vpevnf-baremetal',
53 [{'network': '0064:ff9b:0:0:0:0:9810:6414',
55 'gateway': '0064:ff9b:0:0:0:0:9810:6414',
57 {'network': '0064:ff9b:0:0:0:0:9810:2814',
59 'gateway': '0064:ff9b:0:0:0:0:9810:2814',
61 'id': 'vpevnf-baremetal',
63 [{'virtual-interface':
64 {'dst_mac': '00:00:00:00:00:04',
65 'vpci': '0000:05:00.0',
66 'local_ip': '152.16.100.19',
67 'type': 'PCI-PASSTHROUGH',
68 'netmask': '255.255.255.0',
70 'bandwidth': '10 Gbps',
71 'dst_ip': '152.16.100.20',
72 'local_mac': '00:00:00:00:00:01'},
73 'vnfd-connection-point-ref': 'xe0',
76 {'dst_mac': '00:00:00:00:00:03',
77 'vpci': '0000:05:00.1',
78 'local_ip': '152.16.40.19',
79 'type': 'PCI-PASSTHROUGH',
80 'netmask': '255.255.255.0',
82 'bandwidth': '10 Gbps',
83 'dst_ip': '152.16.40.20',
84 'local_mac': '00:00:00:00:00:02'},
85 'vnfd-connection-point-ref': 'xe1',
87 'description': 'Vpe approximation using DPDK',
89 {'vdu-id': 'vpevnf-baremetal',
95 {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
96 'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
97 {'type': 'VPORT', 'name': 'xe1'}],
98 'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
100 def test___init__(self):
102 FixedProfile(TrafficProfile)
103 self.assertIsNotNone(fixed_profile)
105 def test_execute(self):
106 traffic_generator = mock.Mock(autospec=TrafficProfile)
107 traffic_generator.my_ports = [0, 1]
108 traffic_generator.vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
109 traffic_generator.client = \
110 mock.Mock(return_value=True)
111 fixed_profile = FixedProfile(self.TRAFFIC_PROFILE)
112 fixed_profile.params = self.TRAFFIC_PROFILE
113 fixed_profile.first_run = True
114 self.assertEqual(None, fixed_profile.execute(traffic_generator))