Merge "NFVi Test stops after one hour even if configured context duration is longer"
[yardstick.git] / yardstick / network_services / traffic_profile / prox_ramp.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 ProxRampProfile(ProxProfile):
26
27     def run_test_with_pkt_size(self, traffic_gen, pkt_size, duration):
28         """Run the test for a single packet size.
29
30         :param traffic_gen: traffic generator instance
31         :type traffic_gen: TrafficGen
32         :param  pkt_size: The packet size to test with.
33         :type pkt_size: int
34         :param  duration: The duration for each try.
35         :type duration: int
36
37         """
38
39         LOG.info("Testing with packet size %d", pkt_size)
40
41         for test_value in self.bounds_iterator(LOG):
42             test_result = self._profile_helper.run_test(pkt_size, duration,
43                                                         test_value, self.tolerated_loss)
44
45             if not test_result.success:
46                 LOG.debug("Failure... stopping")
47                 break
48
49             LOG.debug("Success! Increasing test value")
50             samples = test_result.get_samples(pkt_size)
51             self.fill_samples(samples, traffic_gen)
52
53             self.queue.put(samples)