1 # Copyright (c) 2016-2017 Intel Corporation
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
19 from yardstick.tests import STL_MOCKS
21 STLClient = mock.MagicMock()
22 stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
26 from yardstick.network_services.traffic_profile.base import TrafficProfile
27 from yardstick.network_services.traffic_profile.fixed import FixedProfile
30 class TestFixedProfile(unittest.TestCase):
32 "schema": "isb:traffic_profile:0.1",
34 "description": "Fixed traffic profile to run UDP traffic",
36 "traffic_type": "FixedTraffic",
37 "frame_rate": 100, # pps
41 VNFD = {'vnfd:vnfd-catalog':
43 [{'short-name': 'VpeVnf',
46 [{'network': '152.16.100.20',
47 'netmask': '255.255.255.0',
48 'gateway': '152.16.100.20',
50 {'network': '152.16.40.20',
51 'netmask': '255.255.255.0',
52 'gateway': '152.16.40.20',
54 'description': 'VPE approximation using DPDK',
55 'name': 'vpevnf-baremetal',
57 [{'network': '0064:ff9b:0:0:0:0:9810:6414',
59 'gateway': '0064:ff9b:0:0:0:0:9810:6414',
61 {'network': '0064:ff9b:0:0:0:0:9810:2814',
63 'gateway': '0064:ff9b:0:0:0:0:9810:2814',
65 'id': 'vpevnf-baremetal',
67 [{'virtual-interface':
68 {'dst_mac': '00:00:00:00:00:04',
69 'vpci': '0000:05:00.0',
70 'local_ip': '152.16.100.19',
71 'type': 'PCI-PASSTHROUGH',
72 'netmask': '255.255.255.0',
74 'bandwidth': '10 Gbps',
75 'dst_ip': '152.16.100.20',
76 'local_mac': '00:00:00:00:00:01'},
77 'vnfd-connection-point-ref': 'xe0',
80 {'dst_mac': '00:00:00:00:00:03',
81 'vpci': '0000:05:00.1',
82 'local_ip': '152.16.40.19',
83 'type': 'PCI-PASSTHROUGH',
84 'netmask': '255.255.255.0',
86 'bandwidth': '10 Gbps',
87 'dst_ip': '152.16.40.20',
88 'local_mac': '00:00:00:00:00:02'},
89 'vnfd-connection-point-ref': 'xe1',
91 'description': 'Vpe approximation using DPDK',
93 {'vdu-id': 'vpevnf-baremetal',
99 {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
100 'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
101 {'type': 'VPORT', 'name': 'xe1'}],
102 'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
104 def test___init__(self):
105 fixed_profile = FixedProfile(self.TRAFFIC_PROFILE)
106 self.assertIsNotNone(fixed_profile)
108 def test_execute(self):
109 traffic_generator = mock.Mock(autospec=TrafficProfile)
110 traffic_generator.my_ports = [0, 1]
111 traffic_generator.vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
112 traffic_generator.client = \
113 mock.Mock(return_value=True)
114 fixed_profile = FixedProfile(self.TRAFFIC_PROFILE)
115 fixed_profile.params = self.TRAFFIC_PROFILE
116 fixed_profile.first_run = True
117 self.assertIsNone(fixed_profile.execute(traffic_generator))