1 # Copyright (c) 2018 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.
17 from yardstick.common import utils
18 from yardstick.network_services.traffic_profile import pktgen
19 from yardstick.tests.unit import base as ut_base
22 class TestIXIARFC2544Profile(ut_base.BaseUnitTestCase):
25 self._tp_config = {'traffic_profile': {}}
26 self._host = 'localhost'
28 self.tp = pktgen.PktgenTrafficProfile(self._tp_config)
29 self.tp.init(self._host, self._port)
30 self._mock_send_socket_command = mock.patch.object(
31 utils, 'send_socket_command', return_value=0)
32 self.mock_send_socket_command = self._mock_send_socket_command.start()
33 self.addCleanup(self._stop_mock)
36 self._mock_send_socket_command.stop()
40 self.mock_send_socket_command.assert_called_once_with(
41 self._host, self._port, 'pktgen.start("0")')
45 self.mock_send_socket_command.assert_called_once_with(
46 self._host, self._port, 'pktgen.stop("0")')
51 command = 'pktgen.set("0", "rate", 75)'
52 self.mock_send_socket_command.assert_called_once_with(
53 self._host, self._port, command)
55 def test_clear_all_stats(self):
56 self.tp.clear_all_stats()
57 self.mock_send_socket_command.assert_called_once_with(
58 self._host, self._port, 'clr')
62 self.mock_send_socket_command.assert_called_once_with(
63 self._host, self._port, 'help')