Adding ping based sample VNF appliance
[yardstick.git] / tests / unit / network_services / traffic_profile / test_fixed.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2016-2017 Intel Corporation
4 #
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
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16 #
17
18 from __future__ import absolute_import
19 import unittest
20 import mock
21
22 from yardstick.network_services.traffic_profile.base import TrafficProfile
23 from yardstick.network_services.traffic_profile.fixed import FixedProfile
24
25
26 class TestFixedProfile(unittest.TestCase):
27     TRAFFIC_PROFILE = {
28         "schema": "isb:traffic_profile:0.1",
29         "name": "fixed",
30         "description": "Fixed traffic profile to run UDP traffic",
31         "traffic_profile": {
32             "traffic_type": "FixedTraffic",
33             "frame_rate": 100,  # pps
34             "flow_number": 10,
35             "frame_size": 64}}
36
37     VNFD = {'vnfd:vnfd-catalog':
38             {'vnfd':
39              [{'short-name': 'VpeVnf',
40                'vdu':
41                [{'routing_table':
42                  [{'network': '152.16.100.20',
43                    'netmask': '255.255.255.0',
44                    'gateway': '152.16.100.20',
45                    'if': 'xe0'},
46                   {'network': '152.16.40.20',
47                    'netmask': '255.255.255.0',
48                    'gateway': '152.16.40.20',
49                    'if': 'xe1'}],
50                  'description': 'VPE approximation using DPDK',
51                  'name': 'vpevnf-baremetal',
52                  'nd_route_tbl':
53                  [{'network': '0064:ff9b:0:0:0:0:9810:6414',
54                    'netmask': '112',
55                    'gateway': '0064:ff9b:0:0:0:0:9810:6414',
56                    'if': 'xe0'},
57                   {'network': '0064:ff9b:0:0:0:0:9810:2814',
58                    'netmask': '112',
59                    'gateway': '0064:ff9b:0:0:0:0:9810:2814',
60                    'if': 'xe1'}],
61                  'id': 'vpevnf-baremetal',
62                  'external-interface':
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',
69                     'dpdk_port_num': '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',
74                    'name': 'xe0'},
75                   {'virtual-interface':
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',
81                     'dpdk_port_num': '1',
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',
86                    'name': 'xe1'}]}],
87                'description': 'Vpe approximation using DPDK',
88                'mgmt-interface':
89                    {'vdu-id': 'vpevnf-baremetal',
90                     'host': '1.1.1.1',
91                     'password': 'r00t',
92                     'user': 'root',
93                     'ip': '1.1.1.1'},
94                'benchmark':
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'}]}}
99
100     def test___init__(self):
101         fixed_profile = \
102             FixedProfile(TrafficProfile)
103         self.assertIsNotNone(fixed_profile)
104
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))