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