Merge "Use "protocol" parameters in iperf3 yaml and task file"
[yardstick.git] / tests / unit / network_services / traffic_profile / test_ixia_rfc2544.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 from __future__ import division
20 import unittest
21 import mock
22
23 from copy import deepcopy
24
25 from tests.unit import STL_MOCKS
26
27 STLClient = mock.MagicMock()
28 stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
29 stl_patch.start()
30
31 if stl_patch:
32     from yardstick.network_services.traffic_profile.traffic_profile \
33         import TrexProfile
34     from yardstick.network_services.traffic_profile.ixia_rfc2544 import \
35         IXIARFC2544Profile
36     from yardstick.network_services.traffic_profile import ixia_rfc2544
37
38
39 class TestIXIARFC2544Profile(unittest.TestCase):
40
41     TRAFFIC_PROFILE = {
42         "schema": "isb:traffic_profile:0.1",
43         "name": "fixed",
44         "description": "Fixed traffic profile to run UDP traffic",
45         "traffic_profile": {
46             "traffic_type": "FixedTraffic",
47             "frame_rate": 100,  # pps
48             "flow_number": 10,
49             "frame_size": 64,
50         },
51     }
52
53     PROFILE = {'description': 'Traffic profile to run RFC2544 latency',
54                'name': 'rfc2544',
55                'traffic_profile': {'traffic_type': 'IXIARFC2544Profile',
56                                    'frame_rate': 100},
57                IXIARFC2544Profile.DOWNLINK: {'ipv4':
58                           {'outer_l2': {'framesize':
59                                         {'64B': '100', '1518B': '0',
60                                          '128B': '0', '1400B': '0',
61                                          '256B': '0', '373b': '0',
62                                          '570B': '0'}},
63                            'outer_l3v4': {'dstip4': '1.1.1.1-1.15.255.255',
64                                           'proto': 'udp', 'count': '1',
65                                           'srcip4': '90.90.1.1-90.105.255.255',
66                                           'dscp': 0, 'ttl': 32},
67                            'outer_l4': {'srcport': '2001',
68                                         'dsrport': '1234'}}},
69                IXIARFC2544Profile.UPLINK: {'ipv4':
70                            {'outer_l2': {'framesize':
71                                          {'64B': '100', '1518B': '0',
72                                           '128B': '0', '1400B': '0',
73                                           '256B': '0', '373b': '0',
74                                           '570B': '0'}},
75                             'outer_l3v4': {'dstip4': '9.9.1.1-90.105.255.255',
76                                            'proto': 'udp', 'count': '1',
77                                            'srcip4': '1.1.1.1-1.15.255.255',
78                                            'dscp': 0, 'ttl': 32},
79                             'outer_l4': {'dstport': '2001',
80                                          'srcport': '1234'}}},
81                'schema': 'isb:traffic_profile:0.1'}
82
83     def test_get_ixia_traffic_profile_error(self):
84         traffic_generator = mock.Mock(autospec=TrexProfile)
85         traffic_generator.my_ports = [0, 1]
86         traffic_generator.uplink_ports = [-1]
87         traffic_generator.downlink_ports = [1]
88         traffic_generator.client = \
89             mock.Mock(return_value=True)
90         STATIC_TRAFFIC = {
91             IXIARFC2544Profile.UPLINK: {
92                 "id": 1,
93                 "bidir": "False",
94                 "duration": 60,
95                 "iload": "100",
96                 "outer_l2": {
97                     "dstmac": "00:00:00:00:00:03",
98                     "framesPerSecond": True,
99                     "framesize": 64,
100                     "srcmac": "00:00:00:00:00:01"
101                 },
102                 "outer_l3": {
103                     "dscp": 0,
104                     "dstip4": "152.16.40.20",
105                     "proto": "udp",
106                     "srcip4": "152.16.100.20",
107                     "ttl": 32
108                 },
109                 "outer_l3v4": {
110                     "dscp": 0,
111                     "dstip4": "152.16.40.20",
112                     "proto": "udp",
113                     "srcip4": "152.16.100.20",
114                     "ttl": 32
115                 },
116                 "outer_l3v6": {
117                     "count": 1024,
118                     "dscp": 0,
119                     "dstip4": "152.16.100.20",
120                     "proto": "udp",
121                     "srcip4": "152.16.40.20",
122                     "ttl": 32
123                 },
124                 "outer_l4": {
125                     "dstport": "2001",
126                     "srcport": "1234"
127                 },
128                 "traffic_type": "continuous"
129             },
130             IXIARFC2544Profile.DOWNLINK: {
131                 "id": 2,
132                 "bidir": "False",
133                 "duration": 60,
134                 "iload": "100",
135                 "outer_l2": {
136                     "dstmac": "00:00:00:00:00:04",
137                     "framesPerSecond": True,
138                     "framesize": 64,
139                     "srcmac": "00:00:00:00:00:01"
140                 },
141                 "outer_l3": {
142                     "count": 1024,
143                     "dscp": 0,
144                     "dstip4": "152.16.100.20",
145                     "proto": "udp",
146                     "srcip4": "152.16.40.20",
147                     "ttl": 32
148                 },
149                 "outer_l3v4": {
150                     "count": 1024,
151                     "dscp": 0,
152                     "dstip4": "152.16.100.20",
153                     "proto": "udp",
154                     "srcip4": "152.16.40.20",
155                     "ttl": 32
156                 },
157                 "outer_l3v6": {
158                     "count": 1024,
159                     "dscp": 0,
160                     "dstip4": "152.16.100.20",
161                     "proto": "udp",
162                     "srcip4": "152.16.40.20",
163                     "ttl": 32
164                 },
165                 "outer_l4": {
166                     "dstport": "1234",
167                     "srcport": "2001"
168                 },
169                 "traffic_type": "continuous"
170             }
171         }
172         ixia_rfc2544.STATIC_TRAFFIC = STATIC_TRAFFIC
173
174         r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
175         r_f_c2544_profile.rate = 100
176         mac = {"src_mac_0": "00:00:00:00:00:01",
177                "src_mac_1": "00:00:00:00:00:02",
178                "src_mac_2": "00:00:00:00:00:02",
179                "dst_mac_0": "00:00:00:00:00:03",
180                "dst_mac_1": "00:00:00:00:00:04",
181                "dst_mac_2": "00:00:00:00:00:04"}
182         result = r_f_c2544_profile._get_ixia_traffic_profile(
183             self.PROFILE, mac, xfile="tmp",
184             static_traffic=STATIC_TRAFFIC)
185         self.assertIsNotNone(result)
186
187     def test_get_ixia_traffic_profile(self):
188         traffic_generator = mock.Mock(autospec=TrexProfile)
189         traffic_generator.my_ports = [0, 1]
190         traffic_generator.uplink_ports = [-1]
191         traffic_generator.downlink_ports = [1]
192         traffic_generator.client = \
193             mock.Mock(return_value=True)
194         STATIC_TRAFFIC = {
195             IXIARFC2544Profile.UPLINK: {
196                 "id": 1,
197                 "bidir": "False",
198                 "duration": 60,
199                 "iload": "100",
200                 "outer_l2": {
201                     "dstmac": "00:00:00:00:00:03",
202                     "framesPerSecond": True,
203                     "framesize": 64,
204                     "srcmac": "00:00:00:00:00:01"
205                 },
206                 "outer_l3": {
207                     "dscp": 0,
208                     "dstip4": "152.16.40.20",
209                     "proto": "udp",
210                     "srcip4": "152.16.100.20",
211                     "ttl": 32
212                 },
213                 "outer_l3v4": {
214                     "dscp": 0,
215                     "dstip4": "152.16.40.20",
216                     "proto": "udp",
217                     "srcip4": "152.16.100.20",
218                     "ttl": 32,
219                     "count": "1"
220                 },
221                 "outer_l3v6": {
222                     "count": 1024,
223                     "dscp": 0,
224                     "dstip4": "152.16.100.20",
225                     "proto": "udp",
226                     "srcip4": "152.16.40.20",
227                     "ttl": 32,
228                     "count": "1"
229                 },
230                 "outer_l4": {
231                     "dstport": "2001",
232                     "srcport": "1234",
233                     "count": "1"
234                 },
235                 "traffic_type": "continuous"
236             },
237             IXIARFC2544Profile.DOWNLINK: {
238                 "id": 2,
239                 "bidir": "False",
240                 "duration": 60,
241                 "iload": "100",
242                 "outer_l2": {
243                     "dstmac": "00:00:00:00:00:04",
244                     "framesPerSecond": True,
245                     "framesize": 64,
246                     "srcmac": "00:00:00:00:00:01"
247                 },
248                 "outer_l3": {
249                     "count": 1024,
250                     "dscp": 0,
251                     "dstip4": "152.16.100.20",
252                     "proto": "udp",
253                     "srcip4": "152.16.40.20",
254                     "ttl": 32
255                 },
256                 "outer_l3v4": {
257                     "count": 1024,
258                     "dscp": 0,
259                     "dstip4": "152.16.100.20",
260                     "proto": "udp",
261                     "srcip4": "152.16.40.20",
262                     "ttl": 32,
263                     "count": "1"
264                 },
265                 "outer_l3v6": {
266                     "count": 1024,
267                     "dscp": 0,
268                     "dstip4": "152.16.100.20",
269                     "proto": "udp",
270                     "srcip4": "152.16.40.20",
271                     "ttl": 32,
272                     "count": "1"
273                 },
274                 "outer_l4": {
275                     "dstport": "1234",
276                     "srcport": "2001",
277                     "count": "1"
278                 },
279                 "traffic_type": "continuous"
280             }
281         }
282         ixia_rfc2544.STATIC_TRAFFIC = STATIC_TRAFFIC
283
284         r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
285         r_f_c2544_profile.rate = 100
286         mac = {"src_mac_0": "00:00:00:00:00:01",
287                "src_mac_1": "00:00:00:00:00:02",
288                "src_mac_2": "00:00:00:00:00:02",
289                "dst_mac_0": "00:00:00:00:00:03",
290                "dst_mac_1": "00:00:00:00:00:04",
291                "dst_mac_2": "00:00:00:00:00:04"}
292         result = r_f_c2544_profile._get_ixia_traffic_profile(
293             self.PROFILE, mac, xfile="tmp", static_traffic=STATIC_TRAFFIC)
294         self.assertIsNotNone(result)
295
296     @mock.patch("yardstick.network_services.traffic_profile.ixia_rfc2544.open")
297     def test_get_ixia_traffic_profile_v6(self, mock_open):
298         traffic_generator = mock.Mock(autospec=TrexProfile)
299         traffic_generator.my_ports = [0, 1]
300         traffic_generator.uplink_ports = [-1]
301         traffic_generator.downlink_ports = [1]
302         traffic_generator.client = \
303             mock.Mock(return_value=True)
304         STATIC_TRAFFIC = {
305             IXIARFC2544Profile.UPLINK: {
306                 "id": 1,
307                 "bidir": "False",
308                 "duration": 60,
309                 "iload": "100",
310                 "outer_l2": {
311                     "dstmac": "00:00:00:00:00:03",
312                     "framesPerSecond": True,
313                     "framesize": 64,
314                     "srcmac": "00:00:00:00:00:01"
315                 },
316                 "outer_l3": {
317                     "dscp": 0,
318                     "dstip4": "152.16.40.20",
319                     "proto": "udp",
320                     "srcip4": "152.16.100.20",
321                     "ttl": 32
322                 },
323                 "outer_l3v4": {
324                     "dscp": 0,
325                     "dstip4": "152.16.40.20",
326                     "proto": "udp",
327                     "srcip4": "152.16.100.20",
328                     "ttl": 32
329                 },
330                 "outer_l3v6": {
331                     "count": 1024,
332                     "dscp": 0,
333                     "dstip4": "152.16.100.20",
334                     "proto": "udp",
335                     "srcip4": "152.16.40.20",
336                     "ttl": 32
337                 },
338                 "outer_l4": {
339                     "dstport": "2001",
340                     "srcport": "1234"
341                 },
342                 "traffic_type": "continuous"
343             },
344             IXIARFC2544Profile.DOWNLINK: {
345                 "id": 2,
346                 "bidir": "False",
347                 "duration": 60,
348                 "iload": "100",
349                 "outer_l2": {
350                     "dstmac": "00:00:00:00:00:04",
351                     "framesPerSecond": True,
352                     "framesize": 64,
353                     "srcmac": "00:00:00:00:00:01"
354                 },
355                 "outer_l3": {
356                     "count": 1024,
357                     "dscp": 0,
358                     "dstip4": "152.16.100.20",
359                     "proto": "udp",
360                     "srcip4": "152.16.40.20",
361                     "ttl": 32
362                 },
363                 "outer_l3v4": {
364                     "count": 1024,
365                     "dscp": 0,
366                     "dstip4": "152.16.100.20",
367                     "proto": "udp",
368                     "srcip4": "152.16.40.20",
369                     "ttl": 32
370                 },
371                 "outer_l3v6": {
372                     "count": 1024,
373                     "dscp": 0,
374                     "dstip4": "152.16.100.20",
375                     "proto": "udp",
376                     "srcip4": "152.16.40.20",
377                     "ttl": 32
378                 },
379                 "outer_l4": {
380                     "dstport": "1234",
381                     "srcport": "2001"
382                 },
383                 "traffic_type": "continuous"
384             }
385         }
386         ixia_rfc2544.STATIC_TRAFFIC = STATIC_TRAFFIC
387
388         r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
389         r_f_c2544_profile.rate = 100
390         mac = {"src_mac_0": "00:00:00:00:00:01",
391                "src_mac_1": "00:00:00:00:00:02",
392                "src_mac_2": "00:00:00:00:00:02",
393                "dst_mac_0": "00:00:00:00:00:03",
394                "dst_mac_1": "00:00:00:00:00:04",
395                "dst_mac_2": "00:00:00:00:00:04"}
396         profile_data = {'description': 'Traffic profile to run RFC2544',
397                         'name': 'rfc2544',
398                         'traffic_profile':
399                         {'traffic_type': 'IXIARFC2544Profile',
400                          'frame_rate': 100},
401                         IXIARFC2544Profile.DOWNLINK:
402                         {'ipv4':
403                          {'outer_l2': {'framesize':
404                                        {'64B': '100', '1518B': '0',
405                                         '128B': '0', '1400B': '0',
406                                         '256B': '0', '373b': '0',
407                                         '570B': '0'}},
408                           'outer_l3v4': {'dstip4': '1.1.1.1-1.15.255.255',
409                                          'proto': 'udp', 'count': '1',
410                                          'srcip4': '90.90.1.1-90.105.255.255',
411                                          'dscp': 0, 'ttl': 32},
412                           'outer_l3v6': {'dstip6': '1.1.1.1-1.15.255.255',
413                                          'proto': 'udp', 'count': '1',
414                                          'srcip6': '90.90.1.1-90.105.255.255',
415                                          'dscp': 0, 'ttl': 32},
416                           'outer_l4': {'srcport': '2001',
417                                        'dsrport': '1234'}}},
418                         IXIARFC2544Profile.UPLINK: {'ipv4':
419                                     {'outer_l2': {'framesize':
420                                                   {'64B': '100', '1518B': '0',
421                                                    '128B': '0', '1400B': '0',
422                                                    '256B': '0', '373b': '0',
423                                                    '570B': '0'}},
424                                      'outer_l3v4':
425                                      {'dstip4': '9.9.1.1-90.105.255.255',
426                                       'proto': 'udp', 'count': '1',
427                                       'srcip4': '1.1.1.1-1.15.255.255',
428                                       'dscp': 0, 'ttl': 32},
429                                      'outer_l3v6':
430                                      {'dstip6': '9.9.1.1-90.105.255.255',
431                                       'proto': 'udp', 'count': '1',
432                                       'srcip6': '1.1.1.1-1.15.255.255',
433                                       'dscp': 0, 'ttl': 32},
434
435                                      'outer_l4': {'dstport': '2001',
436                                                   'srcport': '1234'}}},
437                         'schema': 'isb:traffic_profile:0.1'}
438         result = r_f_c2544_profile._get_ixia_traffic_profile(
439             profile_data, mac, static_traffic=STATIC_TRAFFIC)
440         self.assertIsNotNone(result)
441
442     def test__get_ixia_traffic_profile_default_args(self):
443         r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
444
445         expected = {}
446         result = r_f_c2544_profile._get_ixia_traffic_profile({})
447         self.assertDictEqual(result, expected)
448
449     def test__ixia_traffic_generate(self):
450         traffic_generator = mock.Mock(autospec=TrexProfile)
451         traffic_generator.networks = {
452             "uplink_0": ["xe0"],
453             "downlink_0": ["xe1"],
454         }
455         traffic_generator.client = \
456             mock.Mock(return_value=True)
457         traffic = {IXIARFC2544Profile.DOWNLINK: {'iload': 10},
458                    IXIARFC2544Profile.UPLINK: {'iload': 10}}
459         ixia_obj = mock.MagicMock()
460         r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
461         r_f_c2544_profile.rate = 100
462         result = r_f_c2544_profile._ixia_traffic_generate(traffic_generator,
463                                                           traffic, ixia_obj)
464         self.assertIsNone(result)
465
466     def test_execute(self):
467         traffic_generator = mock.Mock(autospec=TrexProfile)
468         traffic_generator.networks = {
469             "uplink_0": ["xe0"],
470             "downlink_0": ["xe1"],
471         }
472         traffic_generator.client = \
473             mock.Mock(return_value=True)
474         r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
475         r_f_c2544_profile.first_run = True
476         r_f_c2544_profile.params = {IXIARFC2544Profile.DOWNLINK: {'iload': 10},
477                                     IXIARFC2544Profile.UPLINK: {'iload': 10}}
478
479         r_f_c2544_profile.get_streams = mock.Mock()
480         r_f_c2544_profile.full_profile = {}
481         r_f_c2544_profile._get_ixia_traffic_profile = mock.Mock()
482         r_f_c2544_profile.get_multiplier = mock.Mock()
483         r_f_c2544_profile._ixia_traffic_generate = mock.Mock()
484         ixia_obj = mock.MagicMock()
485         self.assertEqual(None, r_f_c2544_profile.execute_traffic(traffic_generator, ixia_obj))
486
487     def test_update_traffic_profile(self):
488         traffic_generator = mock.Mock(autospec=TrexProfile)
489         traffic_generator.networks = {
490             "uplink_0": ["xe0"],  # private, one value for intfs
491             "downlink_0": ["xe1", "xe2"],  # public, two values for intfs
492             "downlink_1": ["xe3"],  # not in TRAFFIC PROFILE
493             "tenant_0": ["xe4"],  # not public or private
494         }
495
496         ports_expected = [8, 3, 5]
497         traffic_generator.vnfd_helper.port_num.side_effect = ports_expected
498         traffic_generator.client.return_value = True
499
500         traffic_profile = deepcopy(self.TRAFFIC_PROFILE)
501         traffic_profile.update({
502             "uplink_0": ["xe0"],
503             "downlink_0": ["xe1", "xe2"],
504         })
505
506         r_f_c2544_profile = IXIARFC2544Profile(traffic_profile)
507         r_f_c2544_profile.full_profile = {}
508         r_f_c2544_profile.get_streams = mock.Mock()
509
510         self.assertIsNone(r_f_c2544_profile.update_traffic_profile(traffic_generator))
511         self.assertEqual(r_f_c2544_profile.ports, ports_expected)
512
513     def test_get_drop_percentage(self):
514         traffic_generator = mock.Mock(autospec=TrexProfile)
515         traffic_generator.networks = {
516             "uplink_0": ["xe0"],
517             "downlink_0": ["xe1"],
518         }
519         traffic_generator.client = \
520             mock.Mock(return_value=True)
521         r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
522         r_f_c2544_profile.params = self.PROFILE
523         ixia_obj = mock.MagicMock()
524         r_f_c2544_profile.execute = mock.Mock()
525         r_f_c2544_profile._get_ixia_traffic_profile = mock.Mock()
526         r_f_c2544_profile._ixia_traffic_generate = mock.Mock()
527         r_f_c2544_profile.get_multiplier = mock.Mock()
528         r_f_c2544_profile.tmp_throughput = 0
529         r_f_c2544_profile.tmp_drop = 0
530         r_f_c2544_profile.full_profile = {}
531         samples = {}
532         for ifname in range(1):
533             name = "xe{}".format(ifname)
534             samples[name] = {"rx_throughput_fps": 20,
535                              "tx_throughput_fps": 20,
536                              "rx_throughput_mbps": 10,
537                              "tx_throughput_mbps": 10,
538                              "RxThroughput": 10,
539                              "TxThroughput": 10,
540                              "in_packets": 1000,
541                              "out_packets": 1000}
542         tol_min = 100.0
543         tolerance = 0.0
544         self.assertIsNotNone(r_f_c2544_profile.get_drop_percentage(
545                              traffic_generator, samples,
546                              tol_min, tolerance, ixia_obj))
547
548     def test_get_drop_percentage_update(self):
549         traffic_generator = mock.Mock(autospec=TrexProfile)
550         traffic_generator.my_ports = [0, 1]
551         traffic_generator.uplink_ports = [0]
552         traffic_generator.downlink_ports = [1]
553         traffic_generator.client = \
554             mock.Mock(return_value=True)
555         r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
556         r_f_c2544_profile.params = self.PROFILE
557         ixia_obj = mock.MagicMock()
558         r_f_c2544_profile.execute = mock.Mock()
559         r_f_c2544_profile._get_ixia_traffic_profile = mock.Mock()
560         r_f_c2544_profile._ixia_traffic_generate = mock.Mock()
561         r_f_c2544_profile.get_multiplier = mock.Mock()
562         r_f_c2544_profile.tmp_throughput = 0
563         r_f_c2544_profile.tmp_drop = 0
564         r_f_c2544_profile.full_profile = {}
565         samples = {}
566         for ifname in range(1):
567             name = "xe{}".format(ifname)
568             samples[name] = {"rx_throughput_fps": 20,
569                              "tx_throughput_fps": 20,
570                              "rx_throughput_mbps": 10,
571                              "tx_throughput_mbps": 10,
572                              "RxThroughput": 10,
573                              "TxThroughput": 10,
574                              "in_packets": 1000,
575                              "out_packets": 1002}
576         tol_min = 0.0
577         tolerance = 1.0
578         self.assertIsNotNone(r_f_c2544_profile.get_drop_percentage(
579                              traffic_generator, samples,
580                              tol_min, tolerance, ixia_obj))
581
582     def test_get_drop_percentage_div_zero(self):
583         traffic_generator = mock.Mock(autospec=TrexProfile)
584         traffic_generator.my_ports = [0, 1]
585         traffic_generator.uplink_ports = [0]
586         traffic_generator.downlink_ports = [1]
587         traffic_generator.client = \
588             mock.Mock(return_value=True)
589         r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
590         r_f_c2544_profile.params = self.PROFILE
591         ixia_obj = mock.MagicMock()
592         r_f_c2544_profile.execute = mock.Mock()
593         r_f_c2544_profile._get_ixia_traffic_profile = mock.Mock()
594         r_f_c2544_profile._ixia_traffic_generate = mock.Mock()
595         r_f_c2544_profile.get_multiplier = mock.Mock()
596         r_f_c2544_profile.tmp_throughput = 0
597         r_f_c2544_profile.tmp_drop = 0
598         r_f_c2544_profile.full_profile = {}
599         samples = {}
600         for ifname in range(1):
601             name = "xe{}".format(ifname)
602             samples[name] = {"rx_throughput_fps": 20,
603                              "tx_throughput_fps": 20,
604                              "rx_throughput_mbps": 10,
605                              "tx_throughput_mbps": 10,
606                              "RxThroughput": 10,
607                              "TxThroughput": 10,
608                              "in_packets": 1000,
609                              "out_packets": 0}
610         tol_min = 0.0
611         tolerance = 0.0
612         r_f_c2544_profile.tmp_throughput = 0
613         self.assertIsNotNone(r_f_c2544_profile.get_drop_percentage(
614                              traffic_generator, samples,
615                              tol_min, tolerance, ixia_obj))
616
617     def test_get_multiplier(self):
618         r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
619         r_f_c2544_profile.max_rate = 100
620         r_f_c2544_profile.min_rate = 100
621         self.assertEqual("1.0", r_f_c2544_profile.get_multiplier())
622
623     def test_start_ixia_latency(self):
624         traffic_generator = mock.Mock(autospec=TrexProfile)
625         traffic_generator.networks = {
626             "uplink_0": ["xe0"],
627             "downlink_0": ["xe1"],
628         }
629         traffic_generator.client = \
630             mock.Mock(return_value=True)
631         r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
632         r_f_c2544_profile.max_rate = 100
633         r_f_c2544_profile.min_rate = 100
634         ixia_obj = mock.MagicMock()
635         r_f_c2544_profile._get_ixia_traffic_profile = \
636             mock.Mock(return_value={})
637         r_f_c2544_profile.full_profile = {}
638         r_f_c2544_profile._ixia_traffic_generate = mock.Mock()
639         self.assertEqual(
640             None,
641             r_f_c2544_profile.start_ixia_latency(traffic_generator,
642                                                  ixia_obj))
643
644
645 if __name__ == '__main__':
646     unittest.main()