Merge "Prox L2FWD multiflow test fix" into stable/gambia
[yardstick.git] / yardstick / network_services / traffic_profile / prox_ACL.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 """ Fixed traffic profile definitions """
15
16 from __future__ import absolute_import
17
18 import logging
19
20 from yardstick.network_services.traffic_profile.prox_profile import ProxProfile
21
22 LOG = logging.getLogger(__name__)
23
24
25 class ProxACLProfile(ProxProfile):
26     """
27     This profile adds a single stream at the beginning of the traffic session
28     """
29
30     def __init__(self, tp_config):
31         super(ProxACLProfile, self).__init__(tp_config)
32
33     def run_test_with_pkt_size(self, traffic_gen, pkt_size, duration):
34         """Run the test for a single packet size.
35
36         :param traffic_gen: traffic generator instance
37         :type traffic_gen: TrafficGen
38         :param  pkt_size: The packet size to test with.
39         :type pkt_size: int
40         :param  duration: The duration for each try.
41         :type duration: int
42
43         """
44
45         test_value = self.upper_bound
46         # throughput and packet loss from the last successful test
47         for _ in range(self.prox_config["attempts"]):
48             result, port_samples = self._profile_helper.run_test(pkt_size, duration,
49                                                                  test_value, self.tolerated_loss)
50
51             samples = result.get_samples(pkt_size, result.pkt_loss, port_samples)
52             self.queue.put(samples)