1 # Copyright (c) 2018-2019 Intel Corporation
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
19 from yardstick.network_services.traffic_profile import prox_irq
22 class TestProxIrqProfile(unittest.TestCase):
25 self._mock_log_info = mock.patch.object(prox_irq.LOG, 'info')
26 self.mock_log_info = self._mock_log_info.start()
27 self.addCleanup(self._stop_mocks)
29 def _stop_mocks(self):
30 self._mock_log_info.stop()
32 @mock.patch.object(time, 'sleep')
33 def test_execute_1(self, *args):
39 traffic_generator = mock.MagicMock()
40 attrs1 = {'get.return_value' : 10}
41 traffic_generator.scenario_helper.all_options.configure_mock(**attrs1)
43 attrs2 = {'__getitem__.return_value' : 10, 'get.return_value': 10}
44 traffic_generator.scenario_helper.scenario_cfg["runner"].configure_mock(**attrs2)
46 profile_helper = mock.MagicMock()
48 profile = prox_irq.ProxIrqProfile(tp_config)
49 profile.init(mock.MagicMock())
50 profile._profile_helper = profile_helper
52 profile.execute_traffic(traffic_generator)
54 is_ended_flag = profile.is_ended()
56 self.assertFalse(is_ended_flag)
57 self.assertEqual(profile.lower_bound, 10.0)